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.cms.gui.inline;
35
36 import info.magnolia.cms.beans.config.ServerConfiguration;
37 import info.magnolia.cms.gui.control.Bar;
38 import info.magnolia.cms.gui.control.Button;
39 import info.magnolia.cms.i18n.MessagesManager;
40 import info.magnolia.cms.security.Permission;
41 import info.magnolia.cms.core.AggregationState;
42 import info.magnolia.context.MgnlContext;
43 import info.magnolia.freemarker.FreemarkerUtil;
44
45 import org.apache.commons.lang.StringUtils;
46
47 import javax.servlet.http.HttpServletRequest;
48 import javax.servlet.jsp.JspWriter;
49 import java.io.IOException;
50 import java.io.Writer;
51
52
53
54
55
56
57 public class BarEdit extends Bar {
58
59 private ButtonEdit buttonEdit = new ButtonEdit();
60
61 private Button buttonMove = new Button();
62
63 private Button buttonDelete = new Button();
64
65 private String paragraph;
66
67
68
69
70 public BarEdit(HttpServletRequest request) {
71 }
72
73 public BarEdit() {
74
75 }
76
77
78
79
80 public void setDefaultButtons() {
81 this.setButtonEdit();
82 this.setButtonMove();
83 this.setButtonDelete();
84 }
85
86
87
88
89 public void placeDefaultButtons() {
90 if (this.getButtonMove() != null) {
91 this.getButtonsLeft().add(0, this.getButtonMove());
92 }
93 if (this.getButtonEdit() != null) {
94 this.getButtonsLeft().add(0, this.getButtonEdit());
95 }
96 if (this.getButtonDelete() != null) {
97 this.getButtonsRight().add(this.getButtonsRight().size(), this.getButtonDelete());
98 }
99 }
100
101 public ButtonEdit getButtonEdit() {
102 return this.buttonEdit;
103 }
104
105 public void setButtonEdit(ButtonEdit b) {
106 this.buttonEdit = b;
107 }
108
109 public void setButtonEdit() {
110 this.setButtonEdit(this.getPath(), this.getNodeCollectionName(StringUtils.EMPTY), this.getNodeName(StringUtils.EMPTY), this.getParagraph());
111 }
112
113
114
115
116
117
118
119
120
121 public void setButtonEdit(String path, String nodeCollectionName, String nodeName, String paragraph) {
122 ButtonEdit b = new ButtonEdit(path, nodeCollectionName, nodeName, paragraph);
123 b.setDefaultOnclick();
124 this.setButtonEdit(b);
125 }
126
127 public Button getButtonMove() {
128 return this.buttonMove;
129 }
130
131 public void setButtonMove(Button b) {
132 this.buttonMove = b;
133 }
134
135 public void setButtonMove() {
136 this.setButtonMove(this.getNodeCollectionName(StringUtils.EMPTY), this.getNodeName(StringUtils.EMPTY));
137 }
138
139
140
141
142
143
144
145 public void setButtonMove(String nodeCollectionName, String nodeName) {
146 Button b = new Button();
147 b.setLabel(MessagesManager.get("buttons.move"));
148
149 this.setId(nodeCollectionName + "__" + nodeName);
150 b.setOnclick("mgnlMoveNodeStart('" + nodeCollectionName + "','" + nodeName + "','" + this.getId() + "');");
151 this.setButtonMove(b);
152 }
153
154 public Button getButtonDelete() {
155 return this.buttonDelete;
156 }
157
158 public void setButtonDelete(Button b) {
159 this.buttonDelete = b;
160 }
161
162
163
164
165 public void setButtonDelete() {
166 this.setButtonDelete(this.getPath(), this.getNodeCollectionName(), this.getNodeName());
167 }
168
169
170
171
172
173
174
175
176
177
178 public void setButtonDelete(String path, String nodeCollectionName, String nodeName) {
179 Button b = new Button();
180 b.setLabel(MessagesManager.get("buttons.delete"));
181 b.setOnclick("mgnlDeleteNode('" + path + "','" + nodeCollectionName + "','" + nodeName + "');");
182 this.setButtonDelete(b);
183 }
184
185 public void setButtonDelete(String pathToDelete) {
186 Button b = new Button();
187 b.setLabel(MessagesManager.get("buttons.delete"));
188 b.setOnclick("mgnlDeleteNode('" + pathToDelete + "');");
189 this.setButtonDelete(b);
190 }
191
192
193
194
195 public void drawHtml(JspWriter out) throws IOException {
196 drawHtml((Writer) out);
197 }
198
199
200
201
202 public void drawHtml(Writer out) throws IOException {
203 out.write(FreemarkerUtil.process(this));
204
205
206
207
208
209
210
211
212 }
213
214 public String getParagraph() {
215 return this.paragraph;
216 }
217
218 public void setParagraph(String paragraph) {
219 this.paragraph = paragraph;
220 }
221 }