Author: rob.stryker(a)jboss.com
Date: 2010-10-05 08:09:33 -0400 (Tue, 05 Oct 2010)
New Revision: 25485
Modified:
trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/providers/ArchivesActionProvider.java
Log:
JBIDE-7112 - patch from snjezana
Modified:
trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/providers/ArchivesActionProvider.java
===================================================================
---
trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/providers/ArchivesActionProvider.java 2010-10-05
11:22:23 UTC (rev 25484)
+++
trunk/archives/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/providers/ArchivesActionProvider.java 2010-10-05
12:09:33 UTC (rev 25485)
@@ -13,7 +13,10 @@
import java.util.Arrays;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
@@ -21,6 +24,7 @@
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.osgi.util.NLS;
@@ -32,6 +36,7 @@
import org.eclipse.ui.navigator.ICommonViewerSite;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
import org.jboss.ide.eclipse.archives.core.build.SaveArchivesJob;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
@@ -79,6 +84,11 @@
}
public void fillContextMenu(IMenuManager manager) {
+ if (getContext() != null) {
+ enableBuildAction(buildAction, getContext().getSelection());
+ } else {
+ buildAction.setEnabled(false);
+ }
menuAboutToShow2(manager);
}
@@ -172,9 +182,28 @@
};
}
+ private void enableBuildAction(IAction action, ISelection selection) {
+ Object selected = null;
+ if( !selection.isEmpty() && selection instanceof IStructuredSelection ) {
+ Object o = ((IStructuredSelection)selection).getFirstElement();
+ if(o instanceof WrappedProject )
+ o = ((WrappedProject)o).getElement();
+ if( o instanceof IAdaptable ) {
+ IResource res = (IResource) ((IAdaptable)o).getAdapter(IResource.class);
+ if( res != null ) {
+ selected = res.getProject();
+ }
+ }
+ if( o instanceof IArchiveNode )
+ selected = o;
+ boolean enabled = selected instanceof IArchiveNode
+ || ArchivesModel.instance().canReregister(
+ ((IProject) selected).getLocation());
+ action.setEnabled(enabled);
+ }
+ }
-
private void addContextMenuContributions (final IArchiveNode context, IMenuManager mgr)
{
for( int i = 0; i < nodePopupMenuContributions.length; i++ ) {