Author: rob.stryker(a)jboss.com
Date: 2009-07-24 17:54:30 -0400 (Fri, 24 Jul 2009)
New Revision: 16788
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddFolderDialog.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/WTPOveridePlugin.java
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddModuleDependenciesPropertiesPage.java
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ComponentDependencyContentProvider.java
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ModuleAssemblyRootPage.java
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/impl/EarModuleDependenciesPropertyPage.java
Log:
JBIDE-4320 - more work on the properties page
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/META-INF/MANIFEST.MF
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/META-INF/MANIFEST.MF 2009-07-24
19:47:01 UTC (rev 16787)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/META-INF/MANIFEST.MF 2009-07-24
21:54:30 UTC (rev 16788)
@@ -24,7 +24,8 @@
org.jboss.ide.eclipse.as.wtp.override.core;bundle-version="1.0.0",
org.eclipse.wst.server.ui;bundle-version="1.1.102",
org.eclipse.wst.server.core;bundle-version="1.1.101",
- org.eclipse.wst.common.emfworkbench.integration;bundle-version="1.1.300"
+ org.eclipse.wst.common.emfworkbench.integration;bundle-version="1.1.300",
+ org.eclipse.emf.ecore;bundle-version="2.5.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: JBoss by Red Hat
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/WTPOveridePlugin.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/WTPOveridePlugin.java 2009-07-24
19:47:01 UTC (rev 16787)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/WTPOveridePlugin.java 2009-07-24
21:54:30 UTC (rev 16788)
@@ -1,6 +1,8 @@
package org.jboss.ide.eclipse.as.wtp.override.ui;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -57,5 +59,29 @@
IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, message, e);
getDefault().getLog().log(status);
}
+ public static IStatus createStatus(int severity, int aCode,
+ String aMessage, Throwable exception) {
+ return new Status(severity, PLUGIN_ID, aCode,
+ aMessage != null ? aMessage : "No message.", exception); //$NON-NLS-1$
+ }
+ public static IStatus createErrorStatus(int aCode, String aMessage,
+ Throwable exception) {
+ return createStatus(IStatus.ERROR, aCode, aMessage, exception);
+ }
+ public static IStatus createStatus(int severity, String message, Throwable exception) {
+ return new Status(severity, PLUGIN_ID, message, exception);
+ }
+
+ public static IStatus createStatus(int severity, String message) {
+ return createStatus(severity, message, null);
+ }
+ public static void logError(Throwable exception) {
+ Platform.getLog(Platform.getBundle(PLUGIN_ID)).log( createStatus(IStatus.ERROR,
exception.getMessage(), exception));
+ }
+
+ public static void logError(CoreException exception) {
+ Platform.getLog(Platform.getBundle(PLUGIN_ID)).log( exception.getStatus() );
+ }
+
}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddFolderDialog.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddFolderDialog.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddFolderDialog.java 2009-07-24
21:54:30 UTC (rev 16788)
@@ -0,0 +1,133 @@
+package org.jboss.ide.eclipse.as.wtp.override.ui.propertypage;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+public class AddFolderDialog extends TitleAreaDialog {
+ private IProject project;
+ private TreeViewer viewer;
+ private IContainer selected = null;
+ public AddFolderDialog(Shell parentShell, IProject project) {
+ super(parentShell);
+ this.project = project;
+ }
+
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ shell.setText("Add Folder");
+ shell.setBounds(shell.getLocation().x, shell.getLocation().y, 400,300);
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite c = (Composite)super.createDialogArea(parent);
+ this.viewer = new TreeViewer(c, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL |
SWT.BORDER);
+ viewer.setContentProvider(getContentProvider());
+ viewer.setLabelProvider(getLabelProvider());
+ viewer.addFilter(getFilter());
+ viewer.setInput(project);
+ viewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
+ viewer.addSelectionChangedListener(getListener());
+ return c;
+ }
+
+ protected ISelectionChangedListener getListener() {
+ return new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection sel = (IStructuredSelection)viewer.getSelection();
+ Object first = sel.getFirstElement();
+ if( first instanceof IContainer)
+ selected = (IContainer)first;
+ }
+ };
+ }
+
+ public IContainer getSelected() {
+ return selected;
+ }
+
+ protected ViewerFilter getFilter() {
+ return new ViewerFilter() {
+ public boolean select(Viewer viewer, Object parentElement,
+ Object element) {
+ return element instanceof IContainer;
+ }
+ };
+ }
+
+ protected ITreeContentProvider getContentProvider() {
+ return new ITreeContentProvider() {
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ public void dispose() {
+ }
+
+ public Object[] getElements(Object inputElement) {
+ try {
+ return project.members();
+ } catch( CoreException ce ) {
+ return new Object[]{};
+ }
+ }
+
+ public boolean hasChildren(Object element) {
+ if( element instanceof IContainer) {
+ try {
+ return ((IContainer)element).members().length > 0;
+ } catch( CoreException ce ) {
+ }
+ }
+ return false;
+ }
+
+ public Object getParent(Object element) {
+ if( element instanceof IResource)
+ return ((IResource)element).getParent();
+ return null;
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ if( parentElement instanceof IContainer) {
+ try {
+ return ((IContainer)parentElement).members();
+ } catch( CoreException ce ) {
+ }
+ }
+ return new Object[]{};
+ }
+ };
+ }
+
+ protected LabelProvider getLabelProvider() {
+ return new LabelProvider() {
+ public Image getImage(Object element) {
+ return
PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
+ }
+ public String getText(Object element) {
+ if( element instanceof IResource)
+ return ((IResource)element).getName();
+ return element.toString();
+ }
+ };
+ }
+}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddModuleDependenciesPropertiesPage.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddModuleDependenciesPropertiesPage.java 2009-07-24
19:47:01 UTC (rev 16787)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddModuleDependenciesPropertiesPage.java 2009-07-24
21:54:30 UTC (rev 16788)
@@ -20,6 +20,7 @@
import java.util.Map;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.IWorkspaceRunnable;
@@ -44,7 +45,6 @@
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages;
-import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
@@ -66,10 +66,14 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.wst.common.componentcore.ComponentCore;
import
org.eclipse.wst.common.componentcore.datamodel.properties.ICreateReferenceComponentsDataModelProperties;
+import org.eclipse.wst.common.componentcore.internal.ComponentResource;
+import org.eclipse.wst.common.componentcore.internal.StructureEdit;
+import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent;
import
org.eclipse.wst.common.componentcore.internal.operation.CreateReferenceComponentsDataModelProvider;
import
org.eclipse.wst.common.componentcore.internal.operation.RemoveReferenceComponentsDataModelProvider;
import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
@@ -77,6 +81,7 @@
import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
import org.jboss.ide.eclipse.as.wtp.override.core.vcf.ComponentUtils;
import org.jboss.ide.eclipse.as.wtp.override.ui.Messages;
+import org.jboss.ide.eclipse.as.wtp.override.ui.WTPOveridePlugin;
public class AddModuleDependenciesPropertiesPage implements Listener,
IModuleDependenciesControl {
@@ -99,14 +104,19 @@
protected Listener tableListener;
protected Listener labelListener;
+ // Mappings that existed when the page was opened (or last saved)
protected HashMap<IVirtualComponent, String> oldComponentToRuntimePath = new
HashMap<IVirtualComponent, String>();
- // This should keep a list of all elements currently in the list (not removed)
+ // Mappings that are current
protected HashMap<IVirtualComponent, String> objectToRuntimePath = new
HashMap<IVirtualComponent, String>();
- protected HashMap<Object, Object> oldResourceMappings = new HashMap<Object,
Object>();
- protected HashMap<Object, Object> newResourceMappings = new HashMap<Object,
Object>();
+ // A single list of wb-resource mappings. If there's any change,
+ // all old will be removed and new ones added
+ protected ArrayList<ComponentResourceProxy> resourceMappings = new
ArrayList<ComponentResourceProxy>();
+ // keeps track if a change has occurred in wb-resource mappings
+ protected boolean resourceMappingsChanged = false;
+
/**
* Constructor for AddModulestoEARPropertiesControl.
*/
@@ -150,7 +160,7 @@
availableModules = new Label(listGroup, SWT.NONE);
gData = new GridData(GridData.HORIZONTAL_ALIGN_FILL
| GridData.VERTICAL_ALIGN_FILL);
- availableModules.setText("Available dependent modules"); //$NON-NLS-1$
+ availableModules.setText("Module Assembly"); //$NON-NLS-1$
availableModules.setLayoutData(gData);
createTableComposite(listGroup);
}
@@ -219,6 +229,7 @@
ComponentDependencyContentProvider provider = createProvider();
provider.setRuntimePaths(objectToRuntimePath);
+ provider.setResourceMappings(resourceMappings);
availableComponentsViewer.setContentProvider(provider);
availableComponentsViewer.setLabelProvider(provider);
addTableListeners();
@@ -383,14 +394,26 @@
}
public Object getValue(Object element, String property) {
- return objectToRuntimePath.get(element) == null ? new Path("/")
//$NON-NLS-1$
- .toString() : objectToRuntimePath.get(element);
+ Object data = element; //((TableItem)element).getData();
+ if( data instanceof IVirtualComponent ) {
+ return objectToRuntimePath.get(element) == null ? new Path("/")
//$NON-NLS-1$
+ .toString() : objectToRuntimePath.get(element);
+ } else if( data instanceof ComponentResourceProxy) {
+ return ((ComponentResourceProxy)data).runtimePath.toString();
+ }
+ return new Path("/");
}
public void modify(Object element, String property, Object value) {
if (property.equals(DEPLOY_PATH_PROPERTY)) {
TableItem item = (TableItem) element;
- objectToRuntimePath.put((IVirtualComponent)item.getData(), (String) value);
+ if( item.getData() instanceof IVirtualComponent) {
+ objectToRuntimePath.put((IVirtualComponent)item.getData(), (String) value);
+ } else if( item.getData() instanceof ComponentResourceProxy) {
+ ComponentResourceProxy c = ((ComponentResourceProxy)item.getData());
+ c.runtimePath = new Path((String)value);
+ resourceMappingsChanged = true;
+ }
refresh();
}
}
@@ -407,7 +430,16 @@
}
protected void handleAddMappingButton() {
-
+ AddFolderDialog afd = new AddFolderDialog(addMappingButton.getShell(), project);
+ if( afd.open() == Window.OK) {
+ IContainer c = afd.getSelected();
+ if( c != null ) {
+ IPath p = c.getProjectRelativePath();
+ ComponentResourceProxy proxy = new ComponentResourceProxy(p, new
Path("/"));
+ resourceMappings.add(proxy);
+ refresh();
+ }
+ }
}
protected void handleAddReferenceButton() {
@@ -437,7 +469,10 @@
ISelection sel = availableComponentsViewer.getSelection();
if( sel instanceof IStructuredSelection ) {
Object o = ((IStructuredSelection)sel).getFirstElement();
- objectToRuntimePath.remove(o);
+ if( o instanceof IVirtualComponent)
+ objectToRuntimePath.remove(o);
+ else if( o instanceof ComponentResourceProxy)
+ resourceMappings.remove(o);
refresh();
}
}
@@ -518,9 +553,41 @@
objectToRuntimePath.put(comp, val);
oldComponentToRuntimePath.put((IVirtualComponent) comp, val);
}
+
+ ComponentResource[] allMappings = findAllMappings();
+ for( int i = 0; i < allMappings.length; i++ ) {
+ resourceMappings.add(new ComponentResourceProxy(
+ allMappings[i].getSourcePath(), allMappings[i].getRuntimePath()
+ ));
+ }
hasInitialized = true;
}
+ protected ComponentResource[] findAllMappings() {
+ StructureEdit structureEdit = null;
+ try {
+ structureEdit = StructureEdit.getStructureEditForRead(project);
+ WorkbenchComponent component = structureEdit.getComponent();
+ Object[] arr = component.getResources().toArray();
+ ComponentResource[] result = new ComponentResource[arr.length];
+ for( int i = 0; i < arr.length; i++ )
+ result[i] = (ComponentResource)arr[i];
+ return result;
+ } catch(Exception e) {
+ } finally {
+ structureEdit.dispose();
+ }
+ return new ComponentResource[]{};
+ }
+
+ public class ComponentResourceProxy {
+ public IPath source, runtimePath;
+ public ComponentResourceProxy(IPath source, IPath runtimePath) {
+ this.source = source;
+ this.runtimePath = runtimePath;
+ }
+ }
+
/*
* Clean-up methods are below. These include performCancel, performDefaults,
* performOK, and any other methods that are called *only* by this one.
@@ -563,12 +630,46 @@
}
public boolean performOk() {
- // grab what's checked
- ArrayList<IVirtualComponent> checked = new ArrayList<IVirtualComponent>();
- TableItem[] items = availableComponentsViewer.getTable().getItems();
- for (int i = 0; i < items.length; i++)
- checked.add((IVirtualComponent)items[i].getData());
-
+ boolean result = true;
+ result &= saveResourceChanges();
+ result &= saveReferenceChanges();
+ return result;
+ }
+
+ protected boolean saveResourceChanges() {
+ removeAllResourceMappings();
+ addNewResourceMappings();
+ return true;
+ }
+ protected boolean addNewResourceMappings() {
+ ComponentResourceProxy[] proxies = (ComponentResourceProxy[])
resourceMappings.toArray(new ComponentResourceProxy[resourceMappings.size()]);
+ IVirtualFolder rootFolder = rootComponent.getRootFolder();
+ for( int i = 0; i < proxies.length; i++ ) {
+ try {
+ rootFolder.getFolder(proxies[i].runtimePath).createLink(proxies[i].source, 0, null);
+ } catch( CoreException ce ) {
+ }
+ }
+ resourceMappingsChanged = false;
+ return true;
+ }
+
+ protected boolean removeAllResourceMappings() {
+ StructureEdit moduleCore = null;
+ try {
+ moduleCore = StructureEdit.getStructureEditForWrite(project);
+ moduleCore.getComponent().getResources().clear();
+ }
+ finally {
+ if (moduleCore != null) {
+ moduleCore.saveIfNecessary(new NullProgressMonitor());
+ moduleCore.dispose();
+ }
+ }
+ return true;
+ }
+
+ protected boolean saveReferenceChanges() {
// Fill our delta lists
ArrayList<IVirtualComponent> added = new ArrayList<IVirtualComponent>();
ArrayList<IVirtualComponent> removed = new ArrayList<IVirtualComponent>();
@@ -623,7 +724,8 @@
added2.addAll(added);
added2.addAll(changed);
- // meld the changed into the added / removed
+ // meld the changed into the added / removed for less efficiency ;)
+ // basically we lack "change" operations and only have add / remove
handleRemoved(removed2);
handleAdded(added2);
}
@@ -637,7 +739,7 @@
IDataModelOperation operation = getRemoveComponentOperation(component);
operation.execute(null, null);
} catch( ExecutionException e) {
- J2EEUIPlugin.logError(e);
+ WTPOveridePlugin.logError(e);
}
}
}
@@ -693,9 +795,9 @@
}
};
try {
- J2EEUIPlugin.getWorkspace().run(runnable, new NullProgressMonitor());
+ ResourcesPlugin.getWorkspace().run(runnable, new NullProgressMonitor());
} catch( CoreException e ) {
- J2EEUIPlugin.logError(e);
+ WTPOveridePlugin.logError(e);
}
}
@@ -733,7 +835,7 @@
try {
dm.getDefaultOperation().execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
- J2EEUIPlugin.logError(e);
+ WTPOveridePlugin.logError(e);
}
}
/**
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ComponentDependencyContentProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ComponentDependencyContentProvider.java 2009-07-24
19:47:01 UTC (rev 16787)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ComponentDependencyContentProvider.java 2009-07-24
21:54:30 UTC (rev 16788)
@@ -11,6 +11,7 @@
*******************************************************************************/
package org.jboss.ide.eclipse.as.wtp.override.ui.propertypage;
+import java.util.ArrayList;
import java.util.HashMap;
import org.eclipse.core.resources.IProject;
@@ -22,8 +23,10 @@
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.common.componentcore.internal.ComponentResource;
import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import
org.jboss.ide.eclipse.as.wtp.override.ui.propertypage.AddModuleDependenciesPropertiesPage.ComponentResourceProxy;
/*
@@ -39,7 +42,7 @@
final static String PATH_SEPARATOR = String.valueOf(IPath.SEPARATOR);
private HashMap<IVirtualComponent, String> runtimePaths;
-
+ private ArrayList<ComponentResourceProxy> resourceMappings;
public ComponentDependencyContentProvider() {
super();
}
@@ -47,12 +50,19 @@
public void setRuntimePaths(HashMap<IVirtualComponent, String> paths) {
this.runtimePaths = paths;
}
+
+ public void setResourceMappings(ArrayList<ComponentResourceProxy> mappings) {
+ this.resourceMappings = mappings;
+ }
public Object[] getElements(Object inputElement) {
Object[] empty = new Object[0];
if( !(inputElement instanceof IWorkspaceRoot))
return empty;
- return runtimePaths.keySet().toArray();
+ ArrayList<Object> list = new ArrayList<Object>();
+ list.addAll(resourceMappings);
+ list.addAll(runtimePaths.keySet());
+ return list.toArray();
}
public Image getColumnImage(Object element, int columnIndex) {
@@ -60,6 +70,12 @@
}
public String getColumnText(Object element, int columnIndex) {
+ if( element instanceof ComponentResourceProxy) {
+ if( columnIndex == 0 )
+ return ((ComponentResourceProxy)element).runtimePath.toString();
+ else if( columnIndex == 1 )
+ return ((ComponentResourceProxy)element).source.toString();
+ }
if (element instanceof IVirtualComponent) {
IVirtualComponent comp = (IVirtualComponent)element;
if (columnIndex == 0) {
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ModuleAssemblyRootPage.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ModuleAssemblyRootPage.java 2009-07-24
19:47:01 UTC (rev 16787)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ModuleAssemblyRootPage.java 2009-07-24
21:54:30 UTC (rev 16788)
@@ -26,29 +26,12 @@
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
-import org.jboss.ide.eclipse.as.wtp.override.ui.Messages;
-import
org.jboss.ide.eclipse.as.wtp.override.ui.propertypage.impl.EarModuleDependenciesPropertyPage;
-
-/*
- * The only change in this file between here and upstream is
- * the method createEARContent
- *
- * We'd obviously prefer to remove the extension of the superclass here
- * but elements in the web ui demand we be a part of that tree for right now
- * Also we'd switch to depending on IModuleDependenciesControl (local)
- */
-
/**
- * Primary project property page for J2EE dependencies; content is dynamically
- * generated based on the project facets and will be comprised by a
- * set of IJ2EEDependenciesControl implementations.
- *
+ * Primary project property page for Module dependencies;
*/
public class ModuleAssemblyRootPage extends PropertyPage {
- public String DESCRIPTION = Messages.J2EEDependenciesPage_Description;
-
private IProject project;
private IModuleDependenciesControl[] controls = new IModuleDependenciesControl[0];
@@ -57,15 +40,13 @@
}
private Composite getFacetErrorComposite(final Composite parent) {
- final String errorCheckingFacet = Messages.J2EEDependenciesPage_ErrorCheckingFacets;
+ final String errorCheckingFacet = "Error Checking Project Facets";
setErrorMessage(errorCheckingFacet);
- setValid(false);
return getErrorComposite(parent, errorCheckingFacet);
}
private Composite getVirtCompErrorComposite(final Composite parent) {
final String errorCheckingFacet = "The given project is not a virtual component
project";
setErrorMessage(errorCheckingFacet);
- setValid(false);
return getErrorComposite(parent, errorCheckingFacet);
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/impl/EarModuleDependenciesPropertyPage.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/impl/EarModuleDependenciesPropertyPage.java 2009-07-24
19:47:01 UTC (rev 16787)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/impl/EarModuleDependenciesPropertyPage.java 2009-07-24
21:54:30 UTC (rev 16788)
@@ -1,136 +1,29 @@
package org.jboss.ide.eclipse.as.wtp.override.ui.propertypage.impl;
import java.util.ArrayList;
-import java.util.Set;
-import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.MessageDialog;
import
org.eclipse.jst.j2ee.application.internal.operations.AddComponentToEnterpriseApplicationDataModelProvider;
import
org.eclipse.jst.j2ee.application.internal.operations.RemoveComponentFromEnterpriseApplicationDataModelProvider;
-import org.eclipse.jst.j2ee.internal.J2EEConstants;
-import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater;
-import org.eclipse.jst.j2ee.internal.dialogs.ChangeLibDirDialog;
-import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages;
-import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin;
-import org.eclipse.jst.j2ee.model.IEARModelProvider;
-import org.eclipse.jst.j2ee.model.ModelProviderManager;
-import org.eclipse.jst.j2ee.project.EarUtilities;
-import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
-import org.eclipse.jst.j2ee.project.facet.EarFacetRuntimeHandler;
-import org.eclipse.jst.javaee.application.Application;
import org.eclipse.jst.jee.project.facet.EarCreateDeploymentFilesDataModelProvider;
import org.eclipse.jst.jee.project.facet.ICreateDeploymentFilesDataModelProperties;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
-import org.eclipse.wst.common.project.facet.core.IFacetedProject;
-import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import
org.jboss.ide.eclipse.as.wtp.override.ui.propertypage.AddModuleDependenciesPropertiesPage;
import org.jboss.ide.eclipse.as.wtp.override.ui.propertypage.ModuleAssemblyRootPage;
public class EarModuleDependenciesPropertyPage extends
AddModuleDependenciesPropertiesPage {
- protected Button changeLibPathButton;
- protected String libDir = null;
- protected String oldLibDir;
- protected boolean isVersion5;
public EarModuleDependenciesPropertyPage(IProject project,
ModuleAssemblyRootPage page) {
super(project, page);
- initMemberVariables();
}
- protected void initMemberVariables() {
- boolean hasEE5Facet = false;
- try {
- IFacetedProject facetedProject = ProjectFacetsManager.create(project);
- if(facetedProject != null){
- IProjectFacetVersion facetVersion =
facetedProject.getProjectFacetVersion(EarUtilities.ENTERPRISE_APPLICATION_FACET);
- if(facetVersion.equals(EarUtilities.ENTERPRISE_APPLICATION_50)){
- hasEE5Facet = true;
- }
- }
- } catch (CoreException e) {
- J2EEUIPlugin.logError(e);
- }
-
- if(hasEE5Facet){
- String earDDVersion = JavaEEProjectUtilities.getJ2EEDDProjectVersion(project);
- if (earDDVersion.equals(J2EEVersionConstants.VERSION_5_0_TEXT)) {
- isVersion5 = true;
- Application app =
(Application)ModelProviderManager.getModelProvider(project).getModelObject();
- if (app != null)
- oldLibDir = app.getLibraryDirectory();
- if (oldLibDir == null) oldLibDir = J2EEConstants.EAR_DEFAULT_LIB_DIR;
- libDir = oldLibDir;
- }
- }
- }
-
- protected void createPushButtons() {
- super.createPushButtons();
- if (isVersion5)
- changeLibPathButton =
createPushButton(J2EEUIMessages.getResourceString(J2EEUIMessages.CHANGE_LIB_DIR));
-
- }
-
- public void handleEvent(Event event) {
- if( event.widget == changeLibPathButton)
- handleChangeLibDirButton(true);
- else
- super.handleEvent(event);
- }
-
-
- private void handleChangeLibDirButton(boolean warnBlank) {
- IVirtualFile vFile = rootComponent.getRootFolder().getFile(new
Path(J2EEConstants.APPLICATION_DD_URI));
- if (!vFile.exists()) {
- if (!MessageDialog.openQuestion(null,
- J2EEUIMessages.getResourceString(J2EEUIMessages.NO_DD_MSG_TITLE),
- J2EEUIMessages.getResourceString(J2EEUIMessages.GEN_DD_QUESTION))) return;
- createDD(new NullProgressMonitor());
- }
- Application app =
(Application)ModelProviderManager.getModelProvider(project).getModelObject();
- if (libDir == null) {
- libDir = app.getLibraryDirectory();
- if (libDir == null) libDir = J2EEConstants.EAR_DEFAULT_LIB_DIR;
- }
-
- ChangeLibDirDialog dlg = new
ChangeLibDirDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow()
- .getShell(), libDir, warnBlank);
- if (dlg.open() == Dialog.CANCEL) return;
- libDir = dlg.getValue().trim();
- if (libDir.length() > 0) {
- if (!libDir.startsWith(J2EEConstants.EAR_ROOT_DIR)) libDir = IPath.SEPARATOR +
libDir;
- }
- }
-
- protected void createDD(IProgressMonitor monitor) {
- if( rootComponent != null ){
- IDataModelOperation op = generateEARDDOperation();
- try {
- op.execute(monitor, null);
- } catch (ExecutionException e) {
- J2EEUIPlugin.logError(e);
- }
- }
- }
-
protected IDataModelOperation generateEARDDOperation() {
IDataModel model = DataModelFactory.createDataModel(new
EarCreateDeploymentFilesDataModelProvider());
model.setProperty(ICreateDeploymentFilesDataModelProperties.GENERATE_DD,
rootComponent);
@@ -138,47 +31,10 @@
return model.getDefaultOperation();
}
- private void updateLibDir(IProgressMonitor monitor) {
- if (libDir.equals(oldLibDir)) return;
- final IEARModelProvider earModel =
(IEARModelProvider)ModelProviderManager.getModelProvider(project);
- final Application app =
(Application)ModelProviderManager.getModelProvider(project).getModelObject();
- oldLibDir = app.getLibraryDirectory();
- if (oldLibDir == null) oldLibDir = J2EEConstants.EAR_DEFAULT_LIB_DIR;
- earModel.modify(new Runnable() {
- public void run() {
- app.setLibraryDirectory(libDir);
- }}, null);
- }
-
public boolean postHandleChanges(IProgressMonitor monitor) {
return true;
}
- public boolean preHandleChanges(IProgressMonitor monitor) {
- if (isVersion5) {
- if (libDir.length() == 0) {
-
- MessageDialog dlg = new MessageDialog(null,
- J2EEUIMessages.getResourceString(J2EEUIMessages.BLANK_LIB_DIR),
- null,
J2EEUIMessages.getResourceString(J2EEUIMessages.BLANK_LIB_DIR_WARN_QUESTION),
- MessageDialog.QUESTION, new String[] {J2EEUIMessages.YES_BUTTON,
- J2EEUIMessages.NO_BUTTON,
- J2EEUIMessages.CANCEL_BUTTON}, 1);
- switch (dlg.open()) {
- case 0: break;
- case 1: {
- handleChangeLibDirButton(false);
- return false;
- }
- case 2: return false;
- default: return false;
- }
- }
- updateLibDir(monitor);
- }
- return true;
- }
-
protected void handleRemoved(ArrayList<IVirtualComponent> removed) {
super.handleRemoved(removed);
J2EEComponentClasspathUpdater.getInstance().queueUpdateEAR(rootComponent.getProject());