Revision f57d8d08
Added by Patrick Plitzner about 6 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/handler/RemoveFeatureHandler.java | ||
---|---|---|
12 | 12 |
|
13 | 13 |
import org.eclipse.e4.core.di.annotations.CanExecute; |
14 | 14 |
import org.eclipse.e4.core.di.annotations.Execute; |
15 |
import org.eclipse.e4.core.di.annotations.Optional; |
|
15 | 16 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
16 | 17 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
17 | 18 |
import org.eclipse.e4.ui.services.IServiceConstants; |
... | ... | |
43 | 44 |
|
44 | 45 |
@CanExecute |
45 | 46 |
public boolean canExecute( |
46 |
@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection, |
|
47 |
@Optional@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
|
|
47 | 48 |
@Named(IServiceConstants.ACTIVE_PART)MPart thisPart, |
48 | 49 |
MHandledMenuItem menuItem) { |
49 |
boolean canExecute = !selection.isEmpty(); |
|
50 |
for(Object object:selection.toArray()){ |
|
51 |
canExecute &= object instanceof FeatureNode; |
|
50 |
boolean canExecute = false; |
|
51 |
if(selection!=null && !selection.isEmpty()){ |
|
52 |
for(Object object:selection.toArray()){ |
|
53 |
canExecute &= object instanceof FeatureNode; |
|
54 |
} |
|
52 | 55 |
} |
53 | 56 |
canExecute &= thisPart.getObject() instanceof IE4ViewerPart; |
54 | 57 |
menuItem.setVisible(canExecute); |
Also available in: Unified diff
ref #6746 Hide menu items when nothing is selected