Project

General

Profile

Download (1.5 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.cdm.vaadin.util;
10

    
11
import org.vaadin.viritin.fields.CaptionGenerator;
12
import org.vaadin.viritin.fields.LazyComboBox;
13

    
14
import eu.etaxonomy.cdm.format.reference.ReferenceEllypsisFormatter;
15
import eu.etaxonomy.cdm.format.reference.ReferenceEllypsisFormatter.LabelType;
16
import eu.etaxonomy.cdm.model.reference.Reference;
17

    
18
/**
19
 * A <code>CaptionGenerator</code> for {@link Reference References} which creates ellypsed captions.
20
 *
21
 * @author a.kohlbecker
22
 */
23
public class ReferenceEllypsisCaptionGenerator implements CaptionGenerator<Reference> {
24

    
25
    private static final long serialVersionUID = -5820263463222845068L;
26

    
27
    private LazyComboBox<Reference> combobox;
28

    
29
    private ReferenceEllypsisFormatter ellypsisFormatter;
30

    
31
    public ReferenceEllypsisCaptionGenerator(LabelType labelType, LazyComboBox<Reference> combobox){
32
        ellypsisFormatter = new ReferenceEllypsisFormatter(labelType);
33
        this.combobox = combobox;
34
    }
35

    
36

    
37
    /**
38
     * {@inheritDoc}
39
     */
40
    @Override
41
    public String getCaption(Reference reference) {
42
        String preserveString = combobox.getCurrentFilter();
43
        if(preserveString == null){
44
            preserveString = "";
45
        }
46
        return ellypsisFormatter.ellypsis(reference, preserveString);
47
    }
48

    
49
}
(14-14/17)