1
|
/**
|
2
|
* Copyright (C) 2017 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.descriptiveDataSet.matrix.categorical;
|
10
|
|
11
|
import java.util.Collection;
|
12
|
import java.util.Iterator;
|
13
|
|
14
|
import org.eclipse.nebula.widgets.nattable.data.convert.DisplayConverter;
|
15
|
|
16
|
import eu.etaxonomy.cdm.api.service.l10n.TermRepresentation_L10n;
|
17
|
import eu.etaxonomy.cdm.persistence.dto.TermDto;
|
18
|
|
19
|
/**
|
20
|
* Converts CategoricalData and States of one cell of the character matrix to a
|
21
|
* String.
|
22
|
*
|
23
|
* @author pplitzner
|
24
|
* @since Dec 1, 2017
|
25
|
*
|
26
|
*/
|
27
|
public class CategoricalDataDisplayConverter extends DisplayConverter {
|
28
|
|
29
|
@Override
|
30
|
public Object canonicalToDisplayValue(Object canonicalValue) {
|
31
|
if(canonicalValue instanceof TermDto){
|
32
|
((TermDto) canonicalValue).localize(new TermRepresentation_L10n());
|
33
|
return ((TermDto) canonicalValue).getTitleCache();
|
34
|
}
|
35
|
else if (canonicalValue instanceof Collection) {
|
36
|
// Collection.toString() will add [ and ] around
|
37
|
// the values in the Collection
|
38
|
// So by removing the leading and ending
|
39
|
// character, we remove the brackets
|
40
|
|
41
|
String result = canonicalValue.toString();
|
42
|
result = result.substring(1, result.length() - 1);
|
43
|
return result;
|
44
|
}
|
45
|
else if(canonicalValue!=null){
|
46
|
return canonicalValue.toString();
|
47
|
}
|
48
|
return null;
|
49
|
}
|
50
|
|
51
|
@Override
|
52
|
public Object displayToCanonicalValue(Object displayValue) {
|
53
|
return null;
|
54
|
}
|
55
|
|
56
|
}
|