Project

General

Profile

Download (1.71 KB) Statistics
| Branch: | Tag: | Revision:
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.editor.view.checklist.e4;
10

    
11
import org.eclipse.nebula.widgets.nattable.data.convert.DisplayConverter;
12

    
13
import eu.etaxonomy.cdm.model.common.Representation;
14
import eu.etaxonomy.cdm.model.description.Distribution;
15
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
16
import eu.etaxonomy.taxeditor.store.CdmStore;
17

    
18
/**
19
 * @author k.luther
20
 * @since 05.12.2018
21
 *
22
 */
23
public class FilterStatusDisplayConverter extends DisplayConverter{
24
    public static final String DEFAULT_ENTRY = "";
25
    /**
26
     * {@inheritDoc}
27
     */
28
    @Override
29
    public Object canonicalToDisplayValue(Object canonicalValue) {
30
        if(canonicalValue instanceof Distribution){
31
            Distribution distribution = (Distribution)canonicalValue;
32
            if (distribution.getStatus() != null){
33

    
34
                Representation rep = distribution.getStatus().getPreferredRepresentation(CdmStore.getDefaultLanguage());
35
                String label = rep.getLabel();
36
                return (label != null)?label:DEFAULT_ENTRY;
37

    
38
            }
39

    
40
            return "";
41
        }else if(canonicalValue instanceof PresenceAbsenceTerm){
42
            return ((PresenceAbsenceTerm)canonicalValue).getLabel();
43
        } else if(canonicalValue!=null){
44
            return canonicalValue.toString();
45
        }
46
        return null;
47
    }
48

    
49
    /**
50
     * {@inheritDoc}
51
     */
52
    @Override
53
    public Object displayToCanonicalValue(Object displayValue) {
54
        return null;
55
    }
56

    
57
}
(15-15/20)