Project

General

Profile

« Previous | Next » 

Revision f57d8d08

Added by Patrick Plitzner about 6 years ago

ref #6746 Hide menu items when nothing is selected

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/handler/AddChildFeatureHandler.java
15 15
import org.eclipse.core.runtime.IStatus;
16 16
import org.eclipse.e4.core.di.annotations.CanExecute;
17 17
import org.eclipse.e4.core.di.annotations.Execute;
18
import org.eclipse.e4.core.di.annotations.Optional;
18 19
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
19 20
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
20 21
import org.eclipse.e4.ui.services.IServiceConstants;
......
57 58

  
58 59
    @CanExecute
59 60
    public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart thisPart,
60
            @Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
61
            @Optional@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
61 62
            MHandledMenuItem menuItem) {
62 63
        boolean canExecute = false;
63 64
        canExecute = thisPart.getObject() instanceof FeatureTreeEditor
65
                && selection!=null
64 66
                && selection.size()==1
65 67
                && selection.iterator().next() instanceof FeatureNode;
66 68
        menuItem.setVisible(canExecute);

Also available in: Unified diff