1 package eu
.etaxonomy
.taxeditor
.editor
.view
.uses
;
3 import java
.util
.Arrays
;
7 import javax
.swing
.text
.html
.HTMLDocument
.HTMLReader
.IsindexAction
;
9 import org
.eclipse
.jface
.viewers
.ColumnLabelProvider
;
10 import org
.eclipse
.jface
.viewers
.DelegatingStyledCellLabelProvider
.IStyledLabelProvider
;
11 import org
.eclipse
.jface
.viewers
.StyledString
;
13 import eu
.etaxonomy
.cdm
.api
.service
.DefaultCategoricalDescriptionBuilder
;
14 import eu
.etaxonomy
.cdm
.api
.service
.DescriptionBuilder
;
15 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
16 import eu
.etaxonomy
.cdm
.model
.common
.LanguageString
;
17 import eu
.etaxonomy
.cdm
.model
.description
.CategoricalData
;
18 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
19 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
20 import eu
.etaxonomy
.cdm
.model
.description
.State
;
21 import eu
.etaxonomy
.cdm
.model
.description
.StateData
;
22 import eu
.etaxonomy
.cdm
.model
.description
.TextData
;
23 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
25 public class UsesLabelProvider
extends ColumnLabelProvider
implements
26 IStyledLabelProvider
{
28 private static DescriptionBuilder
<CategoricalData
> categoricalDescriptionBuilder
= new DefaultCategoricalDescriptionBuilder();
29 public String
getText(Object element
) {
32 * return DescriptionHelper.getLabel(element);
34 * for (Marker marker : element.getMarkers()) { if
35 * (marker.getMarkerType().getTitleCache().equals("use")) { return
38 if (element
instanceof DescriptionBase
) {
39 text
= ((DescriptionBase
) element
).getTitleCache();
40 if (text
== null || text
.length() == 0) {
41 text
= "Use: No label provided";
44 text
= "Use: " + text
;
47 else if (element
instanceof CategoricalData
) {
49 //TextData textData = categoricalDescriptionBuilder.build((CategoricalData) element, getLanguageList());
50 if (((CategoricalData
) element
).getStates() != null) {
51 for (StateData statedata
: ((CategoricalData
) element
).getStates()) {
52 if(statedata
.getState() != null) {
53 text
= text
+ statedata
.getState().getTitleCache();
56 text
= "No data provided";
60 if (((CategoricalData
) element
).getStatesOnly() != null) {
61 for (State state
: ((CategoricalData
) element
).getStatesOnly()) {
63 text
= text
+ state
.getTitleCache();
66 text
= "No data provided";
71 //text = textData.getText(CdmStore.getDefaultLanguage());
72 if (text
== null || text
.length() == 0) {
73 text
= "No data provided";
77 /*else if (element instanceof DescriptionElementBase) {
78 Map useRecordText = ((DescriptionElementBase) element).getModifyingText();
81 if (text == null || text.length() == 0) {
82 text = "Use Record: No label provided";
84 text = useRecordText.toString();
85 //text = "Something else";
95 public StyledString
getStyledText(Object element
) {
96 return new StyledString(this.getText(element
),
97 StyledString
.QUALIFIER_STYLER
);
100 private static List
<Language
> getLanguageList(){
101 return Arrays
.asList(new Language
[]{CdmStore
.getDefaultLanguage()});