Revision f4fd193c
Added by Niels Hoffmann about 13 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyLabelProvider.java | ||
---|---|---|
11 | 11 |
package eu.etaxonomy.taxeditor.editor.key.polytomous; |
12 | 12 |
|
13 | 13 |
import org.apache.commons.lang.StringUtils; |
14 |
import org.eclipse.draw2d.IFigure; |
|
14 | 15 |
import org.eclipse.jface.viewers.LabelProvider; |
16 |
import org.eclipse.swt.graphics.Color; |
|
17 |
import org.eclipse.zest.core.viewers.IEntityStyleProvider; |
|
15 | 18 |
|
16 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
17 | 19 |
import eu.etaxonomy.cdm.model.common.Language; |
18 | 20 |
import eu.etaxonomy.cdm.model.description.KeyStatement; |
19 | 21 |
import eu.etaxonomy.cdm.model.description.PolytomousKey; |
20 | 22 |
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode; |
23 |
import eu.etaxonomy.taxeditor.model.PolytomousKeyRelationship; |
|
21 | 24 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
22 | 25 |
|
23 | 26 |
/** |
... | ... | |
26 | 29 |
* @created Mar 30, 2011 |
27 | 30 |
* @version 1.0 |
28 | 31 |
*/ |
29 |
class PolytomousKeyLabelProvider extends LabelProvider { |
|
32 |
class PolytomousKeyLabelProvider extends LabelProvider implements |
|
33 |
IEntityStyleProvider { |
|
30 | 34 |
|
31 | 35 |
public static final String LEAF_BUT_NO_TAXON = "leaf but no taxon"; |
32 | 36 |
public static final String NO_NODE_NUMBER = "No node number set"; |
... | ... | |
50 | 54 |
String statementLabel = ""; |
51 | 55 |
String nodeNumber = keyNode.getNodeNumber().toString(); |
52 | 56 |
|
53 |
KeyStatement statement = keyNode.getStatement();
|
|
57 |
KeyStatement question = keyNode.getQuestion();
|
|
54 | 58 |
|
55 |
if (statement != null) {
|
|
59 |
if (question != null) {
|
|
56 | 60 |
statementLabel += " " |
57 |
+ statement.getLabelText(CdmStore
|
|
61 |
+ question.getLabelText(CdmStore
|
|
58 | 62 |
.getDefaultLanguage()); |
59 | 63 |
} |
60 | 64 |
|
... | ... | |
64 | 68 |
} |
65 | 69 |
} else if (element instanceof PolytomousKeyRelationship) { |
66 | 70 |
PolytomousKeyRelationship relationship = (PolytomousKeyRelationship) element; |
67 |
if (relationship.source instanceof PolytomousKeyNode) { |
|
68 |
PolytomousKeyNode sourceNode = (PolytomousKeyNode) relationship.source; |
|
71 |
if (relationship.getSource() instanceof PolytomousKeyNode) { |
|
72 |
PolytomousKeyNode destinationNode = (PolytomousKeyNode) relationship |
|
73 |
.getDestination(); |
|
69 | 74 |
|
70 |
KeyStatement question = (KeyStatement) HibernateProxyHelper |
|
71 |
.deproxy(sourceNode.getQuestion()); |
|
75 |
KeyStatement statement = destinationNode.getStatement(); |
|
72 | 76 |
|
73 |
if (question != null) {
|
|
77 |
if (statement != null) {
|
|
74 | 78 |
Language language = CdmStore.getDefaultLanguage(); |
75 |
String questionLabel = sourceNode.getQuestion() |
|
76 |
.getLabelText(language); |
|
79 |
String statementLabel = statement.getLabelText(language); |
|
77 | 80 |
|
78 |
return StringUtils.isEmpty(questionLabel) ? EMPTY
|
|
79 |
: questionLabel;
|
|
81 |
return StringUtils.isEmpty(statementLabel) ? EMPTY
|
|
82 |
: statementLabel;
|
|
80 | 83 |
} |
81 | 84 |
} |
82 | 85 |
} |
83 | 86 |
return EMPTY; |
84 | 87 |
} |
88 |
|
|
89 |
/* |
|
90 |
* (non-Javadoc) |
|
91 |
* |
|
92 |
* @see |
|
93 |
* org.eclipse.zest.core.viewers.IEntityStyleProvider#fisheyeNode(java.lang |
|
94 |
* .Object) |
|
95 |
*/ |
|
96 |
@Override |
|
97 |
public boolean fisheyeNode(Object arg0) { |
|
98 |
// TODO Auto-generated method stub |
|
99 |
return false; |
|
100 |
} |
|
101 |
|
|
102 |
/* |
|
103 |
* (non-Javadoc) |
|
104 |
* |
|
105 |
* @see |
|
106 |
* org.eclipse.zest.core.viewers.IEntityStyleProvider#getBackgroundColour |
|
107 |
* (java.lang.Object) |
|
108 |
*/ |
|
109 |
@Override |
|
110 |
public Color getBackgroundColour(Object arg0) { |
|
111 |
// TODO Auto-generated method stub |
|
112 |
return null; |
|
113 |
} |
|
114 |
|
|
115 |
/* |
|
116 |
* (non-Javadoc) |
|
117 |
* |
|
118 |
* @see |
|
119 |
* org.eclipse.zest.core.viewers.IEntityStyleProvider#getBorderColor(java |
|
120 |
* .lang.Object) |
|
121 |
*/ |
|
122 |
@Override |
|
123 |
public Color getBorderColor(Object arg0) { |
|
124 |
// TODO Auto-generated method stub |
|
125 |
return null; |
|
126 |
} |
|
127 |
|
|
128 |
/* |
|
129 |
* (non-Javadoc) |
|
130 |
* |
|
131 |
* @see |
|
132 |
* org.eclipse.zest.core.viewers.IEntityStyleProvider#getBorderHighlightColor |
|
133 |
* (java.lang.Object) |
|
134 |
*/ |
|
135 |
@Override |
|
136 |
public Color getBorderHighlightColor(Object arg0) { |
|
137 |
// TODO Auto-generated method stub |
|
138 |
return null; |
|
139 |
} |
|
140 |
|
|
141 |
/* |
|
142 |
* (non-Javadoc) |
|
143 |
* |
|
144 |
* @see |
|
145 |
* org.eclipse.zest.core.viewers.IEntityStyleProvider#getBorderWidth(java |
|
146 |
* .lang.Object) |
|
147 |
*/ |
|
148 |
@Override |
|
149 |
public int getBorderWidth(Object arg0) { |
|
150 |
return 0; |
|
151 |
} |
|
152 |
|
|
153 |
/* |
|
154 |
* (non-Javadoc) |
|
155 |
* |
|
156 |
* @see |
|
157 |
* org.eclipse.zest.core.viewers.IEntityStyleProvider#getForegroundColour |
|
158 |
* (java.lang.Object) |
|
159 |
*/ |
|
160 |
@Override |
|
161 |
public Color getForegroundColour(Object arg0) { |
|
162 |
// TODO Auto-generated method stub |
|
163 |
return null; |
|
164 |
} |
|
165 |
|
|
166 |
/* |
|
167 |
* (non-Javadoc) |
|
168 |
* |
|
169 |
* @see |
|
170 |
* org.eclipse.zest.core.viewers.IEntityStyleProvider#getNodeHighlightColor |
|
171 |
* (java.lang.Object) |
|
172 |
*/ |
|
173 |
@Override |
|
174 |
public Color getNodeHighlightColor(Object arg0) { |
|
175 |
// TODO Auto-generated method stub |
|
176 |
return null; |
|
177 |
} |
|
178 |
|
|
179 |
/* |
|
180 |
* (non-Javadoc) |
|
181 |
* |
|
182 |
* @see |
|
183 |
* org.eclipse.zest.core.viewers.IEntityStyleProvider#getTooltip(java.lang |
|
184 |
* .Object) |
|
185 |
*/ |
|
186 |
@Override |
|
187 |
public IFigure getTooltip(Object arg0) { |
|
188 |
return null; |
|
189 |
} |
|
85 | 190 |
} |
Also available in: Unified diff
Improving polytomous key handling