import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.core.di.annotations.Optional;
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;
}
@CanExecute
- public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION) TreeNode selectedTreeNode, MHandledMenuItem menuItem) {
+ public boolean canExecute(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) TreeNode selectedTreeNode, MHandledMenuItem menuItem) {
boolean canExecute = false;
- Object object = selectedTreeNode.getValue();
- canExecute = (object instanceof SingleRead);
+ if(selectedTreeNode!=null){
+ Object object = selectedTreeNode.getValue();
+ canExecute = (object instanceof SingleRead);
+ }
menuItem.setVisible(canExecute);
return canExecute;
}