Project

General

Profile

Download (2.68 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 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

    
10
package eu.etaxonomy.taxeditor.propertysheet.name;
11

    
12
import java.util.ArrayList;
13
import java.util.Collection;
14
import java.util.List;
15

    
16
import org.apache.log4j.Logger;
17

    
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;
22

    
23
/**
24
 * @author p.ciardelli
25
 * @created 15.05.2008
26
 * @version 1.0
27
 */
28
public class NomStatusPropertySource extends CollectionPropertySource {
29
	private static final Logger logger = Logger.
30
			getLogger(NomStatusPropertySource.class);
31

    
32
	public NomStatusPropertySource(Collection collection) {
33
		super(collection);
34
	}
35

    
36
	static NomenclaturalStatusType[] nomStatusTypes = null;
37
	static String[] P_NOMSTATUS_MENU = null;
38
	private static void populateNomStatusTypes() {
39
		
40
		// Get terms from nom status vocabulary
41
		List<NomenclaturalStatusType> nomStatusTypesList = new ArrayList<NomenclaturalStatusType>();
42
		nomStatusTypesList.addAll(
43
				CdmStore.getDefault().getNomStatus().getTerms());
44
				
45
		// Populate nom status type menu labels 
46
		List<String> nomStatusTypesMenuList = new ArrayList<String>();
47
		for (NomenclaturalStatusType nomStatusType : nomStatusTypesList) {
48
			nomStatusTypesMenuList.add(nomStatusType.getLabel());
49
		}
50
		
51
		// Add an empty element for "nothing selected" in the rank drop-down 
52
		nomStatusTypesList.add(0, null);
53
		nomStatusTypesMenuList.add(0, "");
54
		
55
		// Convert rank lists to array
56
		nomStatusTypes = nomStatusTypesList.toArray(new NomenclaturalStatusType[nomStatusTypesList.size()]);
57
		P_NOMSTATUS_MENU = nomStatusTypesMenuList.toArray(new String[nomStatusTypesMenuList.size()]); 	
58
	}		
59
	
60

    
61
	@Override
62
	protected String getItemDisplayName(Object item) {
63
		// No display names on individual nom statii
64
		return "";
65
	}
66

    
67
	@Override
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();
74
			}
75
		}
76
		return null;
77
	}
78

    
79
	@Override
80
	public void setPropertyValue(Object id, Object value) {
81
		// Fields not editable in property sheet view	
82
	}
83

    
84
	@Override
85
	public String toString() {
86
		// "Nom. Status" header has no value
87
		return "";
88
	}
89
}
(8-8/14)