2 * Copyright (C) 2018 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.editor
.view
.checklist
.e4
;
11 import java
.util
.ArrayList
;
12 import java
.util
.Collections
;
13 import java
.util
.Comparator
;
14 import java
.util
.List
;
15 import java
.util
.UUID
;
17 import org
.apache
.commons
.lang
.StringUtils
;
18 import org
.eclipse
.nebula
.widgets
.nattable
.edit
.editor
.IComboBoxDataProvider
;
20 import eu
.etaxonomy
.cdm
.model
.term
.DefinedTermBase
;
21 import eu
.etaxonomy
.cdm
.model
.term
.OrderedTermComparator
;
22 import eu
.etaxonomy
.cdm
.model
.term
.Representation
;
23 import eu
.etaxonomy
.cdm
.model
.description
.PresenceAbsenceTerm
;
24 import eu
.etaxonomy
.cdm
.model
.metadata
.PreferencePredicate
;
25 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
26 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
33 public class StatusComboBoxDataProvider
implements IComboBoxDataProvider
{
35 private DistributionEditor editor
;
36 private int maxVisibleItems
;
38 public StatusComboBoxDataProvider(DistributionEditor editor
) {
45 public List
<?
> getValues(int columnIndex
, int rowIndex
) {
49 public static List
<?
> getValues(){
50 List
<DefinedTermBase
> inputAll
= new ArrayList
<>();
51 PresenceAbsenceTerm noneTerm
= PresenceAbsenceTerm
.NewInstance();
52 noneTerm
.setTitleCache(" - ", true);
53 noneTerm
.addRepresentation(Representation
.NewInstance(" - ", " ", " ", CdmStore
.getDefaultLanguage()));
54 inputAll
.add(noneTerm
);
55 String statusString
= PreferencesUtil
.getStringValue(PreferencePredicate
.AvailableDistributionStatus
.getKey());
56 List
<PresenceAbsenceTerm
> inputList
;
57 if (!StringUtils
.isBlank(statusString
)){
59 String
[] statusArray
= statusString
.split(";");
60 List
<UUID
> uuidList
= new ArrayList();
61 for (String status
: statusArray
){
62 uuidList
.add(UUID
.fromString(status
));
65 inputList
= CdmStore
.getTermManager().getTerms(uuidList
, PresenceAbsenceTerm
.class);
68 inputList
= CdmStore
.getTermManager().getPreferredTerms(PresenceAbsenceTerm
.class);
70 Comparator
<DefinedTermBase
> comp
= new OrderedTermComparator
<>();
71 Collections
.sort(inputList
, comp
);
72 Collections
.sort(inputList
, Collections
.reverseOrder());
74 inputAll
.addAll(1, inputList
);
78 public int getMaxVisibleItems(){
79 return maxVisibleItems
;