Revision aa42dfd9
Added by Patrick Plitzner almost 6 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/SingleReadCopyToClipboardHandler.java | ||
---|---|---|
9 | 9 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
10 | 10 |
import org.eclipse.e4.ui.services.IServiceConstants; |
11 | 11 |
import org.eclipse.jface.util.LocalSelectionTransfer; |
12 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
12 |
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
13 | 13 |
import org.eclipse.jface.viewers.TreeNode; |
14 | 14 |
|
15 | 15 |
import eu.etaxonomy.cdm.model.molecular.SingleRead; |
... | ... | |
18 | 18 |
public class SingleReadCopyToClipboardHandler { |
19 | 19 |
|
20 | 20 |
@Execute |
21 |
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart part, @Named(IServiceConstants.ACTIVE_SELECTION) TreeNode selectedTreeNode){
|
|
21 |
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart part, @Named(IServiceConstants.ACTIVE_SELECTION) IStructuredSelection selection){
|
|
22 | 22 |
DerivateView derivateView = (DerivateView)part.getObject(); |
23 |
LocalSelectionTransfer.getTransfer().setSelection(new StructuredSelection(selectedTreeNode));
|
|
23 |
LocalSelectionTransfer.getTransfer().setSelection(selection);
|
|
24 | 24 |
derivateView.updateLabelCache(); |
25 | 25 |
derivateView.refreshTree(); |
26 | 26 |
} |
27 | 27 |
|
28 | 28 |
@CanExecute |
29 |
public boolean canExecute(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) TreeNode selectedTreeNode, MHandledMenuItem menuItem) { |
|
29 |
public boolean canExecute(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) IStructuredSelection selection, |
|
30 |
MHandledMenuItem menuItem){ |
|
30 | 31 |
boolean canExecute = false; |
31 |
if(selectedTreeNode!=null){
|
|
32 |
Object object = selectedTreeNode.getValue();
|
|
33 |
canExecute = (object instanceof SingleRead);
|
|
34 |
}
|
|
32 |
canExecute = selection!=null
|
|
33 |
&& selection.size()==1
|
|
34 |
&& selection.getFirstElement() instanceof TreeNode
|
|
35 |
&& ((TreeNode) selection.getFirstElement()).getValue() instanceof SingleRead;
|
|
35 | 36 |
menuItem.setVisible(canExecute); |
36 | 37 |
return canExecute; |
37 | 38 |
} |
Also available in: Unified diff
ref #7010 Adapt derivate view handlers for multiple selection