1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.ui.vaadin.gwt.client.editor.dom;
35
36 import com.google.gwt.dom.client.Element;
37 import com.google.gwt.json.client.JSONObject;
38 import com.google.gwt.json.client.JSONString;
39
40 import info.magnolia.ui.vaadin.gwt.client.editor.model.Model;
41 import info.magnolia.ui.vaadin.gwt.client.editor.widget.controlbar.AbstractBar;
42 import info.magnolia.ui.vaadin.gwt.client.editor.widget.controlbar.AreaEndBar;
43 import info.magnolia.ui.vaadin.gwt.client.editor.widget.placeholder.ComponentPlaceHolder;
44
45 import java.util.Map;
46
47
48
49
50
51 public class MgnlElement extends CmsNode {
52
53 private Map<String, String> attributes;
54
55 private Element startComment;
56 private Element endComment;
57
58 private Element firstElement;
59 private Element lastElement;
60 private Element componentElement;
61 private Element areaElement;
62
63 private Element editElement;
64 private AbstractBar controlBar;
65
66
67 ComponentPlaceHolder componentPlaceHolder;
68 AreaEndBar areaEndBar;
69
70
71
72
73
74 public MgnlElement(MgnlElement parent) {
75 super(parent);
76 }
77
78
79 public void setAttributes(Map<String, String> attributes) {
80 this.attributes = attributes;
81 }
82
83 public Map<String, String> getAttributes() {
84 return this.attributes;
85 }
86
87 public AbstractBar getControlBar() {
88 return controlBar;
89 }
90
91 public void setControlBar(AbstractBar controlBar) {
92 this.controlBar = controlBar;
93 }
94 public ComponentPlaceHolder getComponentPlaceHolder() {
95 return componentPlaceHolder;
96 }
97
98 public void setComponentPlaceHolder(ComponentPlaceHolder componentPlaceHolder) {
99 this.componentPlaceHolder = componentPlaceHolder;
100 }
101
102 public AreaEndBar getAreaEndBar() {
103 return areaEndBar;
104 }
105
106 public void setAreaEndBar(AreaEndBar areaEndBar) {
107 this.areaEndBar = areaEndBar;
108 }
109
110 public Element getFirstElement() {
111 return firstElement;
112 }
113
114 public void setFirstElement(Element firstElement) {
115 this.firstElement = firstElement;
116 }
117
118 public Element getLastElement() {
119 return lastElement;
120 }
121
122 public void setLastElement(Element lastElement) {
123 this.lastElement = lastElement;
124 }
125
126 public void setComponentElement(Element componentElement) {
127 this.componentElement = componentElement;
128 }
129
130 public void setAreaElement(Element areaElement) {
131 this.areaElement = areaElement;
132 }
133
134 public void setEditElement(Element editElement) {
135 this.editElement = editElement;
136 }
137
138 public Element getComponentElement() {
139 return componentElement;
140 }
141
142 public Element getAreaElement() {
143 return areaElement;
144 }
145
146 public Element getEditElement() {
147 return editElement;
148 }
149
150 public String getAttribute(String key) {
151 return this.attributes.get(key);
152 }
153
154 public boolean containsAttribute(String key) {
155 return this.attributes.containsKey(key);
156 }
157
158 public Element getStartComment() {
159 return startComment;
160 }
161
162 public Element getEndComment() {
163 return this.endComment;
164 }
165
166 public void setStartComment(Element element) {
167 this.startComment = element;
168 }
169 public void setEndComment(Element element) {
170 this.endComment = element;
171 }
172
173 public String getType() {
174
175 if (isPage()) {
176 return Model.CMS_PAGE;
177 }
178 if (isArea()) {
179 return Model.CMS_AREA;
180 }
181 else {
182 return Model.CMS_COMPONENT;
183 }
184 }
185
186 public String getJsonAttributes() {
187
188 JSONObject json = new JSONObject();
189
190 for ( String key : attributes.keySet()) {
191 String value = attributes.get(key);
192 json.put(key, new JSONString(value));
193 }
194 return json.toString();
195 }
196 }