2 * Copyright (C) 2007 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.
10 package eu
.etaxonomy
.taxeditor
.propertysheet
.name
;
12 import java
.util
.ArrayList
;
13 import java
.util
.Collection
;
14 import java
.util
.List
;
16 import org
.apache
.log4j
.Logger
;
18 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalStatus
;
19 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalStatusType
;
20 import eu
.etaxonomy
.taxeditor
.propertysheet
.CollectionPropertySource
;
21 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
28 public class NomStatusPropertySource
extends CollectionPropertySource
{
29 private static final Logger logger
= Logger
.
30 getLogger(NomStatusPropertySource
.class);
32 public NomStatusPropertySource(Collection collection
) {
36 static NomenclaturalStatusType
[] nomStatusTypes
= null;
37 static String
[] P_NOMSTATUS_MENU
= null;
38 private static void populateNomStatusTypes() {
40 // Get terms from nom status vocabulary
41 List
<NomenclaturalStatusType
> nomStatusTypesList
= new ArrayList
<NomenclaturalStatusType
>();
42 nomStatusTypesList
.addAll(
43 CdmStore
.getDefault().getNomStatus().getTerms());
45 // Populate nom status type menu labels
46 List
<String
> nomStatusTypesMenuList
= new ArrayList
<String
>();
47 for (NomenclaturalStatusType nomStatusType
: nomStatusTypesList
) {
48 nomStatusTypesMenuList
.add(nomStatusType
.getLabel());
51 // Add an empty element for "nothing selected" in the rank drop-down
52 nomStatusTypesList
.add(0, null);
53 nomStatusTypesMenuList
.add(0, "");
55 // Convert rank lists to array
56 nomStatusTypes
= nomStatusTypesList
.toArray(new NomenclaturalStatusType
[nomStatusTypesList
.size()]);
57 P_NOMSTATUS_MENU
= nomStatusTypesMenuList
.toArray(new String
[nomStatusTypesMenuList
.size()]);
62 protected String
getItemDisplayName(Object item
) {
63 // No display names on individual nom statii
68 public Object
getPropertyValue(Object id
) {
69 if (id
instanceof NomenclaturalStatus
) {
70 NomenclaturalStatus nomenclaturalStatus
= (NomenclaturalStatus
) id
;
71 NomenclaturalStatusType statusType
= nomenclaturalStatus
.getType();
72 if (statusType
!= null) {
73 return statusType
.getLabel();
80 public void setPropertyValue(Object id
, Object value
) {
81 // Fields not editable in property sheet view
85 public String
toString() {
86 // "Nom. Status" header has no value