1
2
3
4
5
6
7
8
9
10
11
12 package sk.uniba.euromath.plugin.views.outline.items;
13
14 import java.util.ArrayList;
15 import java.util.List;
16
17 import org.eclipse.ui.views.properties.IPropertySource;
18 import org.w3c.dom.Node;
19
20 public class OutlineItem extends Object {
21
22 private static final List<OutlineItem> EMPTY_LIST = new ArrayList<OutlineItem>();
23
24 /***
25 * Holds parent Outline item.
26 */
27 private OutlineItem parent;
28
29 /***
30 * Holds node, which this outline item displays.
31 */
32 private Node model;
33
34 protected IPropertySource propSource;
35
36 /***
37 * Constructor.
38 *
39 * @param model
40 */
41 public OutlineItem(Node model) {
42 super();
43 setModel(model);
44 }
45
46 /***
47 * Constructor.
48 * @param model
49 * @param parent
50 */
51 public OutlineItem(Node model, OutlineItem parent) {
52 this(model);
53 setParent(parent);
54 }
55
56 public void addChild(OutlineItem child) {
57 }
58
59 protected IPropertySource createPropertySource() {
60 return null;
61 }
62
63 public List<OutlineItem> getChildren() {
64 return EMPTY_LIST;
65 }
66
67 public String getImageKey() {
68 return null;
69 }
70
71 public Node getModel() {
72 return this.model;
73 }
74
75 public OutlineItem getParent() {
76 return this.parent;
77 }
78
79 public IPropertySource getPropertySource() {
80 if (this.propSource == null) {
81 setPropSource(createPropertySource());
82 }
83 return this.propSource;
84 }
85
86 public boolean isLeaf() {
87 return getChildren().size() == 0;
88 }
89
90 public void removeChild(OutlineItem child) {
91 }
92
93 public void setModel(Node model) {
94 this.model = model;
95 }
96
97 public void setParent(OutlineItem parent) {
98 this.parent = parent;
99 }
100
101 @Override
102 public String toString() {
103 return "OutlineNode (model: " + getModel().toString().trim() + ")";
104 }
105
106 /***
107 * @param propSource The propSource to set.
108 */
109 protected void setPropSource(IPropertySource propSource) {
110 this.propSource = propSource;
111 }
112
113 }