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
.util
.LocalSelectionTransfer
;
13 import org
.eclipse
.jface
.viewers
.ISelection
;
14 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
16 import eu
.etaxonomy
.cdm
.persistence
.dto
.TermNodeDto
;
17 import eu
.etaxonomy
.taxeditor
.featuretree
.e4
.TermTreeEditor
;
19 public class PasteFeatureHandler
{
22 public void execute(@Named(IServiceConstants
.ACTIVE_PART
) MPart part
,
23 @Named(IServiceConstants
.ACTIVE_SELECTION
) IStructuredSelection selection
){
24 TermTreeEditor editor
= (TermTreeEditor
)part
.getObject();
25 editor
.paste(selection
);
29 public boolean canExecute(@Optional @Named(IServiceConstants
.ACTIVE_SELECTION
) IStructuredSelection selection
,
30 @Named(IServiceConstants
.ACTIVE_PART
) MPart part
,
31 MHandledMenuItem menuItem
){
32 boolean canExecute
= false;
33 ISelection transferSelection
= LocalSelectionTransfer
.getTransfer().getSelection();
34 canExecute
= part
.getObject() instanceof TermTreeEditor
36 && selection
.size()==1
37 && transferSelection
instanceof IStructuredSelection
38 && ((IStructuredSelection
)transferSelection
).size()==1
39 && ((IStructuredSelection
)transferSelection
).getFirstElement() instanceof TermNodeDto
;
40 menuItem
.setVisible(canExecute
);