Author: rob.stryker(a)jboss.com
Date: 2009-06-10 05:49:38 -0400 (Wed, 10 Jun 2009)
New Revision: 15843
Removed:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddModulesToEarPropertiesPage.java
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/EarModuleDependenciesPropertyPage.java
Log:
It WORKS =DDD
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-06-10
09:42:34 UTC (rev 15842)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddModuleDependenciesPropertiesPage.java 2009-06-10
09:49:38 UTC (rev 15843)
@@ -15,12 +15,16 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -45,15 +49,22 @@
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.window.Window;
+import
org.eclipse.jst.j2ee.application.internal.operations.AddComponentToEnterpriseApplicationDataModelProvider;
+import
org.eclipse.jst.j2ee.application.internal.operations.RemoveComponentFromEnterpriseApplicationDataModelProvider;
+import org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualArchiveComponent;
import org.eclipse.jst.j2ee.internal.AvailableJ2EEComponentsForEARContentProvider;
import org.eclipse.jst.j2ee.internal.IJ2EEDependenciesControl;
+import org.eclipse.jst.j2ee.internal.J2EEConstants;
import org.eclipse.jst.j2ee.internal.ManifestUIResourceHandler;
import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil;
+import org.eclipse.jst.j2ee.internal.plugin.IJ2EEModuleConstants;
import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages;
import org.eclipse.jst.j2ee.internal.plugin.J2EEUIPlugin;
import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
+import org.eclipse.jst.j2ee.project.facet.IJavaProjectMigrationDataModelProperties;
+import org.eclipse.jst.j2ee.project.facet.JavaProjectMigrationDataModelProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
@@ -77,18 +88,24 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
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.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.IVirtualReference;
+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;
+public abstract class AddModuleDependenciesPropertiesPage implements Listener,
+ IJ2EEDependenciesControl {
-public abstract class AddModuleDependenciesPropertiesPage implements Listener,
IJ2EEDependenciesControl {
-
- protected final String PATH_SEPARATOR =
ComponentDependencyContentProvider.PATH_SEPARATOR;
+ protected final String PATH_SEPARATOR =
ComponentDependencyContentProvider.PATH_SEPARATOR;
protected boolean showRuntimePath;
protected final IProject project;
- protected final J2EEDependenciesPage propPage;
+ protected final J2EEDependenciesPage propPage;
protected IVirtualComponent rootComponent = null;
protected Text componentNameText;
protected Label availableModules;
@@ -103,22 +120,23 @@
protected static final IStatus OK_STATUS = IDataModelProvider.OK_STATUS;
protected Listener tableListener;
protected Listener labelListener;
-
protected HashMap<IVirtualComponent, String> oldComponentToRuntimePath = new
HashMap<IVirtualComponent, String>();
-
- // This should keep a list of all elements currently in the list, even if unchecked
+
+ // This should keep a list of all elements currently in the list, even if
+ // unchecked
protected HashMap<Object, String> objectToRuntimePath = new HashMap<Object,
String>();
-
-
- //[Bug 238264] the cached list elements that are new and need to be manually added to
the viewer
+
+ // [Bug 238264] the cached list elements that are new and need to be
+ // manually added to the viewer
// Can be an IProject or IVirtualComponent
- protected ArrayList<Object> addedElements= new ArrayList<Object>();
+ protected ArrayList<Object> addedElements = new ArrayList<Object>();
/**
* Constructor for AddModulestoEARPropertiesControl.
*/
- public AddModuleDependenciesPropertiesPage(final IProject project, final
J2EEDependenciesPage page) {
+ public AddModuleDependenciesPropertiesPage(final IProject project,
+ final J2EEDependenciesPage page) {
this.project = project;
this.propPage = page;
rootComponent = ComponentCore.createComponent(project);
@@ -128,26 +146,27 @@
protected boolean getShowRuntimePath() {
return this.showRuntimePath;
}
-
+
protected void setShowRuntimePath(boolean bool) {
this.showRuntimePath = bool;
- }
-
+ }
+
/*
* UI Creation Methods
*/
-
- public Composite createContents(final Composite parent) {
+
+ public Composite createContents(final Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginWidth = 0;
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- J2EEDependenciesPage.createDescriptionComposite(composite,
ManifestUIResourceHandler.EAR_Modules_Desc);
+ J2EEDependenciesPage.createDescriptionComposite(composite,
+ ManifestUIResourceHandler.EAR_Modules_Desc);
createListGroup(composite);
refresh();
- Dialog.applyDialogFont(parent);
+ Dialog.applyDialogFont(parent);
return composite;
}
@@ -163,12 +182,14 @@
listGroup.setLayoutData(gData);
availableModules = new Label(listGroup, SWT.NONE);
- gData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
- availableModules.setText(J2EEUIMessages.getResourceString("AVAILABLE_J2EE_COMPONENTS"));
//$NON-NLS-1$ = "Available dependent JARs:"
+ gData = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.VERTICAL_ALIGN_FILL);
+ availableModules.setText(J2EEUIMessages
+ .getResourceString("AVAILABLE_J2EE_COMPONENTS")); //$NON-NLS-1$ =
"Available dependent JARs:"
availableModules.setLayoutData(gData);
createTableComposite(listGroup);
}
-
+
protected void createTableComposite(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridData gData = new GridData(GridData.FILL_BOTH);
@@ -195,15 +216,18 @@
// TODO add a project button here
protected void createPushButtons() {
- String SELECT_ALL_BUTTON = ManifestUIResourceHandler.Select_All_3;
- String DE_SELECT_ALL_BUTTON = ManifestUIResourceHandler.Deselect_All_4;
+ String SELECT_ALL_BUTTON = ManifestUIResourceHandler.Select_All_3;
+ String DE_SELECT_ALL_BUTTON = ManifestUIResourceHandler.Deselect_All_4;
selectAllButton = createPushButton(SELECT_ALL_BUTTON);
deselectAllButton = createPushButton(DE_SELECT_ALL_BUTTON);
projectButton = createPushButton("Add Project...");
- projectJarButton =
createPushButton(J2EEUIMessages.getResourceString(J2EEUIMessages.PROJECT_JAR));
- externalJarButton =
createPushButton(J2EEUIMessages.getResourceString(J2EEUIMessages.EXTERNAL_JAR));
- addVariableButton =
createPushButton(J2EEUIMessages.getResourceString(J2EEUIMessages.ADDVARIABLE));
+ projectJarButton = createPushButton(J2EEUIMessages
+ .getResourceString(J2EEUIMessages.PROJECT_JAR));
+ externalJarButton = createPushButton(J2EEUIMessages
+ .getResourceString(J2EEUIMessages.EXTERNAL_JAR));
+ addVariableButton = createPushButton(J2EEUIMessages
+ .getResourceString(J2EEUIMessages.ADDVARIABLE));
}
protected Button createPushButton(String label) {
@@ -221,7 +245,8 @@
layout.marginHeight = 0;
layout.marginWidth = 0;
aButtonColumn.setLayout(layout);
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL |
GridData.VERTICAL_ALIGN_BEGINNING);
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.VERTICAL_ALIGN_BEGINNING);
aButtonColumn.setLayoutData(data);
return aButtonColumn;
}
@@ -232,7 +257,8 @@
protected void createTable(Composite parent) {
availableComponentsViewer = createAvailableComponentsViewer(parent);
- GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.FILL_VERTICAL);
availableComponentsViewer.getTable().setLayoutData(gd);
if (rootComponent != null) {
@@ -240,127 +266,148 @@
provider.setRuntimePaths(objectToRuntimePath);
availableComponentsViewer.setContentProvider(provider);
availableComponentsViewer.setLabelProvider(provider);
- availableComponentsViewer.setFilters(new ViewerFilter[]{provider});
+ availableComponentsViewer
+ .setFilters(new ViewerFilter[] { provider });
addTableListeners();
}
}
-
+
/**
- * Subclasses should over-ride this and extend the class
+ * Subclasses should over-ride this and extend the class
*/
protected ComponentDependencyContentProvider createProvider() {
- int j2eeVersion = J2EEVersionUtil.convertVersionStringToInt(rootComponent);
+ int j2eeVersion = J2EEVersionUtil
+ .convertVersionStringToInt(rootComponent);
return new ComponentDependencyContentProvider(rootComponent);
}
/*
* Listeners of various events
*/
-
+
protected void addTableListeners() {
addCheckStateListener();
addHoverHelpListeners();
addDoubleClickListener();
}
-
+
protected void addHoverHelpListeners() {
- final Table table = availableComponentsViewer.getTable();
+ final Table table = availableComponentsViewer.getTable();
createLabelListener(table);
createTableListener(table);
table.addListener(SWT.Dispose, tableListener);
table.addListener(SWT.KeyDown, tableListener);
- table.addListener(SWT.MouseMove, tableListener);
- table.addListener(SWT.MouseHover, tableListener);
+ table.addListener(SWT.MouseMove, tableListener);
+ table.addListener(SWT.MouseHover, tableListener);
}
-
+
protected void createLabelListener(final Table table) {
- labelListener = new Listener () {
- public void handleEvent (Event event) {
- Label label = (Label)event.widget;
- Shell shell = label.getShell ();
+ labelListener = new Listener() {
+ public void handleEvent(Event event) {
+ Label label = (Label) event.widget;
+ Shell shell = label.getShell();
switch (event.type) {
- case SWT.MouseDown:
- Event e = new Event ();
- e.item = (TableItem) label.getData ("_TABLEITEM");
- table.setSelection (new TableItem [] {(TableItem) e.item});
- table.notifyListeners (SWT.Selection, e);
- shell.dispose ();
- table.setFocus();
- break;
- case SWT.MouseExit:
- shell.dispose ();
- break;
+ case SWT.MouseDown:
+ Event e = new Event();
+ e.item = (TableItem) label.getData("_TABLEITEM");
+ table.setSelection(new TableItem[] { (TableItem) e.item });
+ table.notifyListeners(SWT.Selection, e);
+ shell.dispose();
+ table.setFocus();
+ break;
+ case SWT.MouseExit:
+ shell.dispose();
+ break;
}
}
};
}
-
+
protected void createTableListener(final Table table) {
- tableListener = new Listener () {
+ tableListener = new Listener() {
Shell tip = null;
Label label = null;
- public void handleEvent (Event event) {
+
+ public void handleEvent(Event event) {
switch (event.type) {
- case SWT.Dispose:
- case SWT.KeyDown:
- case SWT.MouseMove: {
- if (tip == null) break;
- tip.dispose ();
- tip = null;
- label = null;
+ case SWT.Dispose:
+ case SWT.KeyDown:
+ case SWT.MouseMove: {
+ if (tip == null)
break;
+ tip.dispose();
+ tip = null;
+ label = null;
+ break;
+ }
+ case SWT.MouseHover: {
+ TableItem item = table.getItem(new Point(event.x, event.y));
+ if (item != null) {
+ if (!item.getGrayed())
+ return;
+ if (tip != null && !tip.isDisposed())
+ tip.dispose();
+ tip = new Shell(PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell(),
+ SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL);
+ tip.setBackground(Display.getDefault().getSystemColor(
+ SWT.COLOR_INFO_BACKGROUND));
+ FillLayout layout = new FillLayout();
+ layout.marginWidth = 2;
+ tip.setLayout(layout);
+ label = new Label(tip, SWT.WRAP);
+ label.setForeground(Display.getDefault()
+ .getSystemColor(SWT.COLOR_INFO_FOREGROUND));
+ label.setBackground(Display.getDefault()
+ .getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+ label.setData("_TABLEITEM", item); //$NON-NLS-1$
+ label
+ .setText(J2EEUIMessages
+ .getResourceString(J2EEUIMessages.HOVER_HELP_FOR_DISABLED_LIBS));
+ label.addListener(SWT.MouseExit, labelListener);
+ label.addListener(SWT.MouseDown, labelListener);
+ Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ Rectangle rect = item.getBounds(0);
+ Point pt = table.toDisplay(rect.x, rect.y);
+ tip.setBounds(pt.x, pt.y - size.y, size.x, size.y);
+ tip.setVisible(true);
}
- case SWT.MouseHover: {
- TableItem item = table.getItem (new Point (event.x, event.y));
- if (item != null) {
- if (!item.getGrayed())
- return;
- if (tip != null && !tip.isDisposed ()) tip.dispose ();
- tip = new Shell (PlatformUI.getWorkbench().getActiveWorkbenchWindow()
- .getShell(), SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL);
- tip.setBackground (Display.getDefault().getSystemColor
(SWT.COLOR_INFO_BACKGROUND));
- FillLayout layout = new FillLayout ();
- layout.marginWidth = 2;
- tip.setLayout (layout);
- label = new Label (tip, SWT.WRAP);
- label.setForeground (Display.getDefault().getSystemColor
(SWT.COLOR_INFO_FOREGROUND));
- label.setBackground (Display.getDefault().getSystemColor
(SWT.COLOR_INFO_BACKGROUND));
- label.setData ("_TABLEITEM", item); //$NON-NLS-1$
- label.setText
(J2EEUIMessages.getResourceString(J2EEUIMessages.HOVER_HELP_FOR_DISABLED_LIBS));
- label.addListener (SWT.MouseExit, labelListener);
- label.addListener (SWT.MouseDown, labelListener);
- Point size = tip.computeSize (SWT.DEFAULT, SWT.DEFAULT);
- Rectangle rect = item.getBounds (0);
- Point pt = table.toDisplay (rect.x, rect.y);
- tip.setBounds (pt.x, pt.y - size.y, size.x, size.y);
- tip.setVisible (true);
- }
- }
}
+ }
}
- };
+ };
}
protected void addDoubleClickListener() {
- availableComponentsViewer.setColumnProperties(new String[] {"a",
"b", "c"});
- CellEditor[] editors = new CellEditor[]{new TextCellEditor(), new TextCellEditor(), new
TextCellEditor(availableComponentsViewer.getTable())};
+ availableComponentsViewer.setColumnProperties(new String[] { "a",
"b",
+ "c" });
+ CellEditor[] editors = new CellEditor[] { new TextCellEditor(),
+ new TextCellEditor(),
+ new TextCellEditor(availableComponentsViewer.getTable()) };
availableComponentsViewer.setCellEditors(editors);
- availableComponentsViewer.setCellModifier(new RuntimePathCellModifier());
+ availableComponentsViewer
+ .setCellModifier(new RuntimePathCellModifier());
}
-
+
private class RuntimePathCellModifier implements ICellModifier {
public boolean canModify(Object element, String property) {
- int columnIndex =
Arrays.asList(availableComponentsViewer.getColumnProperties()).indexOf(property);
- if( columnIndex == 2 ) {
- if( element instanceof VirtualArchiveComponent ) {
+ int columnIndex = Arrays.asList(
+ availableComponentsViewer.getColumnProperties()).indexOf(
+ property);
+ if (columnIndex == 2) {
+ if (element instanceof VirtualArchiveComponent) {
try {
- boolean sameProject =
- ((VirtualArchiveComponent)element).getWorkspaceRelativePath() != null
- &&
((VirtualArchiveComponent)element).getWorkspaceRelativePath().segment(0)
- .equals(rootComponent.getProject().getName());
- return !(sameProject &&
isPhysicallyAdded(((VirtualArchiveComponent)element)));
- } catch( IllegalArgumentException iae) {}
+ boolean sameProject = ((VirtualArchiveComponent) element)
+ .getWorkspaceRelativePath() != null
+ && ((VirtualArchiveComponent) element)
+ .getWorkspaceRelativePath().segment(0)
+ .equals(
+ rootComponent.getProject()
+ .getName());
+ return !(sameProject && isPhysicallyAdded(((VirtualArchiveComponent)
element)));
+ } catch (IllegalArgumentException iae) {
+ }
}
return true;
}
@@ -368,19 +415,18 @@
}
public Object getValue(Object element, String property) {
- return objectToRuntimePath.get(element) == null ?
- new Path("/").toString() :
- objectToRuntimePath.get(element);
+ return objectToRuntimePath.get(element) == null ? new Path("/")
+ .toString() : objectToRuntimePath.get(element);
}
public void modify(Object element, String property, Object value) {
- if( element instanceof TableItem ) {
- TableItem item = (TableItem)element;
- item.setText(2, (String)value);
- objectToRuntimePath.put(item.getData(), (String)value);
+ if (element instanceof TableItem) {
+ TableItem item = (TableItem) element;
+ item.setText(2, (String) value);
+ objectToRuntimePath.put(item.getData(), (String) value);
}
}
-
+
}
public void handleEvent(Event event) {
@@ -388,48 +434,48 @@
handleSelectAllButtonPressed();
else if (event.widget == deselectAllButton)
handleDeselectAllButtonPressed();
- else if(event.widget == projectButton)
+ else if (event.widget == projectButton)
handleSelectProjectButton();
- else if(event.widget == projectJarButton)
+ else if (event.widget == projectJarButton)
handleSelectProjectJarButton();
- else if(event.widget == externalJarButton)
+ else if (event.widget == externalJarButton)
handleSelectExternalJarButton();
- else if(event.widget == addVariableButton)
+ else if (event.widget == addVariableButton)
handleSelectVariableButton();
}
-
+
private void handleSelectAllButtonPressed() {
- TableItem[] children = availableComponentsViewer.getTable().getItems();
- for (int i = 0; i < children.length; i++) {
- TableItem item = children[i];
- if( !item.getGrayed())
- item.setChecked(true);
- }
+ TableItem[] children = availableComponentsViewer.getTable().getItems();
+ for (int i = 0; i < children.length; i++) {
+ TableItem item = children[i];
+ if (!item.getGrayed())
+ item.setChecked(true);
+ }
}
private void handleDeselectAllButtonPressed() {
- TableItem[] children = availableComponentsViewer.getTable().getItems();
- for (int i = 0; i < children.length; i++) {
- TableItem item = children[i];
- if( !item.getGrayed())
- item.setChecked(false);
- }
+ TableItem[] children = availableComponentsViewer.getTable().getItems();
+ for (int i = 0; i < children.length; i++) {
+ TableItem item = children[i];
+ if (!item.getGrayed())
+ item.setChecked(false);
+ }
}
-
+
private void handleSelectProjectButton() {
- SelectProjectDialog d = new SelectProjectDialog(
- new Shell(), getProjectLabelProvider(), getProjectContentProvider());
- if( d.open() == Window.OK) {
- IProject selected = (IProject)d.getFirstResult();
+ SelectProjectDialog d = new SelectProjectDialog(new Shell(),
+ getProjectLabelProvider(), getProjectContentProvider());
+ if (d.open() == Window.OK) {
+ IProject selected = (IProject) d.getFirstResult();
addedElements.add(selected);
refresh();
TableItem[] items = availableComponentsViewer.getTable().getItems();
- for( int i = 0; i < items.length; i++ )
- if( items[i].getData().equals(selected))
+ for (int i = 0; i < items.length; i++)
+ if (items[i].getData().equals(selected))
items[i].setChecked(true);
}
}
-
+
protected class SelectProjectDialog extends ElementTreeSelectionDialog {
public SelectProjectDialog(Shell parent, ILabelProvider labelProvider,
ITreeContentProvider contentProvider) {
@@ -439,154 +485,171 @@
setInput(ResourcesPlugin.getWorkspace());
}
}
+
protected ILabelProvider getProjectLabelProvider() {
return new LabelProvider() {
- public Image getImage(Object element) {
- if( element instanceof IProject )
- return
PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_PROJECT);
- return null;
- }
- public String getText(Object element) {
- if( element instanceof IProject )
- return ((IProject)element).getName();
- return element == null ? "" : element.toString();//$NON-NLS-1$
- }
+ public Image getImage(Object element) {
+ if (element instanceof IProject)
+ return PlatformUI.getWorkbench().getSharedImages()
+ .getImage(ISharedImages.IMG_OBJ_PROJECT);
+ return null;
+ }
+
+ public String getText(Object element) {
+ if (element instanceof IProject)
+ return ((IProject) element).getName();
+ return element == null ? "" : element.toString();//$NON-NLS-1$
+ }
};
}
+
protected ITreeContentProvider getProjectContentProvider() {
return new ITreeContentProvider() {
public Object[] getElements(Object inputElement) {
return ResourcesPlugin.getWorkspace().getRoot().getProjects();
}
+
public Object[] getChildren(Object parentElement) {
return null;
}
+
public Object getParent(Object element) {
return null;
}
+
public boolean hasChildren(Object element) {
return false;
}
+
public void dispose() {
}
+
public void inputChanged(Viewer viewer, Object oldInput,
Object newInput) {
}
-
+
};
}
-
+
protected IProject[] filterAddProjectList(IProject[] list) {
return list;
}
-
-
+
/**
- * [Bug 238264]
- * Add an archive as a potential new reference for this.earComponent
- * NOTE1: the given archive will not be added as a potential reference if there is
already a reference to it
- * NOTE2: the given archive will only be added as an actual reference when
this.performOk is invoked
+ * [Bug 238264] Add an archive as a potential new reference for
+ * this.earComponent NOTE1: the given archive will not be added as a
+ * potential reference if there is already a reference to it NOTE2: the
+ * given archive will only be added as an actual reference when
+ * this.performOk is invoked
*
- * @param archive the archive to add as a potential new reference in this.earComponent
- *
+ * @param archive
+ * the archive to add as a potential new reference in
+ * this.earComponent
+ *
*/
private void addPotentialNewReference(IVirtualComponent archive) {
- //check to see if a reference to the given archive already exists
- IVirtualReference [] existingRefs = rootComponent.getReferences();
+ // check to see if a reference to the given archive already exists
+ IVirtualReference[] existingRefs = rootComponent.getReferences();
IVirtualComponent referencedComponent;
boolean refAlreadyExists = false;
- for(int i=0;i<existingRefs.length && !refAlreadyExists;i++){
+ for (int i = 0; i < existingRefs.length && !refAlreadyExists; i++) {
referencedComponent = existingRefs[i].getReferencedComponent();
refAlreadyExists = referencedComponent.equals(archive);
}
-
+
// verify it's not already in the list... ugh
TableItem[] allItems = availableComponentsViewer.getTable().getItems();
- for( int i = 0; i < allItems.length; i++ ) {
- if( allItems[i].getData().equals(archive)) {
+ for (int i = 0; i < allItems.length; i++) {
+ if (allItems[i].getData().equals(archive)) {
allItems[i].setChecked(true);
refAlreadyExists = true;
}
}
-
- // only add the archive as a potentialy new reference if it does not already exist
+
+ // only add the archive as a potentialy new reference if it does not
+ // already exist
// also force check it
- if(!refAlreadyExists) {
+ if (!refAlreadyExists) {
this.objectToRuntimePath.put(archive, new Path("/").toString());
this.addedElements.add(archive);
availableComponentsViewer.add(archive);
TableItem[] items = availableComponentsViewer.getTable().getItems();
- for( int i = 0; i < items.length; i++ ) {
- if(items[i].getData().equals(archive))
+ for (int i = 0; i < items.length; i++) {
+ if (items[i].getData().equals(archive))
items[i].setChecked(true);
}
-
+
} else {
- //TODO should inform user that they selected an already referenced archive?
+ // TODO should inform user that they selected an already referenced
+ // archive?
}
}
-
- private void handleSelectExternalJarButton(){
- IPath[] selected= BuildPathDialogAccess.chooseExternalJAREntries(propPage.getShell());
+ private void handleSelectExternalJarButton() {
+ IPath[] selected = BuildPathDialogAccess
+ .chooseExternalJAREntries(propPage.getShell());
+
if (selected != null) {
- for (int i= 0; i < selected.length; i++) {
-
- String type = VirtualArchiveComponent.LIBARCHIVETYPE + IPath.SEPARATOR;
- IVirtualComponent archive = ComponentCore.createArchiveComponent(
rootComponent.getProject(), type +
- selected[i].toString());
-
+ for (int i = 0; i < selected.length; i++) {
+
+ String type = VirtualArchiveComponent.LIBARCHIVETYPE
+ + IPath.SEPARATOR;
+ IVirtualComponent archive = ComponentCore
+ .createArchiveComponent(rootComponent.getProject(),
+ type + selected[i].toString());
+
this.addPotentialNewReference(archive);
}
refresh();
}
-
+
}
- private void handleSelectVariableButton(){
+ private void handleSelectVariableButton() {
IPath existingPath[] = new Path[0];
- IPath[] paths = BuildPathDialogAccess.chooseVariableEntries(propPage.getShell(),
existingPath);
-
+ IPath[] paths = BuildPathDialogAccess.chooseVariableEntries(propPage
+ .getShell(), existingPath);
+
if (paths != null) {
refresh();
for (int i = 0; i < paths.length; i++) {
- IPath resolvedPath= JavaCore.getResolvedVariablePath(paths[i]);
+ IPath resolvedPath = JavaCore.getResolvedVariablePath(paths[i]);
java.io.File file = new java.io.File(resolvedPath.toOSString());
- if( file.isFile() && file.exists()){
- String type = VirtualArchiveComponent.VARARCHIVETYPE + IPath.SEPARATOR;
-
- IVirtualComponent archive = ComponentCore.createArchiveComponent(
rootComponent.getProject(), type +
- paths[i].toString());
-
+ if (file.isFile() && file.exists()) {
+ String type = VirtualArchiveComponent.VARARCHIVETYPE
+ + IPath.SEPARATOR;
+
+ IVirtualComponent archive = ComponentCore
+ .createArchiveComponent(rootComponent.getProject(),
+ type + paths[i].toString());
+
this.addPotentialNewReference(archive);
- }else{
- //display error
+ } else {
+ // display error
}
}
refresh();
- }
+ }
}
-
-
// TODO FIX THIS
protected void addCheckStateListener() {
- availableComponentsViewer.addCheckStateListener(new ICheckStateListener() {
- public void checkStateChanged(CheckStateChangedEvent event) {
- CheckboxTableViewer vr = (CheckboxTableViewer)event.getSource();
- Object element = event.getElement();
- if (vr.getGrayed(element))
- vr.setChecked(element, !vr.getChecked(element));
- Object o = event.getSource();
-
- // TODO : check for conflict + dependency res
- }
- });
+ availableComponentsViewer
+ .addCheckStateListener(new ICheckStateListener() {
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ CheckboxTableViewer vr = (CheckboxTableViewer) event
+ .getSource();
+ Object element = event.getElement();
+ if (vr.getGrayed(element))
+ vr.setChecked(element, !vr.getChecked(element));
+ Object o = event.getSource();
+
+ // TODO : check for conflict + dependency res
+ }
+ });
}
-
-
public CheckboxTableViewer createAvailableComponentsViewer(Composite parent) {
int flags = SWT.CHECK | SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI;
@@ -597,7 +660,7 @@
TableLayout tableLayout = new org.eclipse.jface.viewers.TableLayout();
tableLayout.addColumnData(new ColumnWeightData(300, true));
tableLayout.addColumnData(new ColumnWeightData(300, true));
- if (showRuntimePath)
+ if (showRuntimePath)
tableLayout.addColumnData(new ColumnWeightData(200, true));
table.setLayout(tableLayout);
table.setHeaderVisible(true);
@@ -606,24 +669,24 @@
// table columns
TableColumn fileNameColumn = new TableColumn(table, SWT.NONE, 0);
- fileNameColumn.setText(ManifestUIResourceHandler.JAR_Module_UI_);
+ fileNameColumn.setText(ManifestUIResourceHandler.JAR_Module_UI_);
fileNameColumn.setResizable(true);
TableColumn projectColumn = new TableColumn(table, SWT.NONE, 1);
- projectColumn.setText(ManifestUIResourceHandler.Project_UI_);
+ projectColumn.setText(ManifestUIResourceHandler.Project_UI_);
projectColumn.setResizable(true);
-
+
if (showRuntimePath) {
TableColumn bndColumn = new TableColumn(table, SWT.NONE, 2);
- bndColumn.setText(ManifestUIResourceHandler.Packed_In_Lib_UI_);
- bndColumn.setResizable(true);
+ bndColumn.setText(ManifestUIResourceHandler.Packed_In_Lib_UI_);
+ bndColumn.setResizable(true);
}
-
+
tableLayout.layout(table, true);
return availableComponentsViewer;
}
-
+
protected boolean isPhysicallyAdded(VirtualArchiveComponent component) {
IPath p = null;
try {
@@ -632,101 +695,121 @@
} catch (IllegalArgumentException e) {
return false;
}
- }
+ }
+
private boolean secondShouldBeDisabled(IVirtualComponent component) {
- if(component.isBinary()) return false;
- if (JavaEEProjectUtilities.isApplicationClientComponent(component)) return true;
- if (JavaEEProjectUtilities.isEARProject(component.getProject()) &&
component.isBinary()) return false;
- if (JavaEEProjectUtilities.isEJBComponent(component)) return true;
- if (JavaEEProjectUtilities.isDynamicWebComponent(component)) return true;
- if (JavaEEProjectUtilities.isJCAComponent(component)) return true;
- if (JavaEEProjectUtilities.isStaticWebProject(component.getProject())) return true;
- if (JavaEEProjectUtilities.isProjectOfType(component.getProject(),
IJ2EEFacetConstants.JAVA)) return false;
+ if (component.isBinary())
+ return false;
+ if (JavaEEProjectUtilities.isApplicationClientComponent(component))
+ return true;
+ if (JavaEEProjectUtilities.isEARProject(component.getProject())
+ && component.isBinary())
+ return false;
+ if (JavaEEProjectUtilities.isEJBComponent(component))
+ return true;
+ if (JavaEEProjectUtilities.isDynamicWebComponent(component))
+ return true;
+ if (JavaEEProjectUtilities.isJCAComponent(component))
+ return true;
+ if (JavaEEProjectUtilities.isStaticWebProject(component.getProject()))
+ return true;
+ if (JavaEEProjectUtilities.isProjectOfType(component.getProject(),
+ IJ2EEFacetConstants.JAVA))
+ return false;
return false;
}
-
-
private boolean isInLibDir(VirtualArchiveComponent comp) {
IPath p = comp.getProjectRelativePath();
if (p.segmentCount() == 2)
return false;
return true;
}
-
+
private boolean isConflict(Object lib) {
- IProject libProj = (lib instanceof IProject) ? (IProject)lib :
((IVirtualComponent)lib).getProject();
- IProject earProject = rootComponent.getProject();
- try {
+ IProject libProj = (lib instanceof IProject) ? (IProject) lib
+ : ((IVirtualComponent) lib).getProject();
+ IProject earProject = rootComponent.getProject();
+ try {
IVirtualComponent cmp = ComponentCore.createComponent(earProject);
IProject[] earRefProjects = earProject.getReferencedProjects();
- for (int i = 0; i < earRefProjects.length; i++) {
- if (!J2EEProjectUtilities.isEARProject(earRefProjects[i]) &&
- !earRefProjects[i].equals(libProj)) {
- IVirtualComponent cmp1 = ComponentCore.createComponent(earRefProjects[i]);
+ for (int i = 0; i < earRefProjects.length; i++) {
+ if (!J2EEProjectUtilities.isEARProject(earRefProjects[i])
+ && !earRefProjects[i].equals(libProj)) {
+ IVirtualComponent cmp1 = ComponentCore
+ .createComponent(earRefProjects[i]);
IVirtualReference[] refs = cmp1.getReferences();
for (int j = 0; j < refs.length; j++) {
- if (refs[j].getReferencedComponent().getProject().equals(libProj)) return true;
+ if (refs[j].getReferencedComponent().getProject()
+ .equals(libProj))
+ return true;
}
- }
+ }
}
return false;
} catch (CoreException ce) {
J2EEUIPlugin.logError(ce);
- }
+ }
return false;
- }
-
- private void handleSelectProjectJarButton(){
- IPath[] selected= BuildPathDialogAccess.chooseJAREntries(propPage.getShell(),
project.getLocation(), new IPath[0]);
-
+ }
+
+ private void handleSelectProjectJarButton() {
+ IPath[] selected = BuildPathDialogAccess.chooseJAREntries(propPage
+ .getShell(), project.getLocation(), new IPath[0]);
+
if (selected != null) {
- for (int i= 0; i < selected.length; i++) {
- //IPath fullPath = project.getFile(selected[i]).getFullPath();
- String type = VirtualArchiveComponent.LIBARCHIVETYPE + IPath.SEPARATOR;
- IVirtualComponent archive = ComponentCore.createArchiveComponent(
rootComponent.getProject(), type +
- selected[i].makeRelative().toString());
-
+ for (int i = 0; i < selected.length; i++) {
+ // IPath fullPath = project.getFile(selected[i]).getFullPath();
+ String type = VirtualArchiveComponent.LIBARCHIVETYPE
+ + IPath.SEPARATOR;
+ IVirtualComponent archive = ComponentCore
+ .createArchiveComponent(rootComponent.getProject(),
+ type + selected[i].makeRelative().toString());
+
this.addPotentialNewReference(archive);
}
refresh();
}
-
+
}
+
private boolean hasInitialized = false;
+
/**
* This should only be called on changes, such as adding a project
* reference, adding a lib reference etc.
*
- * It will reset the input, manually re-add missing elements, and do other tasks
+ * It will reset the input, manually re-add missing elements, and do other
+ * tasks
*/
public void refresh() {
TableItem[] items = availableComponentsViewer.getTable().getItems();
- HashMap<Object, Boolean> checked = cacheChecked();
+ HashMap<Object, Boolean> checked = cacheChecked();
resetTableUI();
- if( !hasInitialized) {
+ if (!hasInitialized) {
initialize();
resetTableUI();
}
/*
- * Re-check any added elements that were checked but now lost their check
+ * Re-check any added elements that were checked but now lost their
+ * check
*/
TableItem[] newItems = availableComponentsViewer.getTable().getItems();
- for( int i = 0; i < newItems.length; i++ ) {
- if( checked.containsKey(newItems[i].getData()))
+ for (int i = 0; i < newItems.length; i++) {
+ if (checked.containsKey(newItems[i].getData()))
newItems[i].setChecked(checked.get(newItems[i].getData()));
}
}
- protected HashMap<Object, Boolean> cacheChecked() {
+ protected HashMap<Object, Boolean> cacheChecked() {
// preserve selections / check / etc of new (added) entities
- TableItem [] items = availableComponentsViewer.getTable().getItems();
- HashMap<Object, Boolean> checked = new HashMap<Object,Boolean>();
- if( addedElements != null ) {
+ TableItem[] items = availableComponentsViewer.getTable().getItems();
+ HashMap<Object, Boolean> checked = new HashMap<Object, Boolean>();
+ if (addedElements != null) {
int j = 0;
- for( int i = 0; i < items.length; i++ ) {
- if( addedElements.contains(items[i].getData()))
+ for (int i = 0; i < items.length; i++) {
+ if (addedElements.contains(items[i].getData()))
checked.put(items[i].getData(), items[i].getChecked());
}
}
@@ -737,68 +820,85 @@
IWorkspaceRoot input = ResourcesPlugin.getWorkspace().getRoot();
availableComponentsViewer.setInput(input);
GridData data = new GridData(GridData.FILL_BOTH);
- int numlines = Math.min(10, availableComponentsViewer.getTable().getItemCount());
- data.heightHint = availableComponentsViewer.getTable().getItemHeight() * numlines;
+ int numlines = Math.min(10, availableComponentsViewer.getTable()
+ .getItemCount());
+ data.heightHint = availableComponentsViewer.getTable().getItemHeight()
+ * numlines;
availableComponentsViewer.getTable().setLayoutData(data);
- GridData btndata = new GridData(GridData.HORIZONTAL_ALIGN_FILL |
GridData.VERTICAL_ALIGN_BEGINNING);
+ GridData btndata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.VERTICAL_ALIGN_BEGINNING);
buttonColumn.setLayoutData(btndata);
- //[Bug 238264] for all the jars in the cache temparaly list them in the grid
- for(Object addedElement : this.addedElements) {
- availableComponentsViewer.add(addedElement);
+ // [Bug 238264] for all the jars in the cache temparaly list them in the
+ // grid
+ TableItem[] items = availableComponentsViewer.getTable().getItems();
+ for (Object addedElement : this.addedElements) {
+ boolean found = false;
+ for (int i = 0; i < items.length; i++) {
+ if (items[i].getData().equals(addedElement))
+ found = true;
+ }
+ if (!found)
+ availableComponentsViewer.add(addedElement);
}
}
protected void initialize() {
- TableItem [] items = availableComponentsViewer.getTable().getItems();
-
+ TableItem[] items = availableComponentsViewer.getTable().getItems();
+
// First initialize the paths
Object data;
- for( int i = 0; i < items.length; i++ ) {
+ for (int i = 0; i < items.length; i++) {
data = items[i].getData();
- if( data instanceof IVirtualComponent ) {
- IVirtualReference ref =
rootComponent.getReference(((IVirtualComponent)data).getName());
- String val = ref == null ? new Path(PATH_SEPARATOR).toString() :
ref.getRuntimePath().toString();
+ if (data instanceof IVirtualComponent) {
+ IVirtualReference ref = rootComponent
+ .getReference(((IVirtualComponent) data).getName());
+ String val = ref == null ? new Path(PATH_SEPARATOR).toString()
+ : ref.getRuntimePath().toString();
objectToRuntimePath.put(data, val);
+ oldComponentToRuntimePath.put((IVirtualComponent) data, val);
}
}
-
+
// Then initialize the UI
List forceCheck = new ArrayList();
forceCheck.addAll(getChildrenComponents());
forceCheck.addAll(getCPComponents());
- for( int i = 0; i < items.length; i++ ) {
- if( forceCheck.contains(items[i].getData()))
+ for (int i = 0; i < items.length; i++) {
+ if (forceCheck.contains(items[i].getData()))
items[i].setChecked(true);
-
- if( items[i].getData() instanceof VirtualArchiveComponent )
- items[i].setGrayed(isPhysicallyAdded(((VirtualArchiveComponent)items[i].getData())));
+
+ if (items[i].getData() instanceof VirtualArchiveComponent)
+ items[i]
+ .setGrayed(isPhysicallyAdded(((VirtualArchiveComponent) items[i]
+ .getData())));
}
hasInitialized = true;
}
+
protected List getChildrenComponents() {
List list = new ArrayList();
IVirtualReference refs[] = rootComponent.getReferences();
- for( int i=0; i< refs.length; i++){
- if( isChildComponent(refs[i]))
+ for (int i = 0; i < refs.length; i++) {
+ if (isChildComponent(refs[i]))
list.add(refs[i].getReferencedComponent());
}
return list;
}
-
+
protected boolean isChildComponent(IVirtualReference ref) {
-// if ((ref.getRuntimePath().isRoot() && !inLibFolder) ||
-// (!ref.getRuntimePath().isRoot() && inLibFolder) ||
-// !isVersion5) {
+ // if ((ref.getRuntimePath().isRoot() && !inLibFolder) ||
+ // (!ref.getRuntimePath().isRoot() && inLibFolder) ||
+ // !isVersion5) {
return true;
}
-
+
protected List getCPComponents() {
List list = new ArrayList();
Map pathToComp = new HashMap();
IVirtualReference refs[] = rootComponent.getReferences();
- for( int i=0; i< refs.length; i++){
- if( isChildComponent(refs[i])) {
+ for (int i = 0; i < refs.length; i++) {
+ if (isChildComponent(refs[i])) {
IVirtualComponent comp = refs[i].getReferencedComponent();
addClasspathComponentDependencies(list, pathToComp, comp);
}
@@ -806,401 +906,340 @@
return list;
}
- protected void addClasspathComponentDependencies(final List componentList, final Map
pathToComp, final IVirtualComponent referencedComponent) {
- AvailableJ2EEComponentsForEARContentProvider.addClasspathComponentDependencies(componentList,
pathToComp, referencedComponent);
+ protected void addClasspathComponentDependencies(final List componentList,
+ final Map pathToComp, final IVirtualComponent referencedComponent) {
+ AvailableJ2EEComponentsForEARContentProvider
+ .addClasspathComponentDependencies(componentList, pathToComp,
+ referencedComponent);
}
-
/*
- * Clean-up methods are below. These include
- * performCancel, performDefaults, performOK, and
- * any other methods that are called *only* by this one.
+ * Clean-up methods are below. These include performCancel, performDefaults,
+ * performOK, and any other methods that are called *only* by this one.
*/
public void setVisible(boolean visible) {
}
-
+
public void performDefaults() {
}
-
+
public boolean performCancel() {
return true;
}
-
+
public void dispose() {
Table table = null;
if (availableComponentsViewer != null) {
- table = availableComponentsViewer.getTable();
- if (table == null)
- return;
+ table = availableComponentsViewer.getTable();
+ if (table == null)
+ return;
}
table.removeListener(SWT.Dispose, tableListener);
table.removeListener(SWT.KeyDown, tableListener);
table.removeListener(SWT.MouseMove, tableListener);
- table.removeListener(SWT.MouseHover, tableListener);
+ table.removeListener(SWT.MouseHover, tableListener);
}
- protected abstract boolean performOk(IProgressMonitor monitor);
+
+
+ /*
+ * This is where the OK work goes. Lots of it. Watch your head.
+ * xiao xin
+ */
+
+
+
+ protected abstract boolean preHandleChanges(IProgressMonitor monitor);
+ protected abstract boolean postHandleChanges(IProgressMonitor monitor);
+
public boolean performOk() {
+ // grab what's checked
+ ArrayList<Object> checked = new ArrayList<Object>();
+ TableItem[] items = availableComponentsViewer.getTable().getItems();
+ for (int i = 0; i < items.length; i++)
+ if (items[i].getChecked())
+ checked.add(items[i].getData());
+
+ // Fill our delta lists
+ ArrayList<Object> added = new ArrayList<Object>();
+ ArrayList<IVirtualComponent> removed = new ArrayList<IVirtualComponent>();
+ ArrayList<IVirtualComponent> changed = new ArrayList<IVirtualComponent>();
+
+ Iterator j = oldComponentToRuntimePath.keySet().iterator();
+ Object key, val;
+ while (j.hasNext()) {
+ key = j.next();
+ val = oldComponentToRuntimePath.get(key);
+ if (!checked.contains(key))
+ removed.add((IVirtualComponent)key);
+ else if (!val.equals(objectToRuntimePath.get(key)))
+ changed.add((IVirtualComponent)key);
+ }
+
+ j = objectToRuntimePath.keySet().iterator();
+ while (j.hasNext()) {
+ key = j.next();
+ if (!oldComponentToRuntimePath.containsKey(key))
+ added.add(key);
+ }
+
NullProgressMonitor monitor = new NullProgressMonitor();
- boolean subResult = performOk(monitor);
+ boolean subResult = preHandleChanges(monitor);
if( !subResult )
return false;
-// removeModulesFromEAR(monitor);
-// addModulesToEAR(monitor);
-// refresh();
+ handleDeltas(removed, changed, added);
- Iterator i = addedElements.iterator();
+ subResult &= postHandleChanges(monitor);
+ return subResult;
+ }
+
+ // Subclass can override if it has a good way to handle changed elements
+ protected void handleDeltas(ArrayList<IVirtualComponent> removed,
+ ArrayList<IVirtualComponent> changed, ArrayList<Object> added) {
+ ArrayList<IVirtualComponent> removed2 = new
ArrayList<IVirtualComponent>();
+ ArrayList<Object> added2 = new ArrayList<Object>();
+ removed2.addAll(removed);
+ removed2.addAll(changed);
+ added2.addAll(added);
+ added2.addAll(changed);
+
+ // meld the changed into the added / removed
+ handleRemoved(removed2);
+ handleAdded(added2);
+ }
+ protected void handleRemoved(ArrayList<IVirtualComponent> removed) {
+ // If it's removed it should *only* be a virtual component already
+ Iterator<IVirtualComponent> i = removed.iterator();
+ IVirtualComponent component;
while(i.hasNext()) {
- Object o = i.next();
- System.out.println("Adding " + o + " to path " +
objectToRuntimePath.get(o));
+ try {
+ component = i.next();
+ IDataModelOperation operation = getRemoveComponentOperation(component);
+ operation.execute(null, null);
+ } catch( ExecutionException e) {
+ J2EEUIPlugin.logError(e);
+ }
}
- return true;
}
+
+ protected IDataModelOperation getRemoveComponentOperation(IVirtualComponent component)
{
+ IDataModelProvider provider = getRemoveReferenceDataModelProvider(component);
+ IDataModel model = DataModelFactory.createDataModel(provider);
+ model.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT,
rootComponent);
+ List modHandlesList = (List)
model.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST);
+ modHandlesList.add(component);
+ model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST,
modHandlesList);
+
model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH,
oldComponentToRuntimePath.get(component));
+ return model.getDefaultOperation();
+ }
+
+ protected IDataModelProvider getRemoveReferenceDataModelProvider(IVirtualComponent
component) {
+ return new RemoveReferenceComponentsDataModelProvider();
+ }
-// /*
-// * Methods called directly from OK
-// */
-// private IStatus addModulesToEAR(IProgressMonitor monitor) {
-// IStatus stat = OK_STATUS;
-// try {
-// if( earComponent != null ){
-// final List list = newJ2EEModulesToAdd(false);
-// final List bndList = newJ2EEModulesToAdd(true);
-// final boolean shouldRun = (list != null && !list.isEmpty()) ||
!javaProjectsList.isEmpty();
-// final boolean shouldBndRun = isVersion5 &&
-// ((bndList != null && !bndList.isEmpty()) ||
!javaLibProjectsList.isEmpty());
-// if(shouldRun || shouldBndRun){
-// IWorkspaceRunnable runnable = new IWorkspaceRunnable(){
-//
-// public void run(IProgressMonitor monitor) throws CoreException{
-// if (shouldRun) {
-// execAddOp(monitor, list, J2EEConstants.EAR_ROOT_DIR);
-// execAddOp1(monitor, javaProjectsList, j2eeComponentList,
J2EEConstants.EAR_ROOT_DIR);
-// }
-// if (shouldBndRun) {
-// execAddOp(monitor, bndList, libDir);
-// execAddOp1(monitor, javaLibProjectsList, j2eeLibElementList,
libDir);
-// }
-// }
-// };
-// J2EEUIPlugin.getWorkspace().run(runnable, monitor);
-// }
-// }
-// } catch (Exception e) {
-// J2EEUIPlugin.logError(e);
-// }
-//
-// //[Bug 238264] clear out the cache because they should all either be added as
references now
-// // or no longer checked and therefore not wanted by the user
-// this.addedJARComponents.clear();
-//
-// return OK_STATUS;
-// }
-//
-// private List newJ2EEModulesToAdd(boolean inLibFolder){
-// if (inLibFolder && !isVersion5) return null;
-// List newComps = new ArrayList();
-// List comps = inLibFolder ? j2eeLibElementList : j2eeComponentList;
-// if (comps != null && !comps.isEmpty()){
-// for (int i = 0; i < comps.size(); i++){
-// IVirtualComponent handle = (IVirtualComponent)comps.get(i);
-// if (ClasspathDependencyUtil.isClasspathComponentDependency(handle)) {
-// continue;
-// }
-// if( !inEARAlready(handle))
-// newComps.add(handle);
-// }
-// }
-// return newComps;
-// }
-//
-// /**
-// *
-// * @param componentHandle
-// * @return
-// * @description returns true is a component is already in the EAR as a dependent
-// */
-// protected boolean inEARAlready(IVirtualComponent component){
-// IVirtualReference refs[] = rootComponent.getReferences();
-// for( int i=0; i< refs.length; i++){
-// IVirtualReference ref = refs[i];
-// if ( ref.getReferencedComponent().equals( component ))
-// return true;
-// }
-// return false;
-// }
+ protected void handleChanged(ArrayList<IVirtualComponent> changed) {
+ Iterator<IVirtualComponent> i = changed.iterator();
+ IVirtualComponent component;
+ IVirtualReference ref;
+ IPath p;
+ while(i.hasNext()) {
+ component = i.next();
+ ref = rootComponent.getReference(component.getName());
+ p = new Path(objectToRuntimePath.get(component));
+ ref.setRuntimePath(p);
+ }
+ }
-// 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);
-// }
-//
-// private void remComps(List list, String path) {
-// if( !list.isEmpty()){
-// try {
-// // remove the components from the EAR
-// IDataModelOperation op = removeComponentFromEAROperation(earComponent, list,
path);
-// op.execute(null, null);
-// // if that succeeded, remove all EAR-scope J2EE dependencies on these components
-// J2EEComponentClasspathUpdater.getInstance().queueUpdateEAR(earComponent.getProject());
-// } catch (ExecutionException e) {
-// J2EEUIPlugin.logError(e);
-// }
-// }
-// }
-//
-// private IStatus removeModulesFromEAR(IProgressMonitor monitor) {
-// IStatus stat = OK_STATUS;
-// if (!isVersion5) {
-// if(earComponent != null && j2eeComponentList != null) {
-// List list = getComponentsToRemove();
-// remComps(list, J2EEConstants.EAR_ROOT_DIR);
-// }
-// } else {
-// if( earComponent != null && j2eeComponentList != null) {
-// List[] list = getComponentsToRemoveUpdate(!libDir.equals(oldLibDir));
-// remComps(list[0], J2EEConstants.EAR_ROOT_DIR);
-//
-// remComps(list[1], oldLibDir);
-// }
-// }
-// return stat;
-// }
-//
-// protected IDataModelOperation removeComponentFromEAROperation(IVirtualComponent
sourceComponent, List targetComponentsHandles, String dir) {
-// IDataModel model = DataModelFactory.createDataModel(new
RemoveComponentFromEnterpriseApplicationDataModelProvider());
-// model.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT,
sourceComponent);
-// List modHandlesList = (List)
model.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST);
-// modHandlesList.addAll(targetComponentsHandles);
-// model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST,
modHandlesList);
-//
model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH,
dir);
-// return model.getDefaultOperation();
-// }
-//
-// protected List getComponentsToRemove(){
-// //j2eeComponentList = getCheckedJ2EEElementsAsList();
-// List list = new ArrayList();
-// if( earComponent != null && list != null ){
-// IVirtualReference[] oldrefs = earComponent.getReferences();
-// for (int j = 0; j < oldrefs.length; j++) {
-// IVirtualReference ref = oldrefs[j];
-// IVirtualComponent handle = ref.getReferencedComponent();
-// if(!j2eeComponentList.contains(handle) && (isVersion5 ?
!j2eeLibElementList.contains(handle) : true)){
-// if ((handle instanceof VirtualArchiveComponent) &&
(isPhysicallyAdded((VirtualArchiveComponent)handle)))
-// continue;
-// list.add(handle);
-// }
-// }
-// }
-// return list;
-// }
-//
-// // EAR5 case
-// protected List[] getComponentsToRemoveUpdate(boolean dirUpdated){
-// //j2eeComponentList = getCheckedJ2EEElementsAsList();
-// List[] list = new ArrayList[2];
-// list[0] = new ArrayList();
-// list[1] = new ArrayList();
-// if( earComponent != null && list != null ){
-// IVirtualReference[] oldrefs = earComponent.getReferences();
-// for (int j = 0; j < oldrefs.length; j++) {
-// IVirtualReference ref = oldrefs[j];
-// IVirtualComponent handle = ref.getReferencedComponent();
-// if (handle instanceof VirtualArchiveComponent) {
-// VirtualArchiveComponent comp = (VirtualArchiveComponent)handle;
-// if (isPhysicallyAdded(comp))
-// continue;
-// }
-// if(!j2eeComponentList.contains(handle) && ref.getRuntimePath().isRoot()) {
-// list[0].add(handle);
-// }
-// if((!j2eeLibElementList.contains(handle) || dirUpdated) &&
-// ref.getRuntimePath().toString().equals(oldLibDir)) {
-// list[1].add(handle);
-// }
-// }
-// }
-// return list;
-// }
-//
-//
-// /*
-// * Operations called from OK
-// */
-//
-// private void execAddOp(IProgressMonitor monitor, List componentList, String path)
throws CoreException {
-// if (componentList == null || componentList.isEmpty()) return;
-// IDataModel dm = DataModelFactory.createDataModel(new
AddComponentToEnterpriseApplicationDataModelProvider());
-//
-// dm.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT,
earComponent);
-// dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST,
componentList);
-//
-// //[Bug 238264] the uri map needs to be manually set correctly
-// Map uriMap = new HashMap();
-// IVirtualComponent virtComp;
-// String virtCompURIMapName;
-// for(int i=0; i<componentList.size(); i++) {
-// virtComp = (IVirtualComponent)componentList.get(i);
-// virtCompURIMapName = getVirtualComponentNameWithExtension(virtComp);
-// uriMap.put(virtComp, virtCompURIMapName);
-// }
-// dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP,
uriMap);
-//
-// if (isVersion5)
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(monitor, null);
-// } catch (ExecutionException e) {
-// J2EEUIPlugin.logError(e);
-// }
-// }
-//
-// private void execAddOp1(IProgressMonitor monitor, List jProjList, List j2eeCompList,
String path)
-// throws CoreException {
-// if (!jProjList.isEmpty()) {
-// Set moduleProjects = new HashSet();
-// for (int i = 0; i < jProjList.size(); i++) {
-// try {
-// IProject proj = (IProject) jProjList.get(i);
-// moduleProjects.add(proj);
-// IDataModel migrationdm = DataModelFactory.createDataModel(new
JavaProjectMigrationDataModelProvider());
-// migrationdm.setProperty(IJavaProjectMigrationDataModelProperties.PROJECT_NAME,
proj.getName());
-// migrationdm.getDefaultOperation().execute(monitor, null);
-//
-//
-// IDataModel refdm = DataModelFactory.createDataModel(new
CreateReferenceComponentsDataModelProvider());
-// List targetCompList = (List)
refdm.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST);
-//
-// IVirtualComponent targetcomponent = ComponentCore.createComponent(proj);
-// targetCompList.add(targetcomponent);
-//
-// refdm.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT,
earComponent);
-// refdm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST,
targetCompList);
-// if (isVersion5)
refdm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH,
path);
-//
-//
-// // referenced java projects should have archiveName attribute
-// ((Map)refdm.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP)).put(targetcomponent,
proj.getName().replace(' ', '_') + IJ2EEModuleConstants.JAR_EXT);
-//
-// refdm.getDefaultOperation().execute(monitor, null);
-// j2eeCompList.add(targetcomponent);
-// } catch (ExecutionException e) {
-// J2EEUIPlugin.logError(e);
-// }
-// }
-// EarFacetRuntimeHandler.updateModuleProjectRuntime(earComponent.getProject(),
moduleProjects, new NullProgressMonitor());
-// } // end
-//
-// }
-//
-//
-//
-// /*
-// * Methods called From the Operations (which are called from OK)
-// */
-//
-// /**
-// * Method returns the name of the given IVirtualComponent being sure the correct
extension
-// * is on the end of the name, this is important for internal projects. Added for [Bug
241509]
-// *
-// * @param virtComp the IVirtualComponent to get the name of with the correct
extension
-// * @return the name of the given IVirtualComponent with the correct extension
-// */
-// private String getVirtualComponentNameWithExtension(IVirtualComponent virtComp) {
-// String virtCompURIMapName = this.getURIMappingName(virtComp);
-//
-// boolean linkedToEAR = true;
-// try {
-// if(virtComp.isBinary()){
-// linkedToEAR = ((J2EEModuleVirtualArchiveComponent)virtComp).isLinkedToEAR();
-// ((J2EEModuleVirtualArchiveComponent)virtComp).setLinkedToEAR(false);
-// }
-// if(JavaEEProjectUtilities.isDynamicWebComponent(virtComp)) {
-// if(!virtCompURIMapName.endsWith(IJ2EEModuleConstants.WAR_EXT)) {
-// //web module URIs need to end in WAR
-// virtCompURIMapName += IJ2EEModuleConstants.WAR_EXT;
-// }
-// } else if(JavaEEProjectUtilities.isJCAComponent(virtComp)) {
-// if(!virtCompURIMapName.endsWith(IJ2EEModuleConstants.RAR_EXT)) {
-// //connector module URIs need to end in RAR
-// virtCompURIMapName += IJ2EEModuleConstants.RAR_EXT;
-// }
-// } else if(!virtCompURIMapName.endsWith(IJ2EEModuleConstants.JAR_EXT)) {
-// //all other modules (EJB, AppClient, Utility) need to end in JAR
-// virtCompURIMapName += IJ2EEModuleConstants.JAR_EXT;
-// }
-// } finally {
-// if(virtComp.isBinary()){
-// ((J2EEModuleVirtualArchiveComponent)virtComp).setLinkedToEAR(linkedToEAR);
-// }
-// }
-// return virtCompURIMapName;
-// }
-//
-// /**
-// * [Bug 238264]
-// * determines a unique URI mapping name for a given component
-// * this is in case two components have the same name.
-// *
-// * @return returns a valid (none duplicate) uri mapping name for the given component\
-// */
-// private String getURIMappingName(IVirtualComponent archive) {
-//
-// //get the default uri map name for the given archive
-// IPath componentPath = Path.fromOSString(archive.getName());
-// String uriMapName = componentPath.lastSegment().replace(' ', '_');
-//
-//
-// //check to be sure this uri mapping is not already in use by another reference
-// boolean dupeArchiveName;
-// String refedCompName;
-// int lastDotIndex;
-// String increment;
-// IVirtualReference [] existingRefs = earComponent.getReferences();
-// for(int i=0;i<existingRefs.length;i++){
-// refedCompName = existingRefs[i].getReferencedComponent().getName();
-//
-// //if uri mapping names of the refed component and the given archive are the same
-// // find a new uri map name for the given archive
-// if(existingRefs[i].getArchiveName().equals(uriMapName)){
-// dupeArchiveName = true;
-// //find a new uriMapName for the given component
-// for(int j=1; dupeArchiveName; j++){
-// lastDotIndex = uriMapName.lastIndexOf('.');
-// increment = "_"+j; //$NON-NLS-1$
-//
-// //create the new potential name
-// if(lastDotIndex != -1){
-// uriMapName = uriMapName.substring(0, lastDotIndex) + increment +
uriMapName.substring(lastDotIndex);
-// } else {
-// uriMapName = uriMapName.substring(0)+increment;
-// }
-//
-// //determine if the new potential name is valid
-// for(int k=0; k<existingRefs.length; k++) {
-// dupeArchiveName = existingRefs[k].getArchiveName().equals(uriMapName);
-// if(dupeArchiveName) {
-// break;
-// }
-// }
-// }
-// }
-// }
-//
-// return uriMapName;
-// }
-//
-//
+ protected void handleAdded(ArrayList<Object> added) {
+ final ArrayList<IProject> projects = new ArrayList<IProject>();
+ final ArrayList<IVirtualComponent> components = new
ArrayList<IVirtualComponent>();
+ Iterator i = added.iterator();
+ Object o;
+ while(i.hasNext()) {
+ o = i.next();
+ if( o instanceof IProject )
+ projects.add((IProject)o);
+ else if( o instanceof IVirtualComponent)
+ components.add((IVirtualComponent)o);
+ }
+
+ IWorkspaceRunnable runnable = new IWorkspaceRunnable(){
+ public void run(IProgressMonitor monitor) throws CoreException{
+ addProjects(projects);
+ addComponents(components);
+ }
+ };
+ try {
+ J2EEUIPlugin.getWorkspace().run(runnable, new NullProgressMonitor());
+ } catch( CoreException e ) {
+ J2EEUIPlugin.logError(e);
+ }
+ }
+
+ protected void addProjects(ArrayList<IProject> projects) throws CoreException {
+ // These projects need to be converted to utility projects first
+ Iterator<IProject> i = projects.iterator();
+ IProject proj;
+ Set moduleProjects = new HashSet();
+ String path;
+ while(i.hasNext()) {
+ proj = i.next();
+ path = objectToRuntimePath.get(proj);
+ try {
+ moduleProjects.add(proj);
+ IDataModel migrationdm = DataModelFactory.createDataModel(new
JavaProjectMigrationDataModelProvider());
+ migrationdm.setProperty(IJavaProjectMigrationDataModelProperties.PROJECT_NAME,
proj.getName());
+ migrationdm.getDefaultOperation().execute(new NullProgressMonitor(), null);
+
+
+ IDataModel refdm = DataModelFactory.createDataModel(new
CreateReferenceComponentsDataModelProvider());
+ List targetCompList = (List)
refdm.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST);
+
+ IVirtualComponent targetcomponent = ComponentCore.createComponent(proj);
+ targetCompList.add(targetcomponent);
+
+ refdm.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT,
rootComponent);
+ refdm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST,
targetCompList);
+ refdm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH,
path);
+
+
+ // referenced java projects should have archiveName attribute
+ ((Map)refdm.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP)).put(targetcomponent,
proj.getName().replace(' ', '_') + IJ2EEModuleConstants.JAR_EXT);
+
+ refdm.getDefaultOperation().execute(new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ J2EEUIPlugin.logError(e);
+ }
+ }
+ postAddProjects(moduleProjects);
+ }
+
+ protected void postAddProjects(Set moduleProjects) throws CoreException {
+ }
+
+ protected void addComponents(ArrayList<IVirtualComponent> components) throws
CoreException {
+ Iterator<IVirtualComponent> i = components.iterator();
+ while(i.hasNext()) {
+ addOneComponent(i.next());
+ }
+ }
+
+ protected IDataModelProvider getAddReferenceDataModelProvider(IVirtualComponent
component) {
+ return new CreateReferenceComponentsDataModelProvider();
+ }
+
+ protected void addOneComponent(IVirtualComponent component) throws CoreException {
+ IDataModelProvider provider = getAddReferenceDataModelProvider(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 uriMap = new HashMap();
+ uriMap.put(component, getVirtualComponentNameWithExtension(component));
+ dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP,
uriMap);
+
dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH,
objectToRuntimePath.get(component));
+
+ 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) {
+ J2EEUIPlugin.logError(e);
+ }
+ }
+ /**
+ * Method returns the name of the given IVirtualComponent being sure the correct
extension
+ * is on the end of the name, this is important for internal projects. Added for [Bug
241509]
+ *
+ * @param virtComp the IVirtualComponent to get the name of with the correct extension
+ * @return the name of the given IVirtualComponent with the correct extension
+ */
+ private String getVirtualComponentNameWithExtension(IVirtualComponent virtComp) {
+ String virtCompURIMapName = this.getURIMappingName(virtComp);
+
+ boolean linkedToEAR = true;
+ try {
+ if(virtComp.isBinary()){
+ linkedToEAR = ((J2EEModuleVirtualArchiveComponent)virtComp).isLinkedToEAR();
+ ((J2EEModuleVirtualArchiveComponent)virtComp).setLinkedToEAR(false);
+ }
+ if(JavaEEProjectUtilities.isDynamicWebComponent(virtComp)) {
+ if(!virtCompURIMapName.endsWith(IJ2EEModuleConstants.WAR_EXT)) {
+ //web module URIs need to end in WAR
+ virtCompURIMapName += IJ2EEModuleConstants.WAR_EXT;
+ }
+ } else if(JavaEEProjectUtilities.isJCAComponent(virtComp)) {
+ if(!virtCompURIMapName.endsWith(IJ2EEModuleConstants.RAR_EXT)) {
+ //connector module URIs need to end in RAR
+ virtCompURIMapName += IJ2EEModuleConstants.RAR_EXT;
+ }
+ } else if(!virtCompURIMapName.endsWith(IJ2EEModuleConstants.JAR_EXT)) {
+ //all other modules (EJB, AppClient, Utility) need to end in JAR
+ virtCompURIMapName += IJ2EEModuleConstants.JAR_EXT;
+ }
+ } finally {
+ if(virtComp.isBinary()){
+ ((J2EEModuleVirtualArchiveComponent)virtComp).setLinkedToEAR(linkedToEAR);
+ }
+ }
+ return virtCompURIMapName;
+ }
+
+ /**
+ * [Bug 238264]
+ * determines a unique URI mapping name for a given component
+ * this is in case two components have the same name.
+ *
+ * @return returns a valid (none duplicate) uri mapping name for the given component\
+ */
+ private String getURIMappingName(IVirtualComponent archive) {
+
+ //get the default uri map name for the given archive
+ IPath componentPath = Path.fromOSString(archive.getName());
+ String uriMapName = componentPath.lastSegment().replace(' ', '_');
+
+
+ //check to be sure this uri mapping is not already in use by another reference
+ boolean dupeArchiveName;
+ String refedCompName;
+ int lastDotIndex;
+ String increment;
+ IVirtualReference [] existingRefs = rootComponent.getReferences();
+ for(int i=0;i<existingRefs.length;i++){
+ refedCompName = existingRefs[i].getReferencedComponent().getName();
+
+ //if uri mapping names of the refed component and the given archive are the same
+ // find a new uri map name for the given archive
+ if(existingRefs[i].getArchiveName().equals(uriMapName)){
+ dupeArchiveName = true;
+ //find a new uriMapName for the given component
+ for(int j=1; dupeArchiveName; j++){
+ lastDotIndex = uriMapName.lastIndexOf('.');
+ increment = "_"+j; //$NON-NLS-1$
+
+ //create the new potential name
+ if(lastDotIndex != -1){
+ uriMapName = uriMapName.substring(0, lastDotIndex) + increment +
uriMapName.substring(lastDotIndex);
+ } else {
+ uriMapName = uriMapName.substring(0)+increment;
+ }
+
+ //determine if the new potential name is valid
+ for(int k=0; k<existingRefs.length; k++) {
+ dupeArchiveName = existingRefs[k].getArchiveName().equals(uriMapName);
+ if(dupeArchiveName) {
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return uriMapName;
+ }
}
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddModulesToEarPropertiesPage.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddModulesToEarPropertiesPage.java 2009-06-10
09:42:34 UTC (rev 15842)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddModulesToEarPropertiesPage.java 2009-06-10
09:49:38 UTC (rev 15843)
@@ -1,19 +0,0 @@
-package org.jboss.ide.eclipse.as.wtp.override.ui.propertypage;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-public class AddModulesToEarPropertiesPage extends
- AddModuleDependenciesPropertiesPage {
-
-
- public AddModulesToEarPropertiesPage(IProject project,
- J2EEDependenciesPage page) {
- super(project, page);
- }
-
- protected boolean performOk(IProgressMonitor monitor) {
- return false;
- }
-
-}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/EarModuleDependenciesPropertyPage.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/EarModuleDependenciesPropertyPage.java 2009-06-10
09:42:34 UTC (rev 15842)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/EarModuleDependenciesPropertyPage.java 2009-06-10
09:49:38 UTC (rev 15843)
@@ -2,6 +2,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IProject;
@@ -13,8 +14,11 @@
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.Viewer;
+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;
@@ -22,6 +26,7 @@
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;
@@ -33,6 +38,7 @@
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;
@@ -148,7 +154,11 @@
}}, null);
}
- public boolean performOk(IProgressMonitor monitor) {
+ public boolean postHandleChanges(IProgressMonitor monitor) {
+ return true;
+ }
+
+ public boolean preHandleChanges(IProgressMonitor monitor) {
if (isVersion5) {
if (libDir.length() == 0) {
@@ -173,6 +183,24 @@
return true;
}
+ protected void handleRemoved(ArrayList<IVirtualComponent> removed) {
+ super.handleRemoved(removed);
+ J2EEComponentClasspathUpdater.getInstance().queueUpdateEAR(rootComponent.getProject());
+ }
+
+ protected IDataModelProvider getRemoveReferenceDataModelProvider(Object component) {
+ return new RemoveComponentFromEnterpriseApplicationDataModelProvider();
+ }
+
+ protected void postAddProjects(Set moduleProjects) throws CoreException {
+ EarFacetRuntimeHandler.updateModuleProjectRuntime(rootComponent.getProject(),
moduleProjects, new NullProgressMonitor());
+ }
+
+ protected IDataModelProvider getAddReferenceDataModelProvider(IVirtualComponent
component) {
+ return new AddComponentToEnterpriseApplicationDataModelProvider();
+ }
+
+
public class EarComponentDependencyContentProvider
extends ComponentDependencyContentProvider {