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
.Modifier
;
21 import eu
.etaxonomy
.cdm
.model
.description
.State
;
22 import eu
.etaxonomy
.cdm
.model
.description
.StateData
;
23 import eu
.etaxonomy
.cdm
.model
.description
.TextData
;
24 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
26 public class UsesLabelProvider
extends ColumnLabelProvider
implements
27 IStyledLabelProvider
{
29 private static DescriptionBuilder
<CategoricalData
> categoricalDescriptionBuilder
= new DefaultCategoricalDescriptionBuilder();
30 public String
getText(Object element
) {
33 * return DescriptionHelper.getLabel(element);
35 * for (Marker marker : element.getMarkers()) { if
36 * (marker.getMarkerType().getTitleCache().equals("use")) { return
39 if (element
instanceof DescriptionBase
) {
40 text
= ((DescriptionBase
) element
).getTitleCache();
41 if (text
== null || text
.length() == 0) {
42 text
= "Use: No label provided";
45 text
= "Use: " + text
;
48 else if (element
instanceof CategoricalData
) {
50 //TextData textData = categoricalDescriptionBuilder.build((CategoricalData) element, getLanguageList());
51 if (!((CategoricalData
) element
).getStates().isEmpty()) {
52 for (StateData statedata
: ((CategoricalData
) element
).getStates()) {
53 if(statedata
.getState() != null) {
54 text
= text
+ statedata
.getState().getTitleCache() + "; ";
57 text = "No data provided";
62 if (!((CategoricalData
) element
).getModifiers().isEmpty()) {
63 for (Modifier modifier
: ((CategoricalData
) element
).getModifiers()) {
64 text
= text
+ modifier
.getTitleCache();
69 //text = textData.getText(CdmStore.getDefaultLanguage());
70 if (text
== null || text
.length() == 0) {
71 text
= "No data provided";
75 /*else if (element instanceof DescriptionElementBase) {
76 Map useRecordText = ((DescriptionElementBase) element).getModifyingText();
79 if (text == null || text.length() == 0) {
80 text = "Use Record: No label provided";
82 text = useRecordText.toString();
83 //text = "Something else";
93 public StyledString
getStyledText(Object element
) {
94 return new StyledString(this.getText(element
),
95 StyledString
.QUALIFIER_STYLER
);
98 private static List
<Language
> getLanguageList(){
99 return Arrays
.asList(new Language
[]{CdmStore
.getDefaultLanguage()});