1 package eu
.etaxonomy
.taxeditor
.editor
.handler
;
4 import org
.eclipse
.core
.expressions
.PropertyTester
;
5 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
6 import org
.eclipse
.jface
.viewers
.TreeNode
;
8 import eu
.etaxonomy
.cdm
.model
.molecular
.Sequence
;
9 import eu
.etaxonomy
.cdm
.model
.molecular
.SingleRead
;
10 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
15 * Tests types of specimens to add items to the context menu.
20 public class SpecimenPropertyTester
extends PropertyTester
{
21 private static final String SEQUENCE
= "isSequence";
22 private static final String SINGLE_READ
= "isSingleRead";
25 public SpecimenPropertyTester() {}
29 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
33 public boolean test(Object receiver
, String property
, Object
[] args
,
34 Object expectedValue
) {
36 if (receiver
instanceof IStructuredSelection
) {
37 IStructuredSelection selection
= (IStructuredSelection
) receiver
;
38 TreeNode treeNodeOfSelection
= EditorUtil
.getTreeNodeOfSelection(selection
);
39 if (treeNodeOfSelection
!=null) {
40 if (SEQUENCE
.equals(property
)) {
41 return isSequence(treeNodeOfSelection
.getValue());
43 else if (SINGLE_READ
.equals(property
)) {
44 return isSingleReadAlignment(treeNodeOfSelection
.getValue());
53 private boolean isSequence(Object object
) {
54 return (object
instanceof Sequence
);
58 private boolean isSingleReadAlignment(Object object
) {
59 return (object
instanceof SingleRead
);