Revision 32746e43
Added by Patrick Plitzner about 8 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/SpecimenPropertyTester.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
|
4 | 4 |
import org.eclipse.core.expressions.PropertyTester; |
5 |
import org.eclipse.jface.util.LocalSelectionTransfer; |
|
5 | 6 |
import org.eclipse.jface.viewers.IStructuredSelection; |
6 | 7 |
import org.eclipse.jface.viewers.TreeNode; |
8 |
import org.eclipse.ui.IEditorPart; |
|
9 |
import org.eclipse.ui.IWorkbenchWindow; |
|
10 |
import org.eclipse.ui.PlatformUI; |
|
7 | 11 |
|
8 | 12 |
import eu.etaxonomy.cdm.model.molecular.Sequence; |
9 | 13 |
import eu.etaxonomy.cdm.model.molecular.SingleRead; |
10 | 14 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
15 |
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView; |
|
11 | 16 |
|
12 | 17 |
|
13 | 18 |
|
... | ... | |
20 | 25 |
public class SpecimenPropertyTester extends PropertyTester { |
21 | 26 |
private static final String SEQUENCE = "isSequence"; |
22 | 27 |
private static final String SINGLE_READ = "isSingleRead"; |
28 |
private static final String IS_SINGLEREAD_REUSABLE_HERE = "isSingleReadReusableHere"; |
|
29 |
private static final String IS_SINGLEREAD_REUSED = "isSingleReadReused"; |
|
23 | 30 |
|
24 | 31 |
|
25 | 32 |
public SpecimenPropertyTester() {} |
... | ... | |
37 | 44 |
else if (SINGLE_READ.equals(property)) { |
38 | 45 |
return isSingleReadAlignment(treeNodeOfSelection.getValue()); |
39 | 46 |
} |
47 |
else if (IS_SINGLEREAD_REUSABLE_HERE.equals(property)) { |
|
48 |
return isSingleReadReusableHere(treeNodeOfSelection.getValue()); |
|
49 |
} |
|
50 |
else if (IS_SINGLEREAD_REUSED.equals(property)) { |
|
51 |
return isSingleReadReused(treeNodeOfSelection.getValue()); |
|
52 |
} |
|
40 | 53 |
} |
41 | 54 |
} |
42 | 55 |
return false; |
43 | 56 |
} |
44 | 57 |
|
45 |
private boolean isSequence(Object object) { |
|
58 |
private boolean isSingleReadReused(Object value) { |
|
59 |
final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); |
|
60 |
final IEditorPart activeEditor = window.getActivePage().getActiveEditor(); |
|
61 |
if(value instanceof SingleRead){ |
|
62 |
if(activeEditor instanceof DerivateView |
|
63 |
&& ((DerivateView) activeEditor).getMultiLinkSingleReads().contains(value)){ |
|
64 |
return true; |
|
65 |
} |
|
66 |
} |
|
67 |
return false; |
|
68 |
} |
|
69 |
|
|
70 |
private boolean isSingleReadReusableHere(Object value) { |
|
71 |
TreeNode clipboardNode = EditorUtil.getTreeNodeOfSelection(LocalSelectionTransfer.getTransfer().getSelection()); |
|
72 |
if(value instanceof Sequence && clipboardNode!=null && clipboardNode.getValue() instanceof SingleRead |
|
73 |
&& !((Sequence) value).getSingleReads().contains(clipboardNode.getValue())){ |
|
74 |
return true; |
|
75 |
} |
|
76 |
return false; |
|
77 |
} |
|
78 |
|
|
79 |
private boolean isSequence(Object object) { |
|
46 | 80 |
return (object instanceof Sequence); |
47 | 81 |
} |
48 | 82 |
|
Also available in: Unified diff
Refactor SingleReadContextMenu #5406