1
|
/**
|
2
|
* Copyright (C) 2018 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.taxeditor.preference.wizard;
|
10
|
|
11
|
import org.eclipse.jface.viewers.ILabelProvider;
|
12
|
import org.eclipse.jface.viewers.StyledString;
|
13
|
import org.eclipse.jface.viewers.StyledString.Styler;
|
14
|
import org.eclipse.jface.viewers.ViewerCell;
|
15
|
import org.eclipse.swt.custom.StyleRange;
|
16
|
import org.eclipse.swt.graphics.Image;
|
17
|
|
18
|
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
|
19
|
import eu.etaxonomy.cdm.model.common.TermVocabulary;
|
20
|
import eu.etaxonomy.taxeditor.editor.definedterm.TermLabelProvider;
|
21
|
|
22
|
/**
|
23
|
* @author k.luther
|
24
|
* @since 04.10.2018
|
25
|
*
|
26
|
*/
|
27
|
public class AreaLabelProvider extends TermLabelProvider implements ILabelProvider{
|
28
|
|
29
|
public AreaLabelProvider(Styler vocStyler){
|
30
|
super(vocStyler);
|
31
|
}
|
32
|
|
33
|
|
34
|
@Override
|
35
|
public void update(ViewerCell cell) {
|
36
|
Object element = cell.getElement();
|
37
|
|
38
|
String text = getText(element);
|
39
|
cell.setText(text);
|
40
|
|
41
|
Styler styler = null;
|
42
|
if (element instanceof TermVocabulary && text != null) {
|
43
|
styler = getVocabularyStyler();
|
44
|
}
|
45
|
else if(element instanceof NamedAreaWrapper && ((NamedAreaWrapper) element).getNamedArea().getKindOf()!=null){
|
46
|
styler = getKindOfStyler();
|
47
|
}
|
48
|
if(styler!=null){
|
49
|
StyledString styledString = new StyledString(text, styler);
|
50
|
StyleRange[] styleRanges;
|
51
|
styleRanges = styledString.getStyleRanges();
|
52
|
cell.setStyleRanges(styleRanges);
|
53
|
}
|
54
|
super.update(cell);
|
55
|
}
|
56
|
|
57
|
@Override
|
58
|
public String getText(Object element) {
|
59
|
String label = null;
|
60
|
if(element instanceof NamedAreaWrapper){
|
61
|
NamedAreaWrapper wrapper = (NamedAreaWrapper)element;
|
62
|
DefinedTermBase termBase = wrapper.getNamedArea();
|
63
|
label = super.getText(termBase);
|
64
|
if (wrapper.isBaseElement){
|
65
|
label = label +""; //+ " (Base)"
|
66
|
}
|
67
|
return label;
|
68
|
|
69
|
}
|
70
|
return super.getText(element);
|
71
|
}
|
72
|
|
73
|
|
74
|
/**
|
75
|
* {@inheritDoc}
|
76
|
*/
|
77
|
@Override
|
78
|
public Image getImage(Object element) {
|
79
|
// TODO Auto-generated method stub
|
80
|
return null;
|
81
|
}
|
82
|
|
83
|
|
84
|
|
85
|
|
86
|
}
|