Revision c226920a
Added by Fabian Reimeier almost 6 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/container/PresenceAbsenceTermContainer.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
private static Collection<PresenceAbsenceTerm> defaultDistributionStatus; |
29 | 29 |
|
30 |
/** |
|
31 |
* A comparator to sort {@link PresenceAbsenceTerm}s contained in {@link PresenceAbsenceTermContainer}s. |
|
32 |
* |
|
33 |
*/ |
|
30 | 34 |
static class PresenceAbsenceTermComparator implements Comparator<PresenceAbsenceTerm> { |
31 | 35 |
@Override |
32 | 36 |
public int compare(PresenceAbsenceTerm pa1, PresenceAbsenceTerm pa2) { |
... | ... | |
35 | 39 |
|
36 | 40 |
} |
37 | 41 |
|
42 |
/** |
|
43 |
* Creates and initializes a new {@link PresenceAbsenceTermContainer}. |
|
44 |
* @throws IllegalArgumentException |
|
45 |
*/ |
|
38 | 46 |
private PresenceAbsenceTermContainer() |
39 | 47 |
throws IllegalArgumentException { |
40 | 48 |
super(PresenceAbsenceTerm.class); |
41 | 49 |
initDataModel(); |
42 | 50 |
} |
43 | 51 |
|
52 |
/** |
|
53 |
* Initializes the data model of the container and adds all allowed {@link PresenceAbsenceTerm}s to the bean. |
|
54 |
*/ |
|
44 | 55 |
private void initDataModel() { |
45 | 56 |
Collection<PresenceAbsenceTerm> distributionStatus = getDistributionStatusList(TERMS_INIT_STRATEGY); |
46 | 57 |
defaultDistributionStatus = distributionStatus; |
47 | 58 |
addAll(distributionStatus); |
48 | 59 |
} |
49 | 60 |
|
61 |
/** |
|
62 |
* Gets an existing instance of the {@link PresenceAbsenceTermContainer} or creates a new one. |
|
63 |
* @return Instance of {@link PresenceAbsenceTermContainer}. |
|
64 |
*/ |
|
50 | 65 |
public static PresenceAbsenceTermContainer getInstance(){ |
51 | 66 |
if(instance == null){ |
52 | 67 |
instance = new PresenceAbsenceTermContainer(); |
... | ... | |
64 | 79 |
return instance; |
65 | 80 |
} |
66 | 81 |
|
82 |
/** |
|
83 |
* Returns a list of all allowed {@link PresenceAbsenceTerm}s. |
|
84 |
* @param propertyPath The property path to use for calling {@link CdmSpringContextHelper} functions to load {@link PresenceAbsenceTerm}s. |
|
85 |
* @return List of all allowed {@link PresenceAbsenceTerm}s. |
|
86 |
*/ |
|
67 | 87 |
public static List<PresenceAbsenceTerm> getDistributionStatusList(List<String> propertyPath){ |
68 | 88 |
CdmPreference statusPref = CdmSpringContextHelper.getPreferenceService().findVaadin(PreferencePredicate.AvailableDistributionStatus); |
69 | 89 |
List<PresenceAbsenceTerm> paList; |
Also available in: Unified diff
Documentation and refactoring