Revision b6f56e18
Added by Patrick Plitzner almost 7 years ago
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 |
} |
Also available in: Unified diff
ref #6566 Adjust SingleRead context menu items visibility