1
|
package eu.etaxonomy.taxeditor.molecular.handler;
|
2
|
|
3
|
|
4
|
import org.eclipse.core.expressions.PropertyTester;
|
5
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
6
|
import org.eclipse.jface.viewers.TreeNode;
|
7
|
|
8
|
import eu.etaxonomy.cdm.model.molecular.Sequence;
|
9
|
import eu.etaxonomy.cdm.model.molecular.SingleRead;
|
10
|
import eu.etaxonomy.taxeditor.editor.EditorUtil;
|
11
|
|
12
|
|
13
|
|
14
|
/**
|
15
|
* Tests types of specimens to add items to the context menu.
|
16
|
*
|
17
|
* @author pplitzner
|
18
|
* @author BenStoever
|
19
|
*/
|
20
|
public class SpecimenPropertyTester extends PropertyTester {
|
21
|
private static final String SEQUENCE = "isSequence";
|
22
|
private static final String SINGLE_READ = "isSingleRead";
|
23
|
|
24
|
|
25
|
public SpecimenPropertyTester() {}
|
26
|
|
27
|
|
28
|
/* (non-Javadoc)
|
29
|
* @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
|
30
|
*/
|
31
|
/** {@inheritDoc} */
|
32
|
@Override
|
33
|
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
|
34
|
if (receiver instanceof IStructuredSelection) {
|
35
|
IStructuredSelection selection = (IStructuredSelection) receiver;
|
36
|
TreeNode treeNodeOfSelection = EditorUtil.getTreeNodeOfSelection(selection);
|
37
|
if (treeNodeOfSelection!=null) {
|
38
|
if (SEQUENCE.equals(property)) {
|
39
|
return isSequence(treeNodeOfSelection.getValue());
|
40
|
}
|
41
|
else if (SINGLE_READ.equals(property)) {
|
42
|
return isSingleReadAlignment(treeNodeOfSelection.getValue());
|
43
|
}
|
44
|
}
|
45
|
}
|
46
|
return false;
|
47
|
}
|
48
|
|
49
|
|
50
|
private boolean isSequence(Object object) {
|
51
|
return (object instanceof Sequence);
|
52
|
}
|
53
|
|
54
|
|
55
|
private boolean isSingleReadAlignment(Object object) {
|
56
|
return (object instanceof SingleRead);
|
57
|
}
|
58
|
}
|