Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 271355
Collapse All | Expand All

(-)j2ee_ui/org/eclipse/jst/j2ee/internal/actions/J2EEDeployAction.java (-30 / +47 lines)
Lines 33-44 Link Here
33
import org.eclipse.jface.dialogs.MessageDialog;
33
import org.eclipse.jface.dialogs.MessageDialog;
34
import org.eclipse.jface.viewers.ISelection;
34
import org.eclipse.jface.viewers.ISelection;
35
import org.eclipse.jface.viewers.IStructuredSelection;
35
import org.eclipse.jface.viewers.IStructuredSelection;
36
import org.eclipse.jst.j2ee.componentcore.EnterpriseArtifactEdit;
36
import org.eclipse.jst.j2ee.internal.deploy.DeployerRegistry;
37
import org.eclipse.jst.j2ee.internal.deploy.DeployerRegistry;
37
import org.eclipse.jst.j2ee.internal.deploy.J2EEDeployOperation;
38
import org.eclipse.jst.j2ee.internal.deploy.J2EEDeployOperation;
38
import org.eclipse.jst.j2ee.internal.dialogs.RuntimeSelectionDialog;
39
import org.eclipse.jst.j2ee.internal.dialogs.RuntimeSelectionDialog;
40
import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin;
39
import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages;
41
import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages;
40
import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
42
import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
41
import org.eclipse.swt.widgets.Shell;
43
import org.eclipse.swt.widgets.Shell;
44
import org.eclipse.wst.common.componentcore.ComponentCore;
45
import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities;
46
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
42
import org.eclipse.wst.common.frameworks.internal.WTPResourceHandler;
47
import org.eclipse.wst.common.frameworks.internal.WTPResourceHandler;
43
import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
48
import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
44
import org.eclipse.wst.server.core.IRuntime;
49
import org.eclipse.wst.server.core.IRuntime;
Lines 108-151 Link Here
108
113
109
	
114
	
110
	public boolean checkEnabled(Shell shell) {
115
	public boolean checkEnabled(Shell shell) {
111
112
		try {
116
		try {
113
			DeployerRegistry reg = DeployerRegistry.instance();
117
			DeployerRegistry reg = DeployerRegistry.instance();
114
118
			Object[] modules = selection.toArray();
115
			List modules = DeployerRegistry.getSelectedModules(selection.toArray());
119
			for (int i = 0; i < modules.length; i++) {
116
			for (int i = 0; i < modules.size(); i++) {
120
				Object object = modules[i];
117
				EObject module = (EObject) modules.get(i);
121
				if (object instanceof EObject) {
118
				IProject proj = ProjectUtilities.getProject(module);
122
					object = ProjectUtilities.getProject(object);
119
				if (proj == null) {
120
					displayMessageDialog(J2EEUIMessages.getResourceString("DEPLOY_PROJECT_NOT_FOUND") , shell);
121
					return false;
122
				}
123
				}
123
				
124
				if (!(object instanceof IProject)) {
124
				IRuntime runtime = J2EEProjectUtilities.getServerRuntime(proj);
125
					continue;
125
				if (runtime == null) {
126
					String message = MessageFormat.format(J2EEUIMessages.getResourceString("DEPLOY_RUNTIME_NOT_FOUND"), new String []{proj.getName()});
127
					RuntimeSelectionDialog selectionDialog = new RuntimeSelectionDialog(shell, 
128
							J2EEUIMessages.getResourceString("DEPLOY_DIALOG_TITLE"), 
129
 								null /* default image */, 
130
 								message, 
131
 								MessageDialog.ERROR, 
132
 								new String[] { IDialogConstants.OK_LABEL }, 0, proj) ;
133
					selectionDialog.open();
134
					runtime = J2EEProjectUtilities.getServerRuntime(proj);
135
					if (runtime == null)
136
						return false;
137
				}
126
				}
138
				List visitors = reg.getDeployModuleExtensions(module, runtime);
127
				IVirtualComponent component = ComponentCore.createComponent((IProject) object);
139
				if (visitors.isEmpty()) {
128
				EnterpriseArtifactEdit edit = null;
140
					displayMessageDialog(MessageFormat.format(J2EEUIMessages.getResourceString("DEPLOY_PROJECT_NOT_SUPPORTED"), new String []{proj.getName()}), shell);
129
				try {
141
					return false;
130
					edit = (EnterpriseArtifactEdit) ComponentUtilities.getArtifactEditForRead(component);
131
					if (edit == null)
132
						continue;
133
					EObject module = edit.getDeploymentDescriptorRoot();
134
					IProject proj = (IProject) object;
135
					if (proj == null) {
136
						displayMessageDialog(J2EEUIMessages.getResourceString("DEPLOY_PROJECT_NOT_FOUND"), shell);
137
						return false;
138
					}
139
					IRuntime runtime = J2EEProjectUtilities.getServerRuntime(proj);
140
					if (runtime == null) {
141
						String message = MessageFormat.format(J2EEUIMessages.getResourceString("DEPLOY_RUNTIME_NOT_FOUND"), new String[] { proj.getName() });
142
						RuntimeSelectionDialog selectionDialog = new RuntimeSelectionDialog( shell,
143
								J2EEUIMessages.getResourceString("DEPLOY_DIALOG_TITLE"),
144
								null /* default image */, message,
145
								MessageDialog.ERROR,
146
								new String[] { IDialogConstants.OK_LABEL }, 0, proj);
147
						selectionDialog.open();
148
						runtime = J2EEProjectUtilities.getServerRuntime(proj);
149
						if (runtime == null)
150
							return false;
151
					}
152
					List visitors = reg.getDeployModuleExtensions(module, runtime);
153
					if (visitors.isEmpty()) {
154
						displayMessageDialog( MessageFormat.format( J2EEUIMessages.getResourceString("DEPLOY_PROJECT_NOT_SUPPORTED"),
155
																				new String[] { proj.getName() }), shell);
156
						return false;
157
					}
158
				} finally {
159
					if (edit != null)
160
						edit.dispose();
142
				}
161
				}
143
				
144
			}
162
			}
145
			
146
			return true;
163
			return true;
147
		} catch (CoreException e) {
164
		} catch (CoreException e) {
148
			System.out.println("Deploy Action recovering from problem verifying enablement."); //$NON-NLS-1$
165
			J2EEPlugin.log(4, -1, "Deploy Action recovering from problem verifying enablement.", e); //$NON-NLS-1$
149
			e.printStackTrace();
166
			e.printStackTrace();
150
		}
167
		}
151
		return false;
168
		return false;

Return to bug 271355