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
.description
;
12 import java
.util
.Vector
;
14 import org
.eclipse
.ui
.views
.properties
.IPropertyDescriptor
;
15 import org
.eclipse
.ui
.views
.properties
.PropertyDescriptor
;
17 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
18 import eu
.etaxonomy
.taxeditor
.propertysheet
.ICdmBasePropertySource
;
25 public class TaxonDescriptionPropertySource
implements ICdmBasePropertySource
{
27 // The TaxonDescription whose properties are being displayed
28 private TaxonDescription taxonDescription
;
30 // If this is a property with a parent, the parent's property ID
31 private String parentid
;
33 // Property unique keys
34 public static final String P_ID_LABEL
= "label";
35 public static final String P_ID_UUID
= "uuid";
37 // Property display keys
38 public String P_LABEL
= "Description Label";
39 public static final String P_UUID
= "UUID";
41 protected static final String
[] TOP_LEVEL_PROPERTIES
= new String
[] {
45 * Constructor for top level property fields. All fields that are not subfields
46 * should be listed here.
49 public TaxonDescriptionPropertySource(TaxonDescription taxonDescription
) {
50 this(taxonDescription
, null, TOP_LEVEL_PROPERTIES
);
53 public TaxonDescriptionPropertySource(TaxonDescription taxonDescription
, String parentid
,
56 if (taxonDescription
.isImageGallery()) {
57 P_LABEL
= "Image Gallery Label";
60 this.taxonDescription
= taxonDescription
;
61 this.setParentid(parentid
);
62 for (String key
: keys
) {
67 protected Vector
<PropertyDescriptor
> descriptors
= new Vector
<PropertyDescriptor
>();
69 * Add descriptor for a given property.
71 * Notes on Descriptor:
73 * PropertyDescriptor - uneditable cell value
74 * ComboBoxPropertyDescriptor - dropdown list, property supplied must be integer-based
75 * TextPropertyDescriptor - editable cell value
77 * If any descriptor calls setCategory, all descriptors w/out a category are put in
80 * descriptor.setFilterFlags (new String[] { IPropertySheetEntry.FILTER_ID_EXPERT }) -
81 * this descriptor shown under advanced properties
85 protected void addDescriptor(String id
) {
86 if (id
.equals(P_ID_LABEL
)) {
87 descriptors
.addElement(
88 new PropertyDescriptor(P_ID_LABEL
, P_LABEL
));
90 if (id
.equals(P_ID_UUID
)) {
91 descriptors
.addElement(
92 new PropertyDescriptor(P_ID_UUID
, P_UUID
));
97 * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
99 public Object
getEditableValue() {
104 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
106 public IPropertyDescriptor
[] getPropertyDescriptors() {
107 return (IPropertyDescriptor
[]) descriptors
.toArray(
108 new IPropertyDescriptor
[descriptors
.size()]);
112 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
114 public Object
getPropertyValue(Object id
) {
115 if (id
.equals(P_ID_LABEL
)) {
116 return taxonDescription
.getTitleCache();
118 if (id
.equals(P_ID_UUID
)) {
119 return taxonDescription
.getUuid().toString();
125 * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
127 public boolean isPropertySet(Object id
) {
132 * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
134 public void resetPropertyValue(Object id
) {}
137 * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
139 public void setPropertyValue(Object id
, Object value
) {
140 if (id
.equals(P_ID_LABEL
)) {
141 taxonDescription
.setTitleCache((String
) value
);
146 * @param parentid the parentid to set
148 public void setParentid(String parentid
) {
149 this.parentid
= parentid
;
153 * @return the parentid
155 public String
getParentid() {