Revision 7dc115d1
Added by Katja Luther over 4 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/StatusDataDisplayConverter.java | ||
---|---|---|
14 | 14 |
import org.apache.commons.lang.StringUtils; |
15 | 15 |
import org.eclipse.nebula.widgets.nattable.data.convert.DisplayConverter; |
16 | 16 |
|
17 |
import eu.etaxonomy.cdm.model.term.Representation; |
|
18 | 17 |
import eu.etaxonomy.cdm.model.description.Distribution; |
19 |
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm; |
|
20 | 18 |
import eu.etaxonomy.cdm.model.metadata.TermDisplayEnum; |
19 |
import eu.etaxonomy.cdm.model.term.Representation; |
|
21 | 20 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
22 | 21 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
23 | 22 |
|
... | ... | |
36 | 35 |
if(canonicalValue instanceof Distribution){ |
37 | 36 |
|
38 | 37 |
Distribution distribution = (Distribution) canonicalValue; |
39 |
PresenceAbsenceTerm term = distribution.getStatus(); |
|
40 |
Representation rep = distribution.getStatus().getPreferredRepresentation(CdmStore.getDefaultLanguage()); |
|
41 |
String label = rep.getLabel(); |
|
42 |
|
|
43 |
if (label == null){ |
|
44 |
label = distribution.getStatus().getTitleCache(); |
|
45 |
} |
|
46 |
if (PreferencesUtil.displayStatusInChecklistEditor() != null){ |
|
47 |
if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.IdInVocabulary.getKey())){ |
|
48 |
return (StringUtils.isNotBlank(distribution.getStatus().getIdInVocabulary()))?distribution.getStatus().getIdInVocabulary():label; |
|
49 |
}else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol1.getKey())){ |
|
50 |
|
|
51 |
return (StringUtils.isNotBlank(distribution.getStatus().getSymbol() ))?distribution.getStatus().getSymbol():label; |
|
52 |
}else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol2.getKey())){ |
|
53 |
return (StringUtils.isNotBlank(distribution.getStatus().getSymbol2() ))?distribution.getStatus().getSymbol2():label; |
|
54 |
}else{ |
|
55 |
return (label != null)?label:DEFAULT_ENTRY; |
|
56 |
} |
|
57 | 38 |
|
58 |
}else{ |
|
59 |
return (label != null)?label:DEFAULT_ENTRY; |
|
60 |
} |
|
39 |
return extractStatusString(distribution); |
|
61 | 40 |
} |
62 | 41 |
else if(canonicalValue instanceof HashSet<?>){ |
63 | 42 |
HashSet<?> distributionSet = (HashSet<?>) canonicalValue; |
64 | 43 |
Iterator<?> distributions = distributionSet.iterator(); |
65 | 44 |
String result = ""; |
66 | 45 |
while(distributions.hasNext()){ |
67 |
result.concat(((Distribution)distributions.next()).getStatus().getLabel()+", ");
|
|
46 |
result.concat(extractStatusString((Distribution)distributions.next())+", ");
|
|
68 | 47 |
} |
69 | 48 |
result = result.substring(1, result.length() - 1); |
70 | 49 |
return result; |
... | ... | |
73 | 52 |
return null; |
74 | 53 |
} |
75 | 54 |
|
55 |
public Object extractStatusString(Distribution distribution) { |
|
56 |
if (distribution.getStatus() == null){ |
|
57 |
return DEFAULT_ENTRY; |
|
58 |
} |
|
59 |
|
|
60 |
Representation rep = distribution.getStatus().getPreferredRepresentation(CdmStore.getDefaultLanguage()); |
|
61 |
String label = rep.getLabel(); |
|
62 |
|
|
63 |
if (label == null){ |
|
64 |
label = distribution.getStatus().getTitleCache(); |
|
65 |
} |
|
66 |
if (PreferencesUtil.displayStatusInChecklistEditor() != null){ |
|
67 |
if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.IdInVocabulary)){ |
|
68 |
return (StringUtils.isNotBlank(distribution.getStatus().getIdInVocabulary()))?distribution.getStatus().getIdInVocabulary():label; |
|
69 |
}else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol1)){ |
|
70 |
|
|
71 |
return (StringUtils.isNotBlank(distribution.getStatus().getSymbol() ))?distribution.getStatus().getSymbol():label; |
|
72 |
}else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol2)){ |
|
73 |
return (StringUtils.isNotBlank(distribution.getStatus().getSymbol2() ))?distribution.getStatus().getSymbol2():label; |
|
74 |
}else{ |
|
75 |
return (label != null)?label:DEFAULT_ENTRY; |
|
76 |
} |
|
77 |
|
|
78 |
}else{ |
|
79 |
return (label != null)?label:DEFAULT_ENTRY; |
|
80 |
} |
|
81 |
} |
|
82 |
|
|
76 | 83 |
/** |
77 | 84 |
* {@inheritDoc} |
78 | 85 |
*/ |
Also available in: Unified diff
adapt display of multiple status in distr editor to preference value