@CanExecute
private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
boolean canExecute = false;
- canExecute = selection.getFirstElement() instanceof TaxonNode
+ canExecute = selection.size()==1
+ && selection.getFirstElement() instanceof TaxonNode
&& ((TaxonNode) selection.getFirstElement()).getTaxon()==null
&& PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_EXPERIMENTAL_FEATURES);
menuItem.setVisible(canExecute);
import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.jface.viewers.TreeSelection;
-import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
@CanExecute
private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
boolean canExecute = false;
- canExecute = selection.getFirstElement() instanceof ITaxonTreeNode;
+ canExecute = selection.size()==1
+ && selection.getFirstElement() instanceof TaxonNodeDto;
menuItem.setVisible(canExecute);
return canExecute;
}
@CanExecute
private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
boolean canExecute = false;
- canExecute = selection.getFirstElement() instanceof TaxonNode
+ canExecute = selection.size()==1
+ && selection.getFirstElement() instanceof TaxonNode
&& ((TaxonNode) selection.getFirstElement()).getTaxon()==null
&& PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_EXPERIMENTAL_FEATURES);
menuItem.setVisible(canExecute);
@CanExecute
private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
boolean canExecute = false;
- canExecute = !selection.isEmpty() && !(selection.getFirstElement() instanceof Synonym);
+ canExecute = !selection.isEmpty();
+ Object[] array = selection.toArray();
+ for (Object object : array) {
+ canExecute &= !(object instanceof Synonym);
+ }
menuItem.setVisible(canExecute);
return canExecute;
}
import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.MApplication;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
}
@CanExecute
- private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection){
- return selection!=null && !selection.isEmpty();
+ private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection,
+ MHandledMenuItem menuItem){
+ boolean canExecute = false;
+ canExecute = selection!=null && selection.size()==1;
+ menuItem.setVisible(canExecute);
+ return canExecute;
}
}
import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.jface.viewers.TreeSelection;
-import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
/**
@CanExecute
private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
boolean canExecute = false;
- canExecute = selection.getFirstElement() instanceof TaxonNodeDto;
+ canExecute = !selection.isEmpty();
menuItem.setVisible(canExecute);
return canExecute;
}
@CanExecute
private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
boolean canExecute = false;
- canExecute = (selection.getFirstElement() instanceof TaxonNodeDto) && ((TaxonNodeDto)selection.getFirstElement()).getTaxonUuid() != null ;
+ canExecute = selection.size()==1
+ && selection.getFirstElement() instanceof TaxonNodeDto
+ && ((TaxonNodeDto)selection.getFirstElement()).getTaxonUuid() != null ;
menuItem.setVisible(canExecute);
return canExecute;
}
@CanExecute
private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
boolean canExecute = false;
- Object selectionElement = selection.getFirstElement();
-
- canExecute = (selectionElement instanceof TaxonNodeDto) ||
- (selectionElement instanceof TaxonNode && ((TaxonNode)selectionElement).getTaxon() == null);
+ canExecute = selection.size()==1
+ && (selection.getFirstElement() instanceof TaxonNodeDto)
+ ||
+ (selection.getFirstElement() instanceof TaxonNode
+ && ((TaxonNode)selection.getFirstElement()).getTaxon() == null);
menuItem.setVisible(canExecute);
return canExecute;
}
@CanExecute
private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
boolean canExecute = false;
- canExecute = (selection.getFirstElement() instanceof TaxonNodeDto) && ((TaxonNodeDto)selection.getFirstElement()).getTaxonUuid() != null;
+ canExecute = selection.size()==1
+ && selection.getFirstElement() instanceof TaxonNodeDto
+ && ((TaxonNodeDto)selection.getFirstElement()).getTaxonUuid() != null;
menuItem.setVisible(canExecute);
return canExecute;
}
@CanExecute
private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
boolean canExecute = false;
- canExecute = (selection.getFirstElement() instanceof TaxonNodeDto) && ((TaxonNodeDto)selection.getFirstElement()).getTaxonUuid() != null;
+ canExecute = selection.size()==1
+ && selection.getFirstElement() instanceof TaxonNodeDto
+ && ((TaxonNodeDto)selection.getFirstElement()).getTaxonUuid() != null;
menuItem.setVisible(canExecute);
return canExecute;
}
@CanExecute
private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
boolean canExecute = false;
- canExecute = selection.getFirstElement() instanceof TaxonNodeDto;
+ canExecute = selection.size()==1
+ && selection.getFirstElement() instanceof TaxonNodeDto;
menuItem.setVisible(canExecute);
return canExecute;
}
@CanExecute
private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
boolean canExecute = false;
- canExecute = selection.getFirstElement() instanceof TaxonNodeDto;
+ canExecute = selection.size()==1
+ && selection.getFirstElement() instanceof TaxonNodeDto;
menuItem.setVisible(canExecute);
return canExecute;
}