Revision 94d3e32a
Added by Patrick Plitzner over 8 years ago
eu.etaxonomy.taxeditor.editor/plugin.xml | ||
---|---|---|
1616 | 1616 |
</test> |
1617 | 1617 |
</with> |
1618 | 1618 |
</definition> |
1619 |
<definition |
|
1620 |
id="isSequence"> |
|
1621 |
<with |
|
1622 |
variable="selection"> |
|
1623 |
<test |
|
1624 |
property="eu.etaxonomy.taxeditor.editor.handler.SpecimenPropertyTester.isSequence"> |
|
1625 |
</test> |
|
1626 |
</with> |
|
1627 |
</definition> |
|
1628 |
<definition |
|
1629 |
id="isSingleRead"> |
|
1630 |
<with |
|
1631 |
variable="selection"> |
|
1632 |
<test |
|
1633 |
property="eu.etaxonomy.taxeditor.editor.handler.SpecimenPropertyTester.isSingleRead"> |
|
1634 |
</test> |
|
1635 |
</with> |
|
1636 |
</definition> |
|
1619 | 1637 |
</extension> |
1620 | 1638 |
<extension |
1621 | 1639 |
point="org.eclipse.core.expressions.propertyTesters"> |
... | ... | |
1640 | 1658 |
properties="isGroupEditor" |
1641 | 1659 |
type="eu.etaxonomy.taxeditor.bulkeditor.BulkEditor"> |
1642 | 1660 |
</propertyTester> |
1661 |
<propertyTester |
|
1662 |
class="eu.etaxonomy.taxeditor.editor.handler.SpecimenPropertyTester" |
|
1663 |
id="eu.etaxonomy.taxeditor.editor.handler.SpecimenPropertyTester" |
|
1664 |
namespace="eu.etaxonomy.taxeditor.editor.handler.SpecimenPropertyTester" |
|
1665 |
properties="isSequence,isSingleRead" |
|
1666 |
type="org.eclipse.jface.viewers.IStructuredSelection"> |
|
1667 |
</propertyTester> |
|
1643 | 1668 |
</extension> |
1644 | 1669 |
<extension |
1645 | 1670 |
point="org.eclipse.ui.bindings"> |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/SpecimenPropertyTester.java | ||
---|---|---|
1 |
package eu.etaxonomy.taxeditor.editor.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 |
/** {@inheritDoc} */ |
|
28 |
@Override |
|
29 |
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { |
|
30 |
if (receiver instanceof IStructuredSelection) { |
|
31 |
IStructuredSelection selection = (IStructuredSelection) receiver; |
|
32 |
TreeNode treeNodeOfSelection = EditorUtil.getTreeNodeOfSelection(selection); |
|
33 |
if (treeNodeOfSelection!=null) { |
|
34 |
if (SEQUENCE.equals(property)) { |
|
35 |
return isSequence(treeNodeOfSelection.getValue()); |
|
36 |
} |
|
37 |
else if (SINGLE_READ.equals(property)) { |
|
38 |
return isSingleReadAlignment(treeNodeOfSelection.getValue()); |
|
39 |
} |
|
40 |
} |
|
41 |
} |
|
42 |
return false; |
|
43 |
} |
|
44 |
|
|
45 |
private boolean isSequence(Object object) { |
|
46 |
return (object instanceof Sequence); |
|
47 |
} |
|
48 |
|
|
49 |
private boolean isSingleReadAlignment(Object object) { |
|
50 |
return (object instanceof SingleRead); |
|
51 |
} |
|
52 |
} |
eu.etaxonomy.taxeditor.molecular/plugin.xml | ||
---|---|---|
261 | 261 |
commandId="eu.etaxonomy.taxeditor.molecular.pherogramComponent.changeQualityOutput"> |
262 | 262 |
</handler> |
263 | 263 |
</extension> |
264 |
<extension |
|
265 |
point="org.eclipse.core.expressions.definitions"> |
|
266 |
<definition |
|
267 |
id="isSequence"> |
|
268 |
<with |
|
269 |
variable="selection"> |
|
270 |
<test |
|
271 |
property="eu.etaxonomy.taxeditor.molecular.SpecimenPropertyTester.isSequence"> |
|
272 |
</test> |
|
273 |
</with> |
|
274 |
</definition> |
|
275 |
<definition |
|
276 |
id="isSingleRead"> |
|
277 |
<with |
|
278 |
variable="selection"> |
|
279 |
<test |
|
280 |
property="eu.etaxonomy.taxeditor.molecular.SpecimenPropertyTester.isSingleRead"> |
|
281 |
</test> |
|
282 |
</with> |
|
283 |
</definition> |
|
284 |
</extension> |
|
285 |
<extension |
|
286 |
point="org.eclipse.core.expressions.propertyTesters"> |
|
287 |
<propertyTester |
|
288 |
class="eu.etaxonomy.taxeditor.molecular.handler.SpecimenPropertyTester" |
|
289 |
id="eu.etaxonomy.taxeditor.molecular.SpecimenPropertyTester" |
|
290 |
namespace="eu.etaxonomy.taxeditor.molecular.SpecimenPropertyTester" |
|
291 |
properties="isSequence,isSingleRead" |
|
292 |
type="org.eclipse.jface.viewers.IStructuredSelection"> |
|
293 |
</propertyTester> |
|
294 |
</extension> |
|
295 | 264 |
<extension |
296 | 265 |
point="org.eclipse.ui.bindings"> |
297 | 266 |
<scheme |
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/handler/SpecimenPropertyTester.java | ||
---|---|---|
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 |
} |
Also available in: Unified diff
Move property tester to editor plugin