Project

General

Profile

Download (1.68 KB) Statistics
| Branch: | Tag: | Revision:
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

    
13
import org.eclipse.nebula.widgets.nattable.data.convert.DisplayConverter;
14

    
15
import eu.etaxonomy.cdm.api.service.l10n.TermRepresentation_L10n;
16
import eu.etaxonomy.cdm.persistence.dto.TermDto;
17

    
18
/**
19
 * Converts CategoricalData and States of one cell of the character matrix to a
20
 * String.
21
 *
22
 * @author pplitzner
23
 * @since Dec 1, 2017
24
 *
25
 */
26
public class CategoricalDataDisplayConverter extends DisplayConverter {
27

    
28
    @Override
29
    public Object canonicalToDisplayValue(Object canonicalValue) {
30
        if(canonicalValue instanceof TermDto){
31
            ((TermDto) canonicalValue).localize(new TermRepresentation_L10n());
32
            return ((TermDto) canonicalValue).getRepresentation_L10n();
33
        }
34
        else if (canonicalValue instanceof Collection) {
35
            // Collection.toString() will add [ and ] around
36
            // the values in the Collection
37
            // So by removing the leading and ending
38
            // character, we remove the brackets
39
            String result = canonicalValue.toString();
40
            result = result.substring(1, result.length() - 1);
41
            return result;
42
        }
43
        else if(canonicalValue!=null){
44
            return canonicalValue.toString();
45
        }
46
        return null;
47
    }
48

    
49
    @Override
50
    public Object displayToCanonicalValue(Object displayValue) {
51
        return null;
52
    }
53

    
54
}
(3-3/3)