import eu.etaxonomy.cdm.common.CdmUtils;
import eu.etaxonomy.cdm.model.common.Language;
import eu.etaxonomy.cdm.model.common.LanguageString;
+import eu.etaxonomy.cdm.model.description.Feature;
import eu.etaxonomy.cdm.model.description.KeyStatement;
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
import eu.etaxonomy.taxeditor.store.CdmStore;
// TODO make this configurable via preferences
private static final String INCREMENTOR_CHARACTER = "'"; //$NON-NLS-1$
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.jface.viewers.StyledCellLabelProvider#update(org.eclipse.
- * jface.viewers.ViewerCell)
- */
@Override
public void update(ViewerCell cell) {
Object element = cell.getElement();
case 0:
return getItemNumber(node);
case 1:
- return getItemQuestion(node);
+ return getItemQuestion(node);
case 2:
return getItemEdgeNumber(node);
case 3:
return EMPTY;
}
- /**
- * @return
- */
+ private String getFeature(PolytomousKeyNode node) {
+ if (isParentRoot(node)) {
+ return ""; //$NON-NLS-1$
+ } else {
+ Feature parentFeature = getParent(node).getFeature();
+ if (parentFeature == null){
+ return EMPTY;
+ }
+ String statementLabel = CdmUtils.Nz(parentFeature.getLabel(CdmStore.getDefaultLanguage()));
+ if(CdmUtils.isBlank(statementLabel)){
+ statementLabel = parentFeature.getLabel();
+ }
+ return statementLabel;
+ }
+ }
+
private Styler getStyler() {
if (styler == null) {
styler = new Styler() {
}
private String getItemQuestion(PolytomousKeyNode node) {
- if (isParentRoot(node)) {
- return ""; //$NON-NLS-1$
- } else {
+ String questionString = EMPTY;
+ if (!isParentRoot(node)) {
KeyStatement question = getParent(node).getQuestion();
- if (question == null){
- return EMPTY;
- }
- String statementLabel = CdmUtils.Nz(question.getLabelText(CdmStore.getDefaultLanguage()));
- if (StringUtils.isBlank(statementLabel)){
- Map<Language, LanguageString> labels = question.getLabel();
- if (labels != null && !labels.isEmpty()){
- for (LanguageString langString: labels.values()){
- if (StringUtils.isNotBlank(langString.getText())){
- statementLabel = langString.getText();
- break;
- }
+ if (question != null){
+ questionString = CdmUtils.Nz(question.getLabelText(CdmStore.getDefaultLanguage()));
+ if (StringUtils.isBlank(questionString)){
+ Map<Language, LanguageString> labels = question.getLabel();
+ if (labels != null && !labels.isEmpty()){
+ for (LanguageString langString: labels.values()){
+ if (StringUtils.isNotBlank(langString.getText())){
+ questionString = langString.getText();
+ break;
+ }
+ }
}
}
}
- return statementLabel;
}
+ String featureString = getFeature(node);
+ return StringUtils.join(new String[]{questionString, featureString});
}
private String getItemStatement(PolytomousKeyNode node) {
KeyStatement statement = node.getStatement();
+ if(statement==null) {
+ return EMPTY;
+ }
String statementLabel = CdmUtils.Nz(statement.getLabelText(CdmStore
.getDefaultLanguage()));
if (StringUtils.isBlank(statementLabel)){