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
.TextData
;
21 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
23 public class UsesLabelProvider
extends ColumnLabelProvider
implements
24 IStyledLabelProvider
{
26 private static DescriptionBuilder
<CategoricalData
> categoricalDescriptionBuilder
= new DefaultCategoricalDescriptionBuilder();
27 public String
getText(Object element
) {
30 * return DescriptionHelper.getLabel(element);
32 * for (Marker marker : element.getMarkers()) { if
33 * (marker.getMarkerType().getTitleCache().equals("use")) { return
36 if (element
instanceof DescriptionBase
) {
37 text
= ((DescriptionBase
) element
).getTitleCache();
38 if (text
== null || text
.length() == 0) {
39 text
= "Use: No label provided";
42 text
= "Use: " + text
;
45 else if (element
instanceof CategoricalData
) {
46 TextData textData
= categoricalDescriptionBuilder
.build((CategoricalData
) element
, getLanguageList());
47 text
= textData
.getText(CdmStore
.getDefaultLanguage());
48 if (text
== null || text
.length() == 0) {
49 text
= "No data provided";
53 /*else if (element instanceof DescriptionElementBase) {
54 Map useRecordText = ((DescriptionElementBase) element).getModifyingText();
57 if (text == null || text.length() == 0) {
58 text = "Use Record: No label provided";
60 text = useRecordText.toString();
61 //text = "Something else";
71 public StyledString
getStyledText(Object element
) {
72 return new StyledString(this.getText(element
),
73 StyledString
.QUALIFIER_STYLER
);
76 private static List
<Language
> getLanguageList(){
77 return Arrays
.asList(new Language
[]{CdmStore
.getDefaultLanguage()});