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
.apache
.log4j
.Logger
;
15 import org
.eclipse
.ui
.views
.properties
.IPropertyDescriptor
;
16 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
17 import org
.eclipse
.ui
.views
.properties
.PropertyDescriptor
;
18 import org
.eclipse
.ui
.views
.properties
.TextPropertyDescriptor
;
20 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
27 public class TaxonDescriptionPropertySource
implements IPropertySource
{
28 private static final Logger logger
= Logger
29 .getLogger(TaxonDescriptionPropertySource
.class);
31 // The TaxonDescription whose properties are being displayed
32 private TaxonDescription taxonDescription
;
34 // If this is a property with a parent, the parent's property ID
35 private String parentid
;
37 // Property unique keys
38 public static final String P_ID_LABEL
= "label";
39 public static final String P_ID_UUID
= "uuid";
41 // Property display keys
42 public String P_LABEL
= "Description Label";
43 public static final String P_UUID
= "UUID";
45 protected static final String
[] TOP_LEVEL_PROPERTIES
= new String
[] {
49 * Constructor for top level property fields. All fields that are not subfields
50 * should be listed here.
53 public TaxonDescriptionPropertySource(TaxonDescription taxonDescription
) {
54 this(taxonDescription
, null, TOP_LEVEL_PROPERTIES
);
57 public TaxonDescriptionPropertySource(TaxonDescription taxonDescription
, String parentid
,
60 if (taxonDescription
.isImageGallery()) {
61 P_LABEL
= "Image Gallery Label";
64 this.taxonDescription
= taxonDescription
;
65 this.parentid
= parentid
;
66 for (String key
: keys
) {
71 protected Vector
<PropertyDescriptor
> descriptors
= new Vector
<PropertyDescriptor
>();
73 * Add descriptor for a given property.
75 * Notes on Descriptor:
77 * PropertyDescriptor - uneditable cell value
78 * ComboBoxPropertyDescriptor - dropdown list, property supplied must be integer-based
79 * TextPropertyDescriptor - editable cell value
81 * If any descriptor calls setCategory, all descriptors w/out a category are put in
84 * descriptor.setFilterFlags (new String[] { IPropertySheetEntry.FILTER_ID_EXPERT }) -
85 * this descriptor shown under advanced properties
89 protected void addDescriptor(String id
) {
90 if (id
.equals(P_ID_LABEL
)) {
91 descriptors
.addElement(
92 new PropertyDescriptor(P_ID_LABEL
, P_LABEL
));
94 if (id
.equals(P_ID_UUID
)) {
95 descriptors
.addElement(
96 new PropertyDescriptor(P_ID_UUID
, P_UUID
));
101 * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
103 public Object
getEditableValue() {
108 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
110 public IPropertyDescriptor
[] getPropertyDescriptors() {
111 return (IPropertyDescriptor
[]) descriptors
.toArray(
112 new IPropertyDescriptor
[descriptors
.size()]);
116 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
118 public Object
getPropertyValue(Object id
) {
119 if (id
.equals(P_ID_LABEL
)) {
120 return taxonDescription
.getTitleCache();
122 if (id
.equals(P_ID_UUID
)) {
123 return taxonDescription
.getUuid().toString();
129 * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
131 public boolean isPropertySet(Object id
) {
136 * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
138 public void resetPropertyValue(Object id
) {}
141 * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
143 public void setPropertyValue(Object id
, Object value
) {
144 if (id
.equals(P_ID_LABEL
)) {
145 taxonDescription
.setTitleCache((String
) value
);