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