Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrstryker2010-03-30 09:07:19 +0000
committerrstryker2010-03-30 09:07:19 +0000
commitdbf11c13dd30ae313f0567acd53756476206a5e7 (patch)
tree0dcb81f5cec681cc9c16adf50b5b3590033a9803 /plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse
parente6ac0be0e4c2d00d8f8614d169e43be7a39434b9 (diff)
downloadwebtools.javaee-dbf11c13dd30ae313f0567acd53756476206a5e7.tar.gz
webtools.javaee-dbf11c13dd30ae313f0567acd53756476206a5e7.tar.xz
webtools.javaee-dbf11c13dd30ae313f0567acd53756476206a5e7.zip
Bug 307148 - [UI] [API] Wrapper bug for j2ee 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/Messages.java12
-rw-r--r--plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/WebDependencyPropertyPage.java151
-rw-r--r--plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/WebModuleDependencyPageProvider.java51
-rw-r--r--plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/messages.properties3
4 files changed, 59 insertions, 158 deletions
diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/Messages.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/Messages.java
index 4682d9fa7..189ab7260 100644
--- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/Messages.java
+++ b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/Messages.java
@@ -3,8 +3,18 @@ package org.eclipse.jst.servlet.ui.internal;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-public class Messages {
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.jst.servlet.ui.internal.messages"; //$NON-NLS-1$
+ public static String DeploymentAssembly;
+ public static String WebDeploymentAssembly;
+ public static String ManifestEntries;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
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 2ccb4b609..f6f056540 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
@@ -10,38 +10,15 @@
******************************************************************************/
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 {
-// protected Button addWebLibRefButton;
-// private boolean addingWebLib = true;
public WebDependencyPropertyPage(IProject project,
ModuleAssemblyRootPage page) {
super(project, page);
@@ -50,44 +27,18 @@ public class WebDependencyPropertyPage extends J2EEModuleDependenciesPropertyPag
@Override
protected void createPushButtons() {
-
- addMappingButton = createPushButton(getAddFolderLabel());
- addReferenceButton = createPushButton(getAddReferenceLabel());
- //addWebLibRefButton = createPushButton(getAddWebLibRefLabel());
- editReferenceButton = createPushButton(getEditReferenceLabel());
- removeButton = createPushButton(getRemoveSelectedLabel());
-
+ super.createPushButtons();
}
protected String getAddWebLibRefLabel() {
-
return Messages.WebDependencyPropertyPage_0;
}
@Override
protected String getModuleAssemblyRootPageDescription() {
-
return Messages.WebDependencyPropertyPage_1;
}
-
- @Override
- protected StringBuffer getCompsForManifest(ArrayList<IVirtualComponent> components) {
- StringBuffer newComps = new StringBuffer();
- 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);
- newComps.append(' ');
- }
- }
- return newComps;
- }
-
@Override
protected ReferenceExtension[] filterReferenceTypes(ReferenceExtension[] defaults) {
// Replace the default one with our own custom one, in class CustomWebProjectReferenceWizardFragment
@@ -98,104 +49,4 @@ 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 removeComponents(ArrayList<IVirtualComponent> removed) {
- Iterator<IVirtualComponent> i = removed.iterator();
- while(i.hasNext()) {
- removeOneComponent(i.next());
- }
- }
-
-
- @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);
- }
- }
}
diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/WebModuleDependencyPageProvider.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/WebModuleDependencyPageProvider.java
index 38c91b827..53ed574ba 100644
--- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/WebModuleDependencyPageProvider.java
+++ b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/WebModuleDependencyPageProvider.java
@@ -12,8 +12,13 @@
package org.eclipse.jst.servlet.ui.internal;
import org.eclipse.core.resources.IProject;
-import org.eclipse.jst.j2ee.internal.ui.Messages;
+import org.eclipse.jst.common.internal.modulecore.util.JavaModuleComponentUtility;
+import org.eclipse.jst.common.ui.internal.assembly.wizard.ManifestModuleDependencyControl;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
import org.eclipse.wst.common.componentcore.ui.propertypage.IDependencyPageProvider;
import org.eclipse.wst.common.componentcore.ui.propertypage.IModuleDependenciesControl;
@@ -23,28 +28,60 @@ import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
public class WebModuleDependencyPageProvider implements IDependencyPageProvider {
+ private IModuleDependenciesControl[] controls;
+
public boolean canHandle(IFacetedProject project) {
boolean isWeb = project.hasProjectFacet(ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_WEB_MODULE));
return isWeb;
}
+ /*
+ * This now allows extenders to say whether this project is standalone or not
+ */
+ protected boolean isStandalone(IProject project) {
+ return JavaModuleComponentUtility.findParentProjects(project).length == 0;
+ }
+
public IModuleDependenciesControl[] createPages(IFacetedProject project,
ModuleAssemblyRootPage parent) {
+
+ if( isStandalone(project.getProject()))
+ return new IModuleDependenciesControl[] {
+ new WebDependencyPropertyPage(project.getProject(), parent)};
+
return new IModuleDependenciesControl[] {
+ new ManifestModuleDependencyControl(project.getProject(), parent),
new WebDependencyPropertyPage(project.getProject(), parent)
};
}
public Composite createRootControl(IFacetedProject project,IModuleDependenciesControl[] pages,
Composite parent) {
- if( pages.length == 1 && pages[0] != null)
+
+ if( isStandalone(project.getProject()))
return pages[0].createContents(parent);
- return null;
+
+ final TabFolder folder = new TabFolder(parent, SWT.LEFT);
+ folder.setLayoutData(new GridData(GridData.FILL_BOTH));
+ folder.setFont(parent.getFont());
+
+ // Create the two tabs
+ controls = new IModuleDependenciesControl[2];
+ controls[0] = pages[0];
+ controls[1] = pages[1];
+
+ TabItem tab = new TabItem(folder, SWT.NONE);
+ tab.setControl(controls[0].createContents(folder));
+ tab.setText(Messages.ManifestEntries);
+ tab = new TabItem(folder, SWT.NONE);
+ tab.setControl(controls[1].createContents(folder));
+ tab.setText(Messages.DeploymentAssembly);
+
+ folder.setSelection(0);
+ return folder;
}
-public String getPageTitle(IProject project) {
- return Messages.J2EEDependencyPageProvider_0;
+ public String getPageTitle(IProject project) {
+ return Messages.WebDeploymentAssembly;
}
-
-
}
diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/messages.properties b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/messages.properties
index 62b854c70..fed5f7c9e 100644
--- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/messages.properties
+++ b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/messages.properties
@@ -1,2 +1,5 @@
CustomWebProjectReferenceWizardFragment.0=Web Library Reference
WebProjectReferenceDescription=Here you can make a project into a reference.\nIf the project is not already a flexible project, it will be converted into one. References are added to the MANIFEST.MF
+DeploymentAssembly=Deployment Assembly
+WebDeploymentAssembly=Web Deployment Assembly
+ManifestEntries=Manifest Entries

Back to the top