1
|
/**
|
2
|
* Copyright (C) 2019 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.editor.view.checklist.e4;
|
10
|
|
11
|
import org.apache.commons.lang.StringUtils;
|
12
|
|
13
|
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
|
14
|
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
|
15
|
import eu.etaxonomy.cdm.model.metadata.TermComboEnum;
|
16
|
import eu.etaxonomy.cdm.model.metadata.TermDisplayEnum;
|
17
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
18
|
|
19
|
/**
|
20
|
* @author k.luther
|
21
|
* @since 27.05.2019
|
22
|
*
|
23
|
*/
|
24
|
public class StatusHelper {
|
25
|
PresenceAbsenceTerm term;
|
26
|
String label;
|
27
|
|
28
|
public StatusHelper(PresenceAbsenceTerm term){
|
29
|
this.term = term;
|
30
|
TermDisplayEnum display = TermDisplayEnum.valueOf(PreferencesUtil.displayStatusInChecklistEditor());
|
31
|
|
32
|
String result = PreferencesUtil.getStringValue(PreferencePredicate.DisplayOfStatusInCombo.getKey());
|
33
|
if (StringUtils.isBlank(result)){
|
34
|
result = ((TermComboEnum) PreferencePredicate.DisplayOfStatusInCombo.getDefaultValue()).getKey();
|
35
|
}
|
36
|
TermComboEnum comboDisplay = TermComboEnum.byKey(result);
|
37
|
if(term.getTitleCache().trim().equals("-")){
|
38
|
label = term.getTitleCache();
|
39
|
}else if (comboDisplay.equals(TermComboEnum.IdInVocabulary) && term.getIdInVocabulary() != null){
|
40
|
label = term.getIdInVocabulary();
|
41
|
}else if (comboDisplay.equals(TermComboEnum.Symbol1) && term.getSymbol() != null){
|
42
|
label = term.getSymbol();
|
43
|
} else if (comboDisplay.equals(TermComboEnum.Symbol2) && term.getSymbol2() != null){
|
44
|
label = term.getSymbol2();
|
45
|
} else if (comboDisplay.equals(TermComboEnum.TermDisplayPlusTitle)){
|
46
|
if (display.equals(TermDisplayEnum.IdInVocabulary)){
|
47
|
label = "["+term.getIdInVocabulary()+"] "+ term.getTitleCache();
|
48
|
}else if (display.equals(TermDisplayEnum.Symbol1)){
|
49
|
label = "["+term.getSymbol()+"] "+ term.getTitleCache();
|
50
|
}else if (display.equals(TermDisplayEnum.Symbol2)){
|
51
|
label = "["+term.getSymbol2()+"] "+ term.getTitleCache();
|
52
|
}else{
|
53
|
label = term.getTitleCache();
|
54
|
}
|
55
|
|
56
|
|
57
|
}
|
58
|
|
59
|
|
60
|
}
|
61
|
@Override
|
62
|
public String toString(){
|
63
|
return label;
|
64
|
}
|
65
|
|
66
|
}
|