[jbosstools-commits] JBoss Tools SVN: r17808 - trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Tue Sep 29 14:58:08 EDT 2009


Author: rob.stryker at jboss.com
Date: 2009-09-29 14:58:07 -0400 (Tue, 29 Sep 2009)
New Revision: 17808

Modified:
   trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/AddModuleDependenciesPropertiesPage.java
   trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/NewReferenceWizard.java
Log:
JBIDE-4957 - adding edit button to new reference wizard (changes to default enablement)

Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/AddModuleDependenciesPropertiesPage.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/AddModuleDependenciesPropertiesPage.java	2009-09-29 16:53:44 UTC (rev 17807)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/AddModuleDependenciesPropertiesPage.java	2009-09-29 18:58:07 UTC (rev 17808)
@@ -79,6 +79,7 @@
 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.server.ui.wizard.WizardFragment;
 import org.jboss.ide.eclipse.as.wtp.ui.Messages;
 import org.jboss.ide.eclipse.as.wtp.ui.WTPOveridePlugin;
  
@@ -304,7 +305,7 @@
 				}
 				case SWT.MouseHover: {
 					TableItem item = table.getItem(new Point(event.x, event.y));
-					if (item != null && item.getData() != null && !canEdit(item.getData())) {
+					if (item != null && item.getData() != null && !canEditPath(item.getData())) {
 						if (tip != null && !tip.isDisposed())
 							tip.dispose();
 						tip = new Shell(PlatformUI.getWorkbench()
@@ -337,7 +338,7 @@
 		};
 	}
 
-	protected boolean canEdit(Object data) {
+	protected boolean canEditPath(Object data) {
 		if( data == null ) return false;
 		if( !(data instanceof VirtualArchiveComponent)) return true;
 		
@@ -370,9 +371,17 @@
 	}
 	
 	protected void viewerSelectionChanged() {
-		removeButton.setEnabled(getSelectedObject() != null && canEdit(getSelectedObject()));
+		editReferenceButton.setEnabled(hasEditWizardPage(getSelectedObject()));
+		removeButton.setEnabled(getSelectedObject() != null && canEditPath(getSelectedObject()));
 	}
 	
+	protected boolean hasEditWizardPage(Object o) {
+		if( o == null || !(o instanceof IVirtualComponent)) 
+			return false;
+		WizardFragment wf = NewReferenceWizard.getFirstEditingFragment((IVirtualComponent)o);
+		return wf != null;
+	}
+	
 	protected Object getSelectedObject() {
 		IStructuredSelection sel = (IStructuredSelection)availableComponentsViewer.getSelection();
 		return sel.getFirstElement();
@@ -384,7 +393,7 @@
 			if( property.equals(DEPLOY_PATH_PROPERTY)) {
 				if (element instanceof VirtualArchiveComponent) {
 					try {
-						return canEdit(element);
+						return canEditPath(element);
 					} catch (IllegalArgumentException iae) {
 					}
 				}
@@ -588,6 +597,8 @@
 					allMappings[i].getSourcePath(), allMappings[i].getRuntimePath()
 			));
 		}
+		removeButton.setEnabled(false);
+		editReferenceButton.setEnabled(false);
 		hasInitialized = true;
 	}
 

Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/NewReferenceWizard.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/NewReferenceWizard.java	2009-09-29 16:53:44 UTC (rev 17807)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/NewReferenceWizard.java	2009-09-29 18:58:07 UTC (rev 17808)
@@ -26,18 +26,24 @@
 			if( component == null )
 				list.add(new NewReferenceRootWizardFragment());
 			else {
-				WizardFragment[] frags = DependencyPageExtensionManager.getManager().loadAllReferenceWizardFragments();
-				for( int i = 0; i < frags.length; i++ ) {
-					if( frags[i] instanceof IReferenceEditor ) {
-						if( ((IReferenceEditor)frags[i]).canEdit(component)) {
-							// accept first one
-							list.add(frags[i]);
-							return;
-						}
-					}
+				WizardFragment fragment = getFirstEditingFragment(component);
+				if( fragment != null )
+					list.add(fragment);
+			}
+		}
+	}
+	
+	public static WizardFragment getFirstEditingFragment(IVirtualComponent component ) {
+		WizardFragment[] frags = DependencyPageExtensionManager.getManager().loadAllReferenceWizardFragments();
+		for( int i = 0; i < frags.length; i++ ) {
+			if( frags[i] instanceof IReferenceEditor ) {
+				if( ((IReferenceEditor)frags[i]).canEdit(component)) {
+					// accept first one
+					return frags[i];
 				}
 			}
 		}
+		return null;
 	}
 	
 	public void init(IWorkbench newWorkbench, IStructuredSelection newSelection) {



More information about the jbosstools-commits mailing list