Revision b6f56e18
Added by Patrick Plitzner almost 7 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/SingleReadCopyToClipboardHandler.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; |
... | ... | |
25 | 26 |
} |
26 | 27 |
|
27 | 28 |
@CanExecute |
28 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION) TreeNode selectedTreeNode, MHandledMenuItem menuItem) { |
|
29 |
public boolean canExecute(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) TreeNode selectedTreeNode, MHandledMenuItem menuItem) {
|
|
29 | 30 |
boolean canExecute = false; |
30 |
Object object = selectedTreeNode.getValue(); |
|
31 |
canExecute = (object instanceof SingleRead); |
|
31 |
if(selectedTreeNode!=null){ |
|
32 |
Object object = selectedTreeNode.getValue(); |
|
33 |
canExecute = (object instanceof SingleRead); |
|
34 |
} |
|
32 | 35 |
menuItem.setVisible(canExecute); |
33 | 36 |
return canExecute; |
34 | 37 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/SingleReadRemoveHandler.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; |
... | ... | |
40 | 41 |
|
41 | 42 |
@CanExecute |
42 | 43 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART) MPart part, |
43 |
@Named(IServiceConstants.ACTIVE_SELECTION) TreeNode selectedTreeNode, |
|
44 |
@Optional @Named(IServiceConstants.ACTIVE_SELECTION) TreeNode selectedTreeNode,
|
|
44 | 45 |
MHandledMenuItem menuItem) { |
45 | 46 |
boolean canExecute = false; |
46 |
Object value = selectedTreeNode.getValue(); |
|
47 |
canExecute = value instanceof SingleRead && ((DerivateView) part.getObject()).getMultiLinkSingleReads().contains(value); |
|
47 |
if(selectedTreeNode!=null){ |
|
48 |
Object value = selectedTreeNode.getValue(); |
|
49 |
canExecute = value instanceof SingleRead && ((DerivateView) part.getObject()).getMultiLinkSingleReads().contains(value); |
|
50 |
} |
|
48 | 51 |
menuItem.setVisible(canExecute); |
49 | 52 |
return canExecute; |
50 | 53 |
} |
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