import org.eclipse.e4.ui.model.application.ui.menu.MMenuItem;
import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.DescriptiveDataSetEditor;
public class DescriptiveDataSetRemoveTaxonHandler {
@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
MMenuItem menuItem) {
boolean canExecute = false;
- canExecute = !selection.isEmpty() && activePart.getObject() instanceof DescriptiveDataSetEditor;
- menuItem.setVisible(canExecute);
+ TreeSelection sel= ((TreeViewer)((DescriptiveDataSetEditor)activePart.getObject()).getTaxonTreeViewer()).getSelection() instanceof TreeSelection ?(TreeSelection)((TreeViewer)((DescriptiveDataSetEditor)activePart.getObject()).getTaxonTreeViewer()).getSelection(): null;
+ canExecute = !selection.isEmpty() && activePart.getObject() instanceof DescriptiveDataSetEditor && sel != null && (sel.getFirstElement() instanceof TaxonNode );
+ menuItem.setVisible(canExecute);
return canExecute;
}