2 package eu
.etaxonomy
.taxeditor
.featuretree
.e4
.handler
;
4 import javax
.inject
.Named
;
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
;
14 import eu
.etaxonomy
.cdm
.persistence
.dto
.TermNodeDto
;
15 import eu
.etaxonomy
.taxeditor
.featuretree
.e4
.TermTreeEditor
;
17 public class CopyTermHandler
{
20 public void execute(@Named(IServiceConstants
.ACTIVE_PART
) MPart part
,
21 @Named(IServiceConstants
.ACTIVE_SELECTION
) IStructuredSelection selection
){
22 ((TermTreeEditor
) part
.getObject()).copy(selection
);
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 TermTreeEditor
32 && selection
.size()==1
33 && selection
.getFirstElement() instanceof TermNodeDto
;
34 menuItem
.setVisible(canExecute
);