p2izing the editor
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor.prototype2 / src / eu / etaxonomy / taxeditor / prototype2 / model / PropertySheetNode.java
1 package eu.etaxonomy.taxeditor.prototype2.model;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6 import org.eclipse.core.databinding.observable.value.IObservableValue;
7
8 /**
9 *
10 *
11 * @author p.ciardelli
12 *
13 */
14 public class PropertySheetNode {
15
16 private boolean editable;
17 private List<PropertySheetNode> childProperties;
18 private PropertySheetNode parentProperty;
19 private String propertyField;
20 private String propertyValue;
21 private IObservableValue observeValue;
22
23 public static boolean EDITABLE = true;
24 public static boolean NOT_EDITABLE = false;
25
26 public PropertySheetNode(String field, String value,
27 PropertySheetNode parent, boolean editable) {
28 this.propertyField = field;
29 this.propertyValue = value;
30 this.parentProperty = parent;
31 if (parent != null) parent.addChildProperty(this);
32 this.editable = editable;
33 }
34
35 public PropertySheetNode(String field, IObservableValue observeValue,
36 PropertySheetNode parent, boolean editable) {
37 this(field, (String) observeValue.getValue(), parent, editable);
38 this.observeValue = observeValue;
39 }
40
41 private void addChildProperty(PropertySheetNode childProperty ) {
42 if (childProperties == null)
43 childProperties = new ArrayList<PropertySheetNode>();
44 if (!childProperties.contains(childProperty))
45 childProperties.add(childProperty);
46 }
47
48 public boolean isEditable() {
49 return editable;
50 }
51
52 public void setEditable(boolean editable) {
53 this.editable = editable;
54 }
55
56 public String getPropertyField() {
57 return propertyField;
58 }
59
60 public void setPropertyField(String propertyField) {
61 this.propertyField = propertyField;
62 }
63
64 public String getPropertyValue() {
65 if (observeValue != null)
66 return (String) observeValue.getValue();
67 return propertyValue;
68 }
69
70 public void setPropertyValue(String propertyValue) {
71 this.propertyValue = propertyValue;
72 }
73
74 public List<PropertySheetNode> getChildProperties() {
75 return childProperties;
76 }
77
78 public void setChildProperties(List<PropertySheetNode> subProperties) {
79 this.childProperties = subProperties;
80 }
81
82 public PropertySheetNode getParentProperty() {
83 return parentProperty;
84 }
85
86 public void setParentProperty(PropertySheetNode parentProperty) {
87 this.parentProperty = parentProperty;
88 }
89
90 public IObservableValue getObserveValue() {
91 return this.observeValue;
92 }
93 }