Project

General

Profile

« Previous | Next » 

Revision 72eff2a6

Added by Patrick Plitzner about 6 years ago

ref #6746 Add/adapt handlers for feature tree editor

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/handler/AddChildFeatureHandler.java
16 16
import org.eclipse.e4.core.di.annotations.CanExecute;
17 17
import org.eclipse.e4.core.di.annotations.Execute;
18 18
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
19
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
19 20
import org.eclipse.e4.ui.services.IServiceConstants;
21
import org.eclipse.jface.viewers.IStructuredSelection;
20 22
import org.eclipse.jface.wizard.WizardDialog;
21 23
import org.eclipse.swt.widgets.Shell;
22 24

  
......
37 39
    @Execute
38 40
    public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell,
39 41
            @Named(IServiceConstants.ACTIVE_PART)MPart thisPart,
40
            @Named(IServiceConstants.ACTIVE_SELECTION)Object selection) {
42
            @Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection) {
41 43
        FeatureTreeEditor editor = ((FeatureTreeEditor) thisPart.getObject());
42 44
        AvailableFeaturesWizard wizard = new AvailableFeaturesWizard();
43 45
        WizardDialog dialog = new WizardDialog(shell, wizard);
......
55 57

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

Also available in: Unified diff