Project

General

Profile

Download (2.12 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 java.util.ArrayList;
12
import java.util.Collection;
13
import java.util.Collections;
14
import java.util.Comparator;
15
import java.util.List;
16

    
17
import org.eclipse.nebula.widgets.nattable.edit.editor.IComboBoxDataProvider;
18

    
19
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
20
import eu.etaxonomy.cdm.model.common.OrderedTermComparator;
21
import eu.etaxonomy.cdm.model.common.Representation;
22
import eu.etaxonomy.cdm.model.common.TermType;
23
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
24
import eu.etaxonomy.taxeditor.store.CdmStore;
25

    
26
/**
27
 * @author k.luther
28
 * @since 05.12.2018
29
 *
30
 */
31
public class StatusComboBoxDataProvider implements IComboBoxDataProvider {
32

    
33
    private DistributionEditor editor;
34
    private int maxVisibleItems;
35

    
36
    public StatusComboBoxDataProvider(DistributionEditor editor) {
37
        super();
38
        this.editor = editor;
39
    }
40

    
41
    @Override
42
    public List<?> getValues(int columnIndex, int rowIndex) {
43
        return getValues();
44
    }
45

    
46
    public static List<?> getValues(){
47
        List<DefinedTermBase> inputAll = new ArrayList<>();
48
        PresenceAbsenceTerm noneTerm = PresenceAbsenceTerm.NewInstance();
49
        noneTerm.setTitleCache(" ", true);
50
        noneTerm.addRepresentation(Representation.NewInstance("", "", "", CdmStore.getDefaultLanguage()));
51
        inputAll.add(noneTerm);
52
        Collection<DefinedTermBase> input = CdmStore.getTermManager().getPreferredTerms(TermType.PresenceAbsenceTerm);
53
        List<DefinedTermBase> inputList = new ArrayList(input);
54
        Comparator<DefinedTermBase> comp = new OrderedTermComparator<>();
55
        Collections.sort(inputList, comp);
56
        Collections.sort(inputList, Collections.reverseOrder());
57

    
58
        inputAll.addAll(1, inputList);
59
        return inputAll;
60
    }
61

    
62
    public int getMaxVisibleItems(){
63
        return maxVisibleItems;
64
    }
65

    
66
}
(15-15/19)