Revision 0d8040b6
Added by Cherian Mathew over 10 years ago
.gitattributes | ||
---|---|---|
380 | 380 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/handler/RefreshNodeNumberingHandler.java -text |
381 | 381 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/operation/CreateNodeOperation.java -text |
382 | 382 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/operation/DeleteNodeOperation.java -text |
383 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/operation/RefreshNodeNumberingOperation.java -text |
|
383 | 384 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/TaxonNameEditor.java -text |
384 | 385 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/container/AbstractGroup.java -text |
385 | 386 |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/container/AbstractGroupedContainer.java -text |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyListEditor.java | ||
---|---|---|
75 | 75 |
PolytomousKeyNode node = (PolytomousKeyNode) getTableItem( |
76 | 76 |
table, point).getData(); |
77 | 77 |
|
78 |
if (selectedColumn == 3) {
|
|
78 |
if (selectedColumn == 4) {
|
|
79 | 79 |
PolytomousKeyNode linkData = getItemLinkData(node); |
80 | 80 |
if (linkData != null) { |
81 | 81 |
viewer.setSelection(new StructuredSelection(linkData), true); |
82 | 82 |
} |
83 | 83 |
} |
84 |
if (selectedColumn == 4) {
|
|
84 |
if (selectedColumn == 5) {
|
|
85 | 85 |
Taxon taxon = getItemTaxon(node); |
86 | 86 |
if (taxon != null) { |
87 | 87 |
try { |
... | ... | |
277 | 277 |
// This will create the columns for the table |
278 | 278 |
private void createColumns(TableViewer viewer) { |
279 | 279 |
Table table = viewer.getTable(); |
280 |
String[] titles = { "Node Number", "Question", "Statement", "Link", "Taxon" };
|
|
281 |
int[] bounds = { 50, 200, 200, 100, 200 }; |
|
280 |
String[] titles = { "Node", "Question", "Edge", "Statement", "Link", "Taxon" };
|
|
281 |
int[] bounds = { 50, 200, 50, 200, 100, 200 };
|
|
282 | 282 |
|
283 | 283 |
for (int i = 0; i < titles.length; i++) { |
284 | 284 |
TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE); |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyListLabelProvider.java | ||
---|---|---|
21 | 21 |
import org.eclipse.swt.widgets.Display; |
22 | 22 |
|
23 | 23 |
import eu.etaxonomy.cdm.common.CdmUtils; |
24 |
import eu.etaxonomy.cdm.model.common.Language; |
|
24 | 25 |
import eu.etaxonomy.cdm.model.description.KeyStatement; |
25 | 26 |
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode; |
26 | 27 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
... | ... | |
56 | 57 |
|
57 | 58 |
String text = getTextForColumnIndex((PolytomousKeyNode) element, |
58 | 59 |
columnIndex); |
60 |
|
|
61 |
|
|
59 | 62 |
cell.setText(text); |
60 | 63 |
|
61 |
if (columnIndex == 3 || columnIndex == 4) {
|
|
64 |
if (columnIndex == 4 || columnIndex == 5) {
|
|
62 | 65 |
StyledString styledString = new StyledString(text, getStyler()); |
63 | 66 |
StyleRange[] styleRanges; |
64 | 67 |
styleRanges = styledString.getStyleRanges(); |
... | ... | |
74 | 77 |
case 0: |
75 | 78 |
return getItemNumber(node); |
76 | 79 |
case 1: |
77 |
return getItemQuestion(node); |
|
80 |
return getItemQuestion(node);
|
|
78 | 81 |
case 2: |
79 |
return getItemStatement(node);
|
|
82 |
return getItemEdgeNumber(node);
|
|
80 | 83 |
case 3: |
81 |
return getItemLink(node);
|
|
84 |
return getItemStatement(node);
|
|
82 | 85 |
case 4: |
86 |
return getItemLink(node); |
|
87 |
case 5: |
|
83 | 88 |
return getItemTaxon(node); |
84 | 89 |
} |
85 | 90 |
return EMPTY; |
... | ... | |
107 | 112 |
if (isParentRoot(node)) { |
108 | 113 |
return "root"; |
109 | 114 |
} else { |
110 |
PolytomousKeyNode parent = getParent(node); |
|
111 |
String itemNumber = parent.getNodeNumber() != null ? parent |
|
112 |
.getNodeNumber().toString() : EMPTY; |
|
113 |
|
|
114 |
int index = parent.getChildren().indexOf(node); |
|
115 |
|
|
116 |
for (int i = 0; i < index; i++) { |
|
117 |
itemNumber += INCREMENTOR_CHARACTER; |
|
118 |
} |
|
119 |
|
|
115 |
|
|
116 |
String itemNumber = node.getNodeNumber() != null ? node.getNodeNumber().toString() : EMPTY; |
|
120 | 117 |
return itemNumber; |
121 | 118 |
} |
122 | 119 |
} |
123 | 120 |
|
121 |
private String getItemEdgeNumber(PolytomousKeyNode node) { |
|
122 |
String itemEdgeNumber = node.getNodeNumber() != null ? node.getNodeNumber().toString() : EMPTY; |
|
123 |
PolytomousKeyNode parent = getParent(node); |
|
124 |
int index = parent.getChildren().indexOf(node); |
|
125 |
|
|
126 |
for (int i = 0; i < index + 1; i++) { |
|
127 |
itemEdgeNumber += INCREMENTOR_CHARACTER; |
|
128 |
} |
|
129 |
return itemEdgeNumber; |
|
130 |
} |
|
131 |
|
|
124 | 132 |
private String getItemQuestion(PolytomousKeyNode node) { |
125 | 133 |
if (isParentRoot(node)) { |
126 | 134 |
return ""; |
127 | 135 |
} else { |
128 |
KeyStatement question = getParent(node).getQuestion(); |
|
129 |
return question != null ? question.getLabelText(CdmStore
|
|
130 |
.getDefaultLanguage()) : EMPTY; |
|
136 |
KeyStatement question = getParent(node).getQuestion();
|
|
137 |
return question != null ? CdmUtils.Nz(question.getLabelText(CdmStore.getDefaultLanguage())) : EMPTY;
|
|
138 |
|
|
131 | 139 |
} |
132 | 140 |
|
133 | 141 |
} |
... | ... | |
139 | 147 |
} |
140 | 148 |
|
141 | 149 |
private String getItemLink(PolytomousKeyNode node) { |
142 |
String linkString = node.getChildren().isEmpty() ? EMPTY : node.getNodeNumber().toString(); |
|
150 |
String linkString = node.getChildren().isEmpty() ? EMPTY : node.getChildren().get(0).getNodeNumber().toString();
|
|
143 | 151 |
|
144 | 152 |
return linkString; |
145 | 153 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/operation/RefreshNodeNumberingOperation.java | ||
---|---|---|
1 |
package eu.etaxonomy.taxeditor.editor.key.polytomous.operation; |
|
2 |
|
|
3 |
import org.eclipse.core.commands.ExecutionException; |
|
4 |
import org.eclipse.core.commands.operations.IUndoContext; |
|
5 |
import org.eclipse.core.runtime.IAdaptable; |
|
6 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
7 |
import org.eclipse.core.runtime.IStatus; |
|
8 |
|
|
9 |
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode; |
|
10 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
|
11 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
|
12 |
|
|
13 |
/** |
|
14 |
* Operation responsible for refreshing node numbers of the Polytomous Key Nodes. |
|
15 |
* The refresh is performed on the entire Key starting from the root. |
|
16 |
* |
|
17 |
* @author c.mathew |
|
18 |
* |
|
19 |
*/ |
|
20 |
public class RefreshNodeNumberingOperation extends AbstractPostOperation { |
|
21 |
|
|
22 |
PolytomousKeyNode node; |
|
23 |
private PolytomousKeyNode childNode; |
|
24 |
|
|
25 |
public RefreshNodeNumberingOperation(String label, |
|
26 |
IUndoContext undoContext, |
|
27 |
PolytomousKeyNode node, |
|
28 |
IPostOperationEnabled postOperationEnabled) { |
|
29 |
super(label, undoContext, postOperationEnabled); |
|
30 |
this.node = node; |
|
31 |
} |
|
32 |
|
|
33 |
/* (non-Javadoc) |
|
34 |
* @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) |
|
35 |
*/ |
|
36 |
@Override |
|
37 |
public IStatus execute(IProgressMonitor monitor, IAdaptable info) |
|
38 |
throws ExecutionException { |
|
39 |
|
|
40 |
node.refreshNodeNumbering(); |
|
41 |
return postExecute(childNode); |
|
42 |
} |
|
43 |
|
|
44 |
/* (non-Javadoc) |
|
45 |
* @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) |
|
46 |
*/ |
|
47 |
@Override |
|
48 |
public IStatus redo(IProgressMonitor monitor, IAdaptable info) |
|
49 |
throws ExecutionException { |
|
50 |
// TODO Auto-generated method stub |
|
51 |
return null; |
|
52 |
} |
|
53 |
|
|
54 |
/* (non-Javadoc) |
|
55 |
* @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) |
|
56 |
*/ |
|
57 |
@Override |
|
58 |
public IStatus undo(IProgressMonitor monitor, IAdaptable info) |
|
59 |
throws ExecutionException { |
|
60 |
// TODO Auto-generated method stub |
|
61 |
return null; |
|
62 |
} |
|
63 |
|
|
64 |
} |
Also available in: Unified diff
PolytomousKeyListEditor.java : changed table view for polytomous key nodes added edges column to make it more clear.
PolytomousKeyListLabelProvider.java : added labels for edges and updated node number function
RefreshNodeNumberingOperation.java : calls the refreshing node function in PolytomousKeyNode