Project

General

Profile

Download (1.4 KB) Statistics
| Branch: | Tag: | Revision:
1

    
2
package eu.etaxonomy.taxeditor.featuretree.e4.handler;
3

    
4
import javax.inject.Named;
5

    
6
import org.eclipse.e4.core.di.annotations.CanExecute;
7
import org.eclipse.e4.core.di.annotations.Execute;
8
import org.eclipse.e4.core.di.annotations.Optional;
9
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
10
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
11
import org.eclipse.e4.ui.services.IServiceConstants;
12
import org.eclipse.jface.viewers.IStructuredSelection;
13

    
14
import eu.etaxonomy.cdm.model.description.FeatureNode;
15
import eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditor;
16

    
17
public class CopyFeatureHandler {
18

    
19
    @Execute
20
    public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart part,
21
            @Named(IServiceConstants.ACTIVE_SELECTION) IStructuredSelection selection){
22
        ((FeatureTreeEditor) part.getObject()).copy(selection);
23
    }
24

    
25
    @CanExecute
26
    public boolean canExecute(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) IStructuredSelection selection,
27
            @Named(IServiceConstants.ACTIVE_PART) MPart part,
28
            MHandledMenuItem menuItem){
29
        boolean canExecute = false;
30
        canExecute =part.getObject() instanceof FeatureTreeEditor
31
                && selection!=null
32
                && selection.size()==1
33
                && selection.getFirstElement() instanceof FeatureNode;
34
        menuItem.setVisible(canExecute);
35
        return canExecute;
36
    }
37

    
38
}
(3-3/9)