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_UUID
= "uuid";
39 public static final String P_ID_LABEL
= "label";
41 // Property display keys
42 // Note: for an explanation of the sorting prefixes ("04:"),
43 // @see eu.etaxonomy.taxeditor.propertysheet.CustomSortPropertySheetEntry
44 public static final String P_UUID
= "00:UUID";
45 public static final String P_LABEL
= "01:Description Label";
47 // protected static final String[] TOP_LEVEL_PROPERTIES = new String[] {
48 // P_ID_LABEL, P_ID_UUID};
49 protected static final String
[] TOP_LEVEL_PROPERTIES
= new String
[] {
53 * Constructor for top level property fields. All fields that are not subfields
54 * should be listed here.
57 public TaxonDescriptionPropertySource(TaxonDescription taxonDescription
) {
58 this(taxonDescription
, null, TOP_LEVEL_PROPERTIES
);
61 public TaxonDescriptionPropertySource(TaxonDescription taxonDescription
, String parentid
,
63 this.taxonDescription
= taxonDescription
;
64 this.parentid
= parentid
;
65 for (String key
: keys
) {
70 protected Vector
<PropertyDescriptor
> descriptors
= new Vector
<PropertyDescriptor
>();
72 * Add descriptor for a given property.
74 * Notes on Descriptor:
76 * PropertyDescriptor - uneditable cell value
77 * ComboBoxPropertyDescriptor - dropdown list, property supplied must be integer-based
78 * TextPropertyDescriptor - editable cell value
80 * If any descriptor calls setCategory, all descriptors w/out a category are put in
83 * descriptor.setFilterFlags (new String[] { IPropertySheetEntry.FILTER_ID_EXPERT }) -
84 * this descriptor shown under advanced properties
88 protected void addDescriptor(String id
) {
89 if (id
.equals(P_ID_LABEL
)) {
90 descriptors
.addElement(
91 new TextPropertyDescriptor(P_ID_LABEL
, P_LABEL
));
93 if (id
.equals(P_ID_UUID
)) {
94 descriptors
.addElement(
95 new PropertyDescriptor(P_ID_UUID
, P_UUID
));
100 * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
102 public Object
getEditableValue() {
107 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
109 public IPropertyDescriptor
[] getPropertyDescriptors() {
110 return (IPropertyDescriptor
[]) descriptors
.toArray(
111 new IPropertyDescriptor
[descriptors
.size()]);
115 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
117 public Object
getPropertyValue(Object id
) {
118 if (id
.equals(P_ID_LABEL
)) {
119 return taxonDescription
.getTitleCache();
121 if (id
.equals(P_ID_UUID
)) {
122 return taxonDescription
.getUuid().toString();
128 * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
130 public boolean isPropertySet(Object id
) {
135 * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
137 public void resetPropertyValue(Object id
) {}
140 * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
142 public void setPropertyValue(Object id
, Object value
) {
143 if (id
.equals(P_ID_LABEL
)) {
144 taxonDescription
.setTitleCache((String
) value
);