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;
}
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_PART) MPart part,
- @Named(IServiceConstants.ACTIVE_SELECTION) TreeNode selectedTreeNode,
+ @Optional @Named(IServiceConstants.ACTIVE_SELECTION) TreeNode selectedTreeNode,
MHandledMenuItem menuItem) {
boolean canExecute = false;
- Object value = selectedTreeNode.getValue();
- canExecute = value instanceof SingleRead && ((DerivateView) part.getObject()).getMultiLinkSingleReads().contains(value);
+ if(selectedTreeNode!=null){
+ Object value = selectedTreeNode.getValue();
+ canExecute = value instanceof SingleRead && ((DerivateView) part.getObject()).getMultiLinkSingleReads().contains(value);
+ }
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.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 value = selectedTreeNode.getValue();
- TreeNode clipboardNode = EditorUtil.getTreeNodeOfSelection(LocalSelectionTransfer.getTransfer().getSelection());
- if(value instanceof Sequence && clipboardNode!=null && clipboardNode.getValue() instanceof SingleRead
- && !((Sequence) value).getSingleReads().contains(clipboardNode.getValue())){
- canExecute = true;
+ if(selectedTreeNode!=null){
+ Object value = selectedTreeNode.getValue();
+ TreeNode clipboardNode = EditorUtil.getTreeNodeOfSelection(LocalSelectionTransfer.getTransfer().getSelection());
+ if(value instanceof Sequence && clipboardNode!=null && clipboardNode.getValue() instanceof SingleRead
+ && !((Sequence) value).getSingleReads().contains(clipboardNode.getValue())){
+ canExecute = true;
+ }
}
menuItem.setVisible(canExecute);
return canExecute;