Moving editor sources back into trunk
[taxeditor.git] / taxeditor-editor / src / main / java / eu / etaxonomy / taxeditor / propertysheet / type / TypePropertySource.java
1 /**
2 * Copyright (C) 2009 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.type;
11
12 import java.util.Set;
13 import java.util.Vector;
14
15 import org.apache.log4j.Logger;
16 import org.eclipse.ui.views.properties.IPropertyDescriptor;
17 import org.eclipse.ui.views.properties.IPropertySource;
18 import org.eclipse.ui.views.properties.PropertyDescriptor;
19
20 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
21
22 /**
23 * @author p.ciardelli
24 * @created 11.02.2009
25 * @version 1.0
26 */
27 public class TypePropertySource implements IPropertySource {
28 private static Logger logger = Logger.getLogger(TypePropertySource.class);
29
30 /**
31 * The name whose types are being displayed.
32 */
33 private TaxonNameBase name;
34
35 /**
36 * If this is a property with a parent, the parent's property ID
37 */
38 private String parentid;
39
40 /**
41 * Property unique keys
42 */
43 public static final String P_ID_NAMETYPES = "nametypes";
44
45 /**
46 * Property display keys
47 */
48 public static final String P_NAMETYPES = "Name Types";
49
50 protected static final String[] TOP_LEVEL_PROPERTIES = new String[] {
51 P_ID_NAMETYPES};
52
53 protected Vector<PropertyDescriptor> descriptors = new Vector<PropertyDescriptor>();
54
55 public TypePropertySource(TaxonNameBase name) {
56 this.name = name;
57
58 addDescriptor(P_ID_NAMETYPES);
59 }
60
61
62 /**
63 *
64 */
65 private void addDescriptor(String id) {
66 // Name relations, listed in custom property descriptor
67 if (id.equals(P_ID_NAMETYPES)) {
68 descriptors.addElement(
69 new TypePropertyDescriptor(P_ID_NAMETYPES, P_NAMETYPES, name) {
70 protected void saveTypes(Set set) {
71 setPropertyValue(P_ID_NAMETYPES, set);
72 }
73 }
74 );
75 };
76 }
77
78
79 /* (non-Javadoc)
80 * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
81 */
82 public Object getEditableValue() {
83 return null;
84 }
85
86 /* (non-Javadoc)
87 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
88 */
89 public IPropertyDescriptor[] getPropertyDescriptors() {
90 return (IPropertyDescriptor[]) descriptors.toArray(
91 new IPropertyDescriptor[descriptors.size()]);
92 }
93
94 /* (non-Javadoc)
95 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
96 */
97 public Object getPropertyValue(Object id) {
98 return null;
99 }
100
101 /* (non-Javadoc)
102 * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
103 */
104 public boolean isPropertySet(Object id) {
105 return false;
106 }
107
108 /* (non-Javadoc)
109 * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
110 */
111 public void resetPropertyValue(Object id) {
112
113 }
114
115 /* (non-Javadoc)
116 * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
117 */
118 public void setPropertyValue(Object id, Object value) {
119
120 }
121 }