1 package eu
.etaxonomy
.taxeditor
.editor
.view
.derivate
.handler
;
3 import javax
.inject
.Named
;
5 import org
.eclipse
.e4
.core
.di
.annotations
.CanExecute
;
6 import org
.eclipse
.e4
.core
.di
.annotations
.Execute
;
7 import org
.eclipse
.e4
.core
.di
.annotations
.Optional
;
8 import org
.eclipse
.e4
.ui
.model
.application
.ui
.basic
.MPart
;
9 import org
.eclipse
.e4
.ui
.model
.application
.ui
.menu
.MHandledMenuItem
;
10 import org
.eclipse
.e4
.ui
.services
.IServiceConstants
;
11 import org
.eclipse
.jface
.util
.LocalSelectionTransfer
;
12 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
13 import org
.eclipse
.jface
.viewers
.TreeNode
;
15 import eu
.etaxonomy
.cdm
.model
.molecular
.SingleRead
;
16 import eu
.etaxonomy
.taxeditor
.editor
.view
.derivate
.DerivateView
;
18 public class SingleReadCopyToClipboardHandler
{
21 public void execute(@Named(IServiceConstants
.ACTIVE_PART
) MPart part
, @Named(IServiceConstants
.ACTIVE_SELECTION
) TreeNode selectedTreeNode
){
22 DerivateView derivateView
= (DerivateView
)part
.getObject();
23 LocalSelectionTransfer
.getTransfer().setSelection(new StructuredSelection(selectedTreeNode
));
24 derivateView
.updateLabelCache();
25 derivateView
.refreshTree();
29 public boolean canExecute(@Optional @Named(IServiceConstants
.ACTIVE_SELECTION
) TreeNode selectedTreeNode
, MHandledMenuItem menuItem
) {
30 boolean canExecute
= false;
31 if(selectedTreeNode
!=null){
32 Object object
= selectedTreeNode
.getValue();
33 canExecute
= (object
instanceof SingleRead
);
35 menuItem
.setVisible(canExecute
);