ref #6909 Add canExecute to linkWithTaxonHandler
authorPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 8 Nov 2017 07:47:24 +0000 (08:47 +0100)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 8 Nov 2017 07:47:24 +0000 (08:47 +0100)
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/LinkWithTaxonHandlerE4.java

index 71f40c6eed355c5bf6cd7330cdfb7a22736200d0..6a158e29366fc22a307fb5c76b28fd7221ee5792 100644 (file)
@@ -10,8 +10,10 @@ package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler;
 
 import javax.inject.Named;
 
+import org.eclipse.e4.core.di.annotations.CanExecute;
 import org.eclipse.e4.core.di.annotations.Execute;
 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
 import org.eclipse.e4.ui.services.IServiceConstants;
 
 import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
@@ -29,4 +31,13 @@ public class LinkWithTaxonHandlerE4 {
         TaxonNavigatorE4 taxonNavigator = (TaxonNavigatorE4) activePart.getObject();
         taxonNavigator.setLinkWithTaxon(!taxonNavigator.isLinkWithTaxon());
        }
+
+    @CanExecute
+    public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
+            MHandledMenuItem menuItem){
+        boolean canExecute = false;
+        canExecute = activePart.getObject() instanceof TaxonNavigatorE4;
+        menuItem.setVisible(canExecute);
+        return canExecute;
+    }
 }