Monday, 15 June
2009
Mon, 15 Jun
'09
5:06 a.m.
Author: rob.stryker(a)jboss.com
Date: 2009-06-15 06:06:02 -0400 (Mon, 15 Jun 2009)
New Revision: 15946
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/ComponentDependencyContentProvider.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:
Committing update in case eclipse guys check it out today.
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-15
09:07:32 UTC (rev 15945)
+++
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-15
10:06:02 UTC (rev 15946)
@@ -36,33 +36,27 @@
import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ICellModifier;
-import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+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.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TextCellEditor;
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;
@@ -104,16 +98,13 @@
IJ2EEDependenciesControl {
protected final String PATH_SEPARATOR =
ComponentDependencyContentProvider.PATH_SEPARATOR;
- protected boolean showRuntimePath;
protected final IProject project;
protected final J2EEDependenciesPage propPage;
protected IVirtualComponent rootComponent = null;
protected Text componentNameText;
protected Label availableModules;
- protected CheckboxTableViewer availableComponentsViewer;
- protected Button selectAllButton;
- protected Button deselectAllButton;
- protected Button projectButton;
+ protected TableViewer availableComponentsViewer;
+ protected Button projectButton, removeButton;
protected Button projectJarButton;
protected Button externalJarButton;
protected Button addVariableButton;
@@ -124,8 +115,7 @@
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 (not removed)
protected HashMap<Object, String> objectToRuntimePath = new HashMap<Object,
String>();
// [Bug 238264] the cached list elements that are new and need to be
@@ -141,17 +131,8 @@
this.project = project;
this.propPage = page;
rootComponent = ComponentCore.createComponent(project);
- this.showRuntimePath = true;
}
- protected boolean getShowRuntimePath() {
- return this.showRuntimePath;
- }
-
- protected void setShowRuntimePath(boolean bool) {
- this.showRuntimePath = bool;
- }
-
/*
* UI Creation Methods
*/
@@ -215,13 +196,7 @@
createPushButtons();
}
- // 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;
-
- selectAllButton = createPushButton(SELECT_ALL_BUTTON);
- deselectAllButton = createPushButton(DE_SELECT_ALL_BUTTON);
projectButton = createPushButton("Add Project...");
projectJarButton = createPushButton(J2EEUIMessages
.getResourceString(J2EEUIMessages.PROJECT_JAR));
@@ -229,6 +204,7 @@
.getResourceString(J2EEUIMessages.EXTERNAL_JAR));
addVariableButton = createPushButton(J2EEUIMessages
.getResourceString(J2EEUIMessages.ADDVARIABLE));
+ removeButton = createPushButton("Remove selected...");
}
protected Button createPushButton(String label) {
@@ -267,8 +243,6 @@
provider.setRuntimePaths(objectToRuntimePath);
availableComponentsViewer.setContentProvider(provider);
availableComponentsViewer.setLabelProvider(provider);
- availableComponentsViewer
- .setFilters(new ViewerFilter[] { provider });
addTableListeners();
}
}
@@ -277,9 +251,7 @@
* Subclasses should over-ride this and extend the class
*/
protected ComponentDependencyContentProvider createProvider() {
- int j2eeVersion = J2EEVersionUtil
- .convertVersionStringToInt(rootComponent);
- return new ComponentDependencyContentProvider(rootComponent);
+ return new ComponentDependencyContentProvider();
}
/*
@@ -287,9 +259,9 @@
*/
protected void addTableListeners() {
- addCheckStateListener();
addHoverHelpListeners();
addDoubleClickListener();
+ addSelectionListener();
}
protected void addHoverHelpListeners() {
@@ -343,9 +315,7 @@
}
case SWT.MouseHover: {
TableItem item = table.getItem(new Point(event.x, event.y));
- if (item != null) {
- if (!item.getGrayed())
- return;
+ if (item != null && item.getData() != null &&
!canEdit(item.getData())) {
if (tip != null && !tip.isDisposed())
tip.dispose();
tip = new Shell(PlatformUI.getWorkbench()
@@ -362,8 +332,7 @@
label.setBackground(Display.getDefault()
.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
label.setData("_TABLEITEM", item); //$NON-NLS-1$
- label
- .setText(J2EEUIMessages
+ label.setText(J2EEUIMessages
.getResourceString(J2EEUIMessages.HOVER_HELP_FOR_DISABLED_LIBS));
label.addListener(SWT.MouseExit, labelListener);
label.addListener(SWT.MouseDown, labelListener);
@@ -379,6 +348,11 @@
};
}
+ protected boolean canEdit(Object data) {
+ return !(data != null && data instanceof VirtualArchiveComponent
+ && isPhysicallyAdded((VirtualArchiveComponent)data));
+ }
+
protected void addDoubleClickListener() {
availableComponentsViewer.setColumnProperties(new String[] { "a",
"b",
"c" });
@@ -390,6 +364,24 @@
.setCellModifier(new RuntimePathCellModifier());
}
+ protected void addSelectionListener() {
+ availableComponentsViewer.addSelectionChangedListener(
+ new ISelectionChangedListener(){
+ public void selectionChanged(SelectionChangedEvent event) {
+ viewerSelectionChanged();
+ }
+ });
+ }
+
+ protected void viewerSelectionChanged() {
+ removeButton.setEnabled(getSelectedObject() != null &&
canEdit(getSelectedObject()));
+ }
+
+ protected Object getSelectedObject() {
+ IStructuredSelection sel =
(IStructuredSelection)availableComponentsViewer.getSelection();
+ return sel.getFirstElement();
+ }
+
private class RuntimePathCellModifier implements ICellModifier {
public boolean canModify(Object element, String property) {
@@ -431,11 +423,7 @@
}
public void handleEvent(Event event) {
- if (event.widget == selectAllButton)
- handleSelectAllButtonPressed();
- else if (event.widget == deselectAllButton)
- handleDeselectAllButtonPressed();
- else if (event.widget == projectButton)
+ if (event.widget == projectButton)
handleSelectProjectButton();
else if (event.widget == projectJarButton)
handleSelectProjectJarButton();
@@ -443,26 +431,10 @@
handleSelectExternalJarButton();
else if (event.widget == addVariableButton)
handleSelectVariableButton();
+ else if( event.widget == removeButton )
+ handleRemoveSelectedButton();
}
- 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);
- }
- }
-
- 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);
- }
- }
-
private void handleSelectProjectButton() {
SelectProjectDialog d = new SelectProjectDialog(new Shell(),
getProjectLabelProvider(), getProjectContentProvider());
@@ -637,35 +609,26 @@
}
}
- // 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
- }
- });
+ protected void handleRemoveSelectedButton() {
+ ISelection sel = availableComponentsViewer.getSelection();
+ if( sel instanceof IStructuredSelection ) {
+ Object o = ((IStructuredSelection)sel).getFirstElement();
+ objectToRuntimePath.remove(o);
+ refresh();
+ }
}
- public CheckboxTableViewer createAvailableComponentsViewer(Composite parent) {
- int flags = SWT.CHECK | SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI;
+ public TableViewer createAvailableComponentsViewer(Composite parent) {
+ int flags = SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI;
Table table = new Table(parent, flags);
- availableComponentsViewer = new CheckboxTableViewer(table);
+ availableComponentsViewer = new TableViewer(table);
// set up table layout
TableLayout tableLayout = new org.eclipse.jface.viewers.TableLayout();
tableLayout.addColumnData(new ColumnWeightData(300, true));
tableLayout.addColumnData(new ColumnWeightData(300, true));
- if (showRuntimePath)
- tableLayout.addColumnData(new ColumnWeightData(200, true));
+ tableLayout.addColumnData(new ColumnWeightData(200, true));
table.setLayout(tableLayout);
table.setHeaderVisible(true);
table.setLinesVisible(true);
@@ -680,11 +643,9 @@
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);
- }
+ TableColumn bndColumn = new TableColumn(table, SWT.NONE, 2);
+ bndColumn.setText(ManifestUIResourceHandler.Packed_In_Lib_UI_);
+ bndColumn.setResizable(true);
tableLayout.layout(table, true);
return availableComponentsViewer;
@@ -701,62 +662,6 @@
}
}
- 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;
- 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 {
- 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]);
- IVirtualReference[] refs = cmp1.getReferences();
- for (int j = 0; j < refs.length; j++) {
- 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]);
@@ -787,39 +692,14 @@
* tasks
*/
public void refresh() {
- TableItem[] items = availableComponentsViewer.getTable().getItems();
- HashMap<Object, Boolean> checked = cacheChecked();
resetTableUI();
if (!hasInitialized) {
initialize();
resetTableUI();
}
- /*
- * 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()))
- newItems[i].setChecked(checked.get(newItems[i].getData()));
- }
}
- 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) {
- int j = 0;
- for (int i = 0; i < items.length; i++) {
- if (addedElements.contains(items[i].getData()))
- checked.put(items[i].getData(), items[i].getChecked());
- }
- }
- return checked;
- }
-
protected void resetTableUI() {
IWorkspaceRoot input = ResourcesPlugin.getWorkspace().getRoot();
availableComponentsViewer.setInput(input);
@@ -832,91 +712,20 @@
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
- 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();
-
- // First initialize the paths
- Object data;
- 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();
- objectToRuntimePath.put(data, val);
- oldComponentToRuntimePath.put((IVirtualComponent) data, val);
- }
+ IVirtualReference[] refs = rootComponent.getReferences();
+ IVirtualComponent comp;
+ for( int i = 0; i < refs.length; i++ ) {
+ comp = refs[i].getReferencedComponent();
+ String val = refs[i].getRuntimePath().toString();
+ objectToRuntimePath.put(comp, val);
+ oldComponentToRuntimePath.put((IVirtualComponent) comp, 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()))
- items[i].setChecked(true);
-
- 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]))
- list.add(refs[i].getReferencedComponent());
- }
- return list;
- }
-
- protected boolean isChildComponent(IVirtualReference ref) {
- // 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])) {
- IVirtualComponent comp = refs[i].getReferencedComponent();
- addClasspathComponentDependencies(list, pathToComp, comp);
- }
- }
- return list;
- }
-
- 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.
@@ -961,8 +770,7 @@
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());
+ checked.add(items[i].getData());
// Fill our delta lists
ArrayList<Object> added = new ArrayList<Object>();
@@ -974,7 +782,7 @@
while (j.hasNext()) {
key = j.next();
val = oldComponentToRuntimePath.get(key);
- if (!checked.contains(key))
+ if( !objectToRuntimePath.containsKey(key))
removed.add((IVirtualComponent)key);
else if (!val.equals(objectToRuntimePath.get(key)))
changed.add((IVirtualComponent)key);
@@ -993,8 +801,24 @@
return false;
handleDeltas(removed, changed, added);
-
subResult &= postHandleChanges(monitor);
+
+ // Now update the variables
+ oldComponentToRuntimePath.clear();
+ ArrayList keys = new ArrayList();
+ keys.addAll(objectToRuntimePath.keySet());
+ Iterator i = keys.iterator();
+ while(i.hasNext()) {
+ Object component = i.next();
+ IVirtualComponent vc = component instanceof IVirtualComponent ?
(IVirtualComponent)component : null;
+ String path = objectToRuntimePath.get(component);
+ if( component instanceof IProject ) {
+ objectToRuntimePath.remove(component);
+ vc = ComponentCore.createComponent((IProject)component);
+ objectToRuntimePath.put(vc, path);
+ }
+ oldComponentToRuntimePath.put(vc, path);
+ }
return subResult;
}
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-06-15
09:07:32 UTC (rev 15945)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ComponentDependencyContentProvider.java 2009-06-15
10:06:02 UTC (rev 15946)
@@ -11,9 +11,7 @@
*******************************************************************************/
package org.jboss.ide.eclipse.as.wtp.override.ui.propertypage;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
@@ -22,137 +20,50 @@
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jst.j2ee.application.internal.operations.ClassPathSelection;
-import org.eclipse.jst.j2ee.classpathdep.ClasspathDependencyUtil;
-import org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants;
-import org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.ModuleCoreNature;
-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;
-public class ComponentDependencyContentProvider extends ViewerFilter implements
IStructuredContentProvider, ITableLabelProvider {
+
+/*
+ * The only valid elements this content provider (should) provide
+ * are IProject or IVirtualComponent objects. The runtime paths portion is
+ * shared with the preference page itself where they can both modify the data.
+ *
+ * The pref page should initialize its data first so that this provider can
+ * spit out the proper information.
+ */
+public class ComponentDependencyContentProvider extends LabelProvider implements
IStructuredContentProvider, ITableLabelProvider {
final static String PATH_SEPARATOR = String.valueOf(IPath.SEPARATOR);
- private IVirtualComponent rootComponent;
private HashMap<Object, String> runtimePaths;
- public ComponentDependencyContentProvider(IVirtualComponent rootComponent) {
+ public ComponentDependencyContentProvider() {
super();
- this.rootComponent = rootComponent;
}
public void setRuntimePaths(HashMap<Object, String> paths) {
this.runtimePaths = paths;
}
- /*
- * (non-Javadoc)
- *
- * @see
org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
public Object[] getElements(Object inputElement) {
- if( rootComponent == null )
- return new Object[]{};
-
Object[] empty = new Object[0];
- if (!(inputElement instanceof IWorkspaceRoot))
+ if( !(inputElement instanceof IWorkspaceRoot))
return empty;
- IProject[] projects = ((IWorkspaceRoot) inputElement).getProjects();
- if (projects == null || projects.length == 0)
- return empty;
- List validCompList = new ArrayList();
- HashMap pathToComp = new HashMap();
- for (int i = 0; i < projects.length; i++) {
- // get flexible project
- IProject project = projects[i];
- if(ModuleCoreNature.isFlexibleProject(project)){
- IVirtualComponent component = ComponentCore.createComponent(project);
- if( !component.equals(rootComponent))
- validCompList.add(component);
- else {
- IVirtualReference[] newrefs = component.getReferences();
- for( int k=0; k< newrefs.length; k++ ){
- IVirtualReference tmpref = newrefs[k];
- IVirtualComponent referencedcomp = tmpref.getReferencedComponent();
- boolean isBinary = referencedcomp.isBinary();
- if( isBinary ){
- validCompList.add(referencedcomp);
- } else {
- addClasspathComponentDependencies(validCompList,pathToComp, referencedcomp);
- }
- }
- }
- } else if (project.exists() && project.isAccessible() ){
- if( !project.getName().startsWith(".") ) //$NON-NLS-1$
- validCompList.add(project);
- }
- }
- return validCompList.toArray();
+ return runtimePaths.keySet().toArray();
}
- public static void addClasspathComponentDependencies(final List componentList, HashMap
pathToComp, final IVirtualComponent referencedComponent) {
- if (referencedComponent instanceof J2EEModuleVirtualComponent) {
- J2EEModuleVirtualComponent j2eeComp = (J2EEModuleVirtualComponent)
referencedComponent;
- IVirtualReference[] cpRefs = j2eeComp.getJavaClasspathReferences();
- for (int j=0; j < cpRefs.length; j++) {
- String unresolvedURI = null;
- // only ../ mappings supported at this level
- if
(!cpRefs[j].getRuntimePath().equals(IClasspathDependencyConstants.RUNTIME_MAPPING_INTO_CONTAINER_PATH))
{
- continue;
- }
- // if the absolute path for this component already has a mapping, skip (the comp
might be contributed by more than
- // one child module)
- final IPath path =
ClasspathDependencyUtil.getClasspathVirtualReferenceLocation(cpRefs[j]);
- final IVirtualComponent comp = (IVirtualComponent) pathToComp.get(path);
- if (comp != null) {
- // replace with a temp VirtualArchiveComponent whose IProject is set to a new pseudo
name that is
- // the concatenation of all project contributions for that archive
- if (comp instanceof VirtualArchiveComponent) {
- final VirtualArchiveComponent oldComp = (VirtualArchiveComponent) comp;
- componentList.remove(comp);
- final VirtualArchiveComponent newComponent =
ClassPathSelection.updateDisplayVirtualArchiveComponent(oldComp, cpRefs[j]);
- pathToComp.put(path, newComponent);
- componentList.add(newComponent);
- }
- continue;
- } else {
- pathToComp.put(path, cpRefs[j].getReferencedComponent());
- }
- componentList.add(cpRefs[j].getReferencedComponent());
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object,
int)
- */
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
- /*
- * Because the Dependency page modifies the rows by hand,
- * and also because there's a Cell modifier used, we need
- * to know the most recent change, so we reference runtimePaths
- */
public String getColumnText(Object element, int columnIndex) {
if (element instanceof IVirtualComponent) {
IVirtualComponent comp = (IVirtualComponent)element;
- String name = ""; //$NON-NLS-1$
if( columnIndex == 0 ){
- if (ClasspathDependencyUtil.isClasspathComponentDependency(comp)) {
- return ClasspathDependencyUtil.getClasspathComponentDependencyDisplayString(comp);
- }
- name = comp.getName();
- return name;
+ return comp.getName();
} else if (columnIndex == 1) {
return comp.getProject().getName();
} else if (columnIndex == 2) {
@@ -174,28 +85,6 @@
return null;
}
- /*
- * Do we want this element to be shown or not?
- */
- @Override
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- return true;
- }
-
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
-
- public void dispose() {
- }
-
- public void addListener(ILabelProviderListener listener) {
- }
-
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-
- public void removeListener(ILabelProviderListener listener) {
- }
-
}
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-15
09:07:32 UTC (rev 15945)
+++
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-15
10:06:02 UTC (rev 15946)
@@ -1,7 +1,6 @@
package org.jboss.ide.eclipse.as.wtp.override.ui.propertypage;
import java.util.ArrayList;
-import java.util.List;
import java.util.Set;
import org.eclipse.core.commands.ExecutionException;
@@ -13,7 +12,6 @@
import org.eclipse.core.runtime.Path;
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;
@@ -81,10 +79,6 @@
}
}
}
-
- protected ComponentDependencyContentProvider createProvider() {
- return new EarComponentDependencyContentProvider(rootComponent);
- }
protected void createPushButtons() {
super.createPushButtons();
@@ -199,24 +193,4 @@
protected IDataModelProvider getAddReferenceDataModelProvider(IVirtualComponent
component) {
return new AddComponentToEnterpriseApplicationDataModelProvider();
}
-
-
- public class EarComponentDependencyContentProvider
- extends ComponentDependencyContentProvider {
-
- public EarComponentDependencyContentProvider(
- IVirtualComponent rootComponent) {
- super(rootComponent);
- }
-
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- List forceCheck = new ArrayList();
- forceCheck.addAll(getChildrenComponents());
- forceCheck.addAll(getCPComponents());
- if( forceCheck.contains(element) || addedElements.contains(element))
- return true;
- return false;
- }
- }
-
}