Revision b6f56e18
Added by Patrick Plitzner almost 7 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/SingleReadReuseHandler.java | ||
---|---|---|
4 | 4 |
|
5 | 5 |
import org.eclipse.e4.core.di.annotations.CanExecute; |
6 | 6 |
import org.eclipse.e4.core.di.annotations.Execute; |
7 |
import org.eclipse.e4.core.di.annotations.Optional; |
|
7 | 8 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
8 | 9 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
9 | 10 |
import org.eclipse.e4.ui.services.IServiceConstants; |
... | ... | |
46 | 47 |
} |
47 | 48 |
|
48 | 49 |
@CanExecute |
49 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION) TreeNode selectedTreeNode, MHandledMenuItem menuItem) { |
|
50 |
public boolean canExecute(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) TreeNode selectedTreeNode, MHandledMenuItem menuItem) {
|
|
50 | 51 |
boolean canExecute = false; |
51 |
Object value = selectedTreeNode.getValue(); |
|
52 |
TreeNode clipboardNode = EditorUtil.getTreeNodeOfSelection(LocalSelectionTransfer.getTransfer().getSelection()); |
|
53 |
if(value instanceof Sequence && clipboardNode!=null && clipboardNode.getValue() instanceof SingleRead |
|
54 |
&& !((Sequence) value).getSingleReads().contains(clipboardNode.getValue())){ |
|
55 |
canExecute = true; |
|
52 |
if(selectedTreeNode!=null){ |
|
53 |
Object value = selectedTreeNode.getValue(); |
|
54 |
TreeNode clipboardNode = EditorUtil.getTreeNodeOfSelection(LocalSelectionTransfer.getTransfer().getSelection()); |
|
55 |
if(value instanceof Sequence && clipboardNode!=null && clipboardNode.getValue() instanceof SingleRead |
|
56 |
&& !((Sequence) value).getSingleReads().contains(clipboardNode.getValue())){ |
|
57 |
canExecute = true; |
|
58 |
} |
|
56 | 59 |
} |
57 | 60 |
menuItem.setVisible(canExecute); |
58 | 61 |
return canExecute; |
Also available in: Unified diff
ref #6566 Adjust SingleRead context menu items visibility