Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbridgha2010-03-04 04:26:32 +0000
committercbridgha2010-03-04 04:26:32 +0000
commita976b1117e3e8ef22df402cf9097f06cab8c330f (patch)
tree00da6ff281203b579db2d18bcd8e63ed19bb9cf5 /plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse
parent1c3e345f0d912ac56479ce16adf02354de66b576 (diff)
downloadwebtools.javaee-a976b1117e3e8ef22df402cf9097f06cab8c330f.tar.gz
webtools.javaee-a976b1117e3e8ef22df402cf9097f06cab8c330f.tar.xz
webtools.javaee-a976b1117e3e8ef22df402cf9097f06cab8c330f.zip
[303706] Multiple enhancements to deployment assembly page
Diffstat (limited to 'plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse')
-rw-r--r--plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/CustomWebProjectReferenceWizardFragment.java77
-rw-r--r--plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/WebDependencyPropertyPage.java144
2 files changed, 152 insertions, 69 deletions
diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/CustomWebProjectReferenceWizardFragment.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/CustomWebProjectReferenceWizardFragment.java
index c0b5378e9..9341a869f 100644
--- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/CustomWebProjectReferenceWizardFragment.java
+++ b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/CustomWebProjectReferenceWizardFragment.java
@@ -25,7 +25,6 @@ import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -43,6 +42,7 @@ public class CustomWebProjectReferenceWizardFragment extends ProjectReferenceWiz
private boolean isWebLib;
private Button button;
+ private Composite tableColumnComposite;
@Override
public Composite createComposite(Composite parent, IWizardHandle handle) {
@@ -57,11 +57,14 @@ public class CustomWebProjectReferenceWizardFragment extends ProjectReferenceWiz
}
private void createTable(Composite c) {
- Composite comp = createTableColumnComposite(c);
+ tableColumnComposite = createTableColumnComposite(c);
- viewer = new TreeViewer(comp, SWT.SINGLE | SWT.BORDER);
+ viewer = new TreeViewer(tableColumnComposite, SWT.MULTI | SWT.BORDER);
viewer.setContentProvider(getContentProvider());
viewer.setLabelProvider(getLabelProvider());
+
+
+
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
selChanged();
@@ -69,20 +72,11 @@ public class CustomWebProjectReferenceWizardFragment extends ProjectReferenceWiz
});
viewer.setInput(ResourcesPlugin.getWorkspace());
}
- private Composite newComposite(Composite parent) {
- Composite c = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- layout.marginHeight = 0;
- c.setLayout(layout);
- c.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
- return c;
- }
+
protected void createButtonColumn(Composite parent) {
- Composite buttonColumn = createButtonColumnComposite(parent);
- GridData data = new GridData(GridData.VERTICAL_ALIGN_END);
- buttonColumn.setLayoutData(data);
- button = new Button(buttonColumn, SWT.CHECK);
+
+
+ button = new Button(parent, SWT.CHECK);
button.setText(Messages.getString("CustomWebProjectReferenceWizardFragment.0")); //$NON-NLS-1$
button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
button.addSelectionListener(new SelectionListener() {
@@ -94,34 +88,46 @@ public class CustomWebProjectReferenceWizardFragment extends ProjectReferenceWiz
}
});
}
- public Composite createButtonColumnComposite(Composite parent) {
- Composite aButtonColumn = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- aButtonColumn.setLayout(layout);
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL
- | GridData.VERTICAL_ALIGN_BEGINNING);
- aButtonColumn.setLayoutData(data);
- return aButtonColumn;
- }
- public Composite createTableColumnComposite(Composite parent) {
- Composite aButtonColumn = new Composite(parent, SWT.NONE);
+// public Composite createButtonColumnComposite(Composite parent) {
+// Composite aButtonColumn = new Composite(parent, SWT.NONE);
// GridLayout layout = new GridLayout();
// layout.numColumns = 1;
// layout.marginHeight = 0;
// layout.marginWidth = 0;
- aButtonColumn.setLayout(new FillLayout());
+// aButtonColumn.setLayout(layout);
// GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL
// | GridData.VERTICAL_ALIGN_FILL);
// aButtonColumn.setLayoutData(data);
+// return aButtonColumn;
+// }
+ public Composite createTableColumnComposite(Composite parent) {
+ Composite aButtonColumn = new Composite(parent, SWT.NONE);
+
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ aButtonColumn.setLayout(layout);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ //data.minimumHeight = 500;
+ //data.minimumWidth = 400;
+ aButtonColumn.setLayoutData(data);
return aButtonColumn;
}
protected void handleEdit() {
isWebLib = button.getSelection();
}
+ private Composite newComposite(Composite parent) {
+ Composite c = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.marginHeight = 0;
+ c.setLayout(layout);
+ c.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
+ return c;
+ }
+
@Override
protected String getArchiveName(IProject proj, IVirtualComponent comp) {
@@ -135,9 +141,12 @@ public class CustomWebProjectReferenceWizardFragment extends ProjectReferenceWiz
@Override
public void performFinish(IProgressMonitor monitor) throws CoreException {
- if(!JavaEEProjectUtilities.isUtilityProject(selected))
- {
- J2EEProjectUtilities.createFlexJavaProjectForProjectOperation(selected).execute(monitor, null);
+ for (int i = 0; i < selected.length; i++) {
+ IProject proj = selected[i];
+ if(!JavaEEProjectUtilities.isUtilityProject(proj))
+ {
+ J2EEProjectUtilities.createFlexJavaProjectForProjectOperation(proj).execute(monitor, null);
+ }
}
super.performFinish(monitor);
}
diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/WebDependencyPropertyPage.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/WebDependencyPropertyPage.java
index 755e1299c..39712c37d 100644
--- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/WebDependencyPropertyPage.java
+++ b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/WebDependencyPropertyPage.java
@@ -11,18 +11,32 @@
package org.eclipse.jst.servlet.ui.internal;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
+import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jst.j2ee.internal.J2EEConstants;
import org.eclipse.jst.j2ee.internal.ui.J2EEModuleDependenciesPropertyPage;
import org.eclipse.jst.j2ee.internal.ui.preferences.Messages;
+import org.eclipse.jst.j2ee.project.EarUtilities;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties;
+import org.eclipse.wst.common.componentcore.internal.operation.CreateReferenceComponentsDataModelProvider;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.ui.ModuleCoreUIPlugin;
import org.eclipse.wst.common.componentcore.ui.internal.propertypage.DependencyPageExtensionManager;
import org.eclipse.wst.common.componentcore.ui.internal.propertypage.DependencyPageExtensionManager.ReferenceExtension;
import org.eclipse.wst.common.componentcore.ui.propertypage.ModuleAssemblyRootPage;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
public class WebDependencyPropertyPage extends J2EEModuleDependenciesPropertyPage {
@@ -33,14 +47,6 @@ public class WebDependencyPropertyPage extends J2EEModuleDependenciesPropertyPag
super(project, page);
}
- @Override
- protected String getRuntimePath(IVirtualComponent addedComp, String wizardPath) {
-// if (addingWebLib) {
-// String lastSegment = new Path(wizardPath).lastSegment();
-// return new Path(J2EEConstants.WEB_INF_LIB).append(lastSegment).makeAbsolute().toString();
-// }
- return super.getRuntimePath(addedComp, wizardPath);
- }
@Override
protected void createPushButtons() {
@@ -57,33 +63,6 @@ public class WebDependencyPropertyPage extends J2EEModuleDependenciesPropertyPag
return Messages.WebDependencyPropertyPage_0;
}
-
-// @Override
-// protected void handleAddReferenceButton() {
-//
-// addingWebLib = false;
-// super.handleAddReferenceButton();
-// }
-// @Override
-// public void handleEvent(Event event) {
-// super.handleEvent(event);
-// if( event.widget == addWebLibRefButton)
-// handleAddWebLibMappingButton();
-//
-// }
-
- @Override
- protected void addComponents(ArrayList<IVirtualComponent> components) throws CoreException {
- // First add the components
- super.addComponents(components);
- // Now add to MANIFEST
-
- }
-
-// private void handleAddWebLibMappingButton() {
-// addingWebLib = true;
-// showReferenceWizard(false);
-// }
@Override
protected String getModuleAssemblyRootPageDescription() {
@@ -98,6 +77,8 @@ public class WebDependencyPropertyPage extends J2EEModuleDependenciesPropertyPag
for (Iterator iterator = components.iterator(); iterator.hasNext();) {
IVirtualComponent comp = (IVirtualComponent) iterator.next();
String runtimePath = objectToRuntimePath.get(comp);
+ if (runtimePath == null)
+ runtimePath = derivedRefsObjectToRuntimePath.get(comp);
if (runtimePath.indexOf(J2EEConstants.WEB_INF_LIB) == -1) {
String archiveName = new Path(runtimePath).lastSegment();
newComps.append(archiveName);
@@ -117,4 +98,97 @@ public class WebDependencyPropertyPage extends J2EEModuleDependenciesPropertyPag
}
return defaults;
}
+ protected IDataModelProvider getAddWebReferenceDataModelProvider(IVirtualComponent component) {
+ return new CreateReferenceComponentsDataModelProvider();
+ }
+
+
+ @Override
+ protected void insertIntoTable(boolean consumed, IVirtualComponent[] compArr, String[] pathArr) {
+
+ for( int i = 0; i < compArr.length; i++ ) {
+ if (pathArr[i].indexOf(J2EEConstants.WEB_INF_LIB) == -1)
+ derivedRefsObjectToRuntimePath.put(compArr[i],getRuntimePath(compArr[i], pathArr[i]));
+ else
+ objectToRuntimePath.put(compArr[i],getRuntimePath(compArr[i], pathArr[i]));
+ if( consumed )
+ consumedReferences.add(compArr[i]);
+ }
+ }
+
+
+ @Override
+ protected void addOneComponent(IVirtualComponent component) throws CoreException {
+
+
+ String runtimePath = objectToRuntimePath.get(component);
+ if (runtimePath == null)
+ runtimePath = derivedRefsObjectToRuntimePath.get(component);
+ if (runtimePath.indexOf(J2EEConstants.WEB_INF_LIB) != -1) {
+ addWebRef(component);
+ return;
+ }
+
+
+ String path, archiveName;
+ path = new Path(derivedRefsObjectToRuntimePath.get(component)).removeLastSegments(1).toString();
+ archiveName = new Path(derivedRefsObjectToRuntimePath.get(component)).lastSegment();
+
+
+ //Find the Ear's that contain this component
+ IProject[] earProjects = EarUtilities.getReferencingEARProjects(rootComponent.getProject());
+ for (int i = 0; i < earProjects.length; i++) {
+ IProject project = earProjects[i];
+
+ IDataModelProvider provider = getAddReferenceDataModelProvider(component);
+ IDataModel dm = DataModelFactory.createDataModel(provider);
+
+ dm.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, ComponentCore.createComponent(project));
+ dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, Arrays.asList(component));
+
+ //[Bug 238264] the uri map needs to be manually set correctly
+ Map<IVirtualComponent, String> uriMap = new HashMap<IVirtualComponent, String>();
+ uriMap.put(component, archiveName);
+ dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, uriMap);
+ dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH, path);
+
+ IStatus stat = dm.validateProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST);
+ if (stat != OK_STATUS)
+ throw new CoreException(stat);
+ try {
+ dm.getDefaultOperation().execute(new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ ModuleCoreUIPlugin.logError(e);
+ }
+ }
+
+ }
+
+
+ private void addWebRef(IVirtualComponent component) throws CoreException {
+ String path, archiveName;
+ path = new Path(objectToRuntimePath.get(component)).removeLastSegments(1).toString();
+ archiveName = new Path(objectToRuntimePath.get(component)).lastSegment();
+
+ IDataModelProvider provider = getAddWebReferenceDataModelProvider(component);
+ IDataModel dm = DataModelFactory.createDataModel(provider);
+
+ dm.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, rootComponent);
+ dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, Arrays.asList(component));
+
+ //[Bug 238264] the uri map needs to be manually set correctly
+ Map<IVirtualComponent, String> uriMap = new HashMap<IVirtualComponent, String>();
+ uriMap.put(component, archiveName);
+ dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, uriMap);
+ dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH, path);
+
+ IStatus stat = dm.validateProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST);
+ if (stat != OK_STATUS)
+ throw new CoreException(stat);
+ try {
+ dm.getDefaultOperation().execute(new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ ModuleCoreUIPlugin.logError(e);
+ }
+ }
}

Back to the top