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(){
|
30
|
super();
|
31
|
}
|
32
|
|
33
|
public AreaLabelProvider(Styler vocStyler){
|
34
|
super(vocStyler);
|
35
|
}
|
36
|
|
37
|
|
38
|
@Override
|
39
|
public void update(ViewerCell cell) {
|
40
|
Object element = cell.getElement();
|
41
|
|
42
|
String text = getText(element);
|
43
|
cell.setText(text);
|
44
|
|
45
|
Styler styler = null;
|
46
|
if (element instanceof TermVocabulary && text != null) {
|
47
|
styler = getVocabularyStyler();
|
48
|
}
|
49
|
else if(element instanceof NamedAreaWrapper && ((NamedAreaWrapper) element).getNamedArea().getKindOf()!=null){
|
50
|
styler = getKindOfStyler();
|
51
|
}
|
52
|
if(styler!=null){
|
53
|
StyledString styledString = new StyledString(text, styler);
|
54
|
StyleRange[] styleRanges;
|
55
|
styleRanges = styledString.getStyleRanges();
|
56
|
cell.setStyleRanges(styleRanges);
|
57
|
}
|
58
|
super.update(cell);
|
59
|
}
|
60
|
|
61
|
@Override
|
62
|
public String getText(Object element) {
|
63
|
String label = null;
|
64
|
if(element instanceof NamedAreaWrapper){
|
65
|
NamedAreaWrapper wrapper = (NamedAreaWrapper)element;
|
66
|
DefinedTermBase termBase = wrapper.getNamedArea();
|
67
|
label = super.getText(termBase);
|
68
|
if (wrapper.isBaseElement){
|
69
|
label = label +""; //+ " (Base)" //$NON-NLS-1$
|
70
|
}
|
71
|
return label;
|
72
|
|
73
|
}
|
74
|
return super.getText(element);
|
75
|
}
|
76
|
|
77
|
|
78
|
/**
|
79
|
* {@inheritDoc}
|
80
|
*/
|
81
|
@Override
|
82
|
public Image getImage(Object element) {
|
83
|
// TODO Auto-generated method stub
|
84
|
return null;
|
85
|
}
|
86
|
|
87
|
|
88
|
|
89
|
|
90
|
}
|