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.module.admininterface.trees;
35
36 import info.magnolia.cms.core.ItemType;
37 import info.magnolia.cms.core.MetaData;
38 import info.magnolia.cms.gui.control.ContextMenuItem;
39 import info.magnolia.cms.gui.control.FunctionBarItem;
40 import info.magnolia.cms.gui.control.Tree;
41 import info.magnolia.cms.gui.control.TreeColumn;
42 import info.magnolia.cms.i18n.Messages;
43 import info.magnolia.module.admininterface.AbstractTreeConfiguration;
44
45 import javax.servlet.http.HttpServletRequest;
46
47
48
49
50
51
52 public class WebsiteTreeConfiguration extends AbstractTreeConfiguration {
53
54
55
56
57
58 public void prepareTree(final Tree tree, boolean browseMode, HttpServletRequest request) {
59 final Messages msgs = getMessages();
60
61 tree.setIconOndblclick("mgnlTreeMenuItemOpen(" + tree.getJavascriptTree() + ");");
62
63 tree.addItemType(ItemType.CONTENT);
64 tree.addIcon(ItemType.DELETED_NODE_MIXIN, "/.resources/icons/16/document_deleted.gif");
65
66 TreeColumn column0 = TreeColumn.createLabelColumn(tree, msgs.get("tree.web.page"), true);
67 column0.setWidth(3);
68
69 TreeColumn columnIcons = TreeColumn.createActivationColumn(tree, msgs.get("tree.web.status"));
70 columnIcons.setIconsPermission(true);
71
72 TreeColumn column1 = TreeColumn.createNodeDataColumn(tree, msgs.get("tree.web.title"), "title", true);
73 column1.setWidth(2);
74
75 TreeColumn column2 = new TemplateColumn(tree.getJavascriptTree(), request);
76 column2.setName(MetaData.TEMPLATE);
77 column2.setIsMeta(true);
78 column2.setWidth(2);
79 column2.setTitle(msgs.get("tree.web.template"));
80
81 column2.setHtmlRenderer(new TemplateTreeColumnHtmlRenderer());
82
83
84
85
86 TreeColumn column3 = TreeColumn.createMetaDataColumn(tree, msgs.get("tree.web.date"), MetaData.LAST_MODIFIED, "yy-MM-dd, HH:mm");
87 column3.setWidth(2);
88
89 tree.addColumn(column0);
90
91 if (!browseMode) {
92 tree.addColumn(column1);
93 if (isAdminInstance() || hasAnyActiveSubscriber()) {
94 tree.addColumn(columnIcons);
95 }
96 tree.addColumn(column2);
97 tree.addColumn(column3);
98 }
99
100 }
101
102
103
104
105
106 public void prepareContextMenu(Tree tree, boolean browseMode, HttpServletRequest request) {
107 final Messages msgs = getMessages();
108 ContextMenuItem menuOpen = new ContextMenuItem("open");
109 menuOpen.setLabel(msgs.get("tree.web.menu.open"));
110 menuOpen.setIcon(request.getContextPath() + "/.resources/icons/16/document_plain_earth.gif");
111 menuOpen.setOnclick("mgnlTreeMenuItemOpen(" + tree.getJavascriptTree() + ");");
112 menuOpen.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot("
113 + tree.getJavascriptTree()
114 + ")");
115
116 ContextMenuItem menuNewPage = new ContextMenuItem("new");
117 menuNewPage.setLabel(msgs.get("tree.web.menu.new"));
118 menuNewPage.setIcon(request.getContextPath() + "/.resources/icons/16/document_plain_earth_add.gif");
119
120 menuNewPage.setOnclick(tree.getJavascriptTree() + ".createNode('" + ItemType.CONTENT.getSystemName() + "');");
121 menuNewPage.addJavascriptCondition("new mgnlTreeMenuItemConditionPermissionWrite("
122 + tree.getJavascriptTree()
123 + ")");
124 menuNewPage.addJavascriptCondition("new mgnlTreeMenuItemConditionNotDeleted(" + tree.getJavascriptTree() + ")");
125
126 ContextMenuItem menuDelete = new ContextMenuItem("delete");
127 menuDelete.setLabel(msgs.get("tree.web.menu.delete"));
128 menuDelete.setIcon(request.getContextPath() + "/.resources/icons/16/delete2.gif");
129 menuDelete.setOnclick(tree.getJavascriptTree() + ".deleteNode("+(!isEnableDeleteConfirmation()) +");");
130 menuDelete.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot("
131 + tree.getJavascriptTree()
132 + ")");
133 menuDelete.addJavascriptCondition("new mgnlTreeMenuItemConditionPermissionWrite("
134 + tree.getJavascriptTree()
135 + ")");
136 menuDelete.addJavascriptCondition("new mgnlTreeMenuItemConditionNotDeleted(" + tree.getJavascriptTree() + ")");
137
138 ContextMenuItem menuMove = new ContextMenuItem("move");
139 menuMove.setLabel(msgs.get("tree.web.menu.move"));
140 menuMove.setIcon(request.getContextPath() + "/.resources/icons/16/up_down.gif");
141 menuMove.setOnclick(tree.getJavascriptTree() + ".cutNode();");
142 menuMove.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot("
143 + tree.getJavascriptTree()
144 + ")");
145 menuMove.addJavascriptCondition("new mgnlTreeMenuItemConditionPermissionWrite("
146 + tree.getJavascriptTree()
147 + ")");
148 menuMove.addJavascriptCondition("new mgnlTreeMenuItemConditionNotDeleted(" + tree.getJavascriptTree() + ")");
149
150 ContextMenuItem menuCopy = new ContextMenuItem("copy");
151 menuCopy.setLabel(msgs.get("tree.web.menu.copy"));
152 menuCopy.setIcon(request.getContextPath() + "/.resources/icons/16/copy.gif");
153 menuCopy.setOnclick(tree.getJavascriptTree() + ".copyNode();");
154 menuCopy.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot("
155 + tree.getJavascriptTree()
156 + ")");
157 menuCopy.addJavascriptCondition("new mgnlTreeMenuItemConditionNotDeleted(" + tree.getJavascriptTree() + ")");
158
159 ContextMenuItem menuVersions = new ContextMenuItem("versions");
160 menuVersions.setLabel(msgs.get("versions"));
161 menuVersions.setIcon(request.getContextPath() + "/.resources/icons/16/elements1.gif");
162 menuVersions.setOnclick("mgnl.admininterface.WebsiteTree.showVersions(" + tree.getJavascriptTree() + ");");
163 menuVersions.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot("
164 + tree.getJavascriptTree()
165 + ")");
166
167 ContextMenuItem menuActivateExcl = new ContextMenuItem("activate");
168 menuActivateExcl.setLabel(msgs.get("tree.web.menu.activate"));
169 menuActivateExcl.setIcon(request.getContextPath() + "/.resources/icons/16/arrow_right_green.gif");
170
171 menuActivateExcl.setOnclick(tree.getJavascriptTree() + ".activateNode(" + Tree.ACTION_ACTIVATE + ",false);");
172 menuActivateExcl.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot("
173 + tree.getJavascriptTree()
174 + ")");
175 menuActivateExcl.addJavascriptCondition("new mgnlTreeMenuItemConditionPermissionWrite("
176 + tree.getJavascriptTree()
177 + ")");
178
179 ContextMenuItem menuActivateIncl = new ContextMenuItem("activateInclSubs");
180 menuActivateIncl.setLabel(msgs.get("tree.web.menu.activateInclSubs"));
181 menuActivateIncl.setIcon(request.getContextPath() + "/.resources/icons/16/arrow_right_green_double.gif");
182 menuActivateIncl.setOnclick(tree.getJavascriptTree() + ".activateNode(" + Tree.ACTION_ACTIVATE + ",true);");
183 menuActivateIncl.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot("
184 + tree.getJavascriptTree()
185 + ")");
186 menuActivateIncl.addJavascriptCondition("new mgnlTreeMenuItemConditionPermissionWrite("
187 + tree.getJavascriptTree()
188 + ")");
189 menuActivateIncl.addJavascriptCondition("new mgnlTreeMenuItemConditionNotDeleted(" + tree.getJavascriptTree() + ")");
190
191 ContextMenuItem menuDeactivate = new ContextMenuItem("deactivate");
192 menuDeactivate.setLabel(msgs.get("tree.web.menu.deactivate"));
193 menuDeactivate.setIcon(request.getContextPath() + "/.resources/icons/16/arrow_left_red.gif");
194 menuDeactivate.setOnclick(tree.getJavascriptTree() + ".deactivateNode(" + Tree.ACTION_DEACTIVATE + ");");
195 menuDeactivate.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot("
196 + tree.getJavascriptTree()
197 + ")");
198 menuDeactivate.addJavascriptCondition("new mgnlTreeMenuItemConditionPermissionWrite("
199 + tree.getJavascriptTree()
200 + ")");
201 menuDeactivate.addJavascriptCondition("new mgnlTreeMenuItemConditionNotDeleted(" + tree.getJavascriptTree() + ")");
202
203 ContextMenuItem menuExport = new ContextMenuItem("export");
204 menuExport.setLabel(msgs.get("tree.menu.export"));
205 menuExport.setIcon(request.getContextPath() + "/.resources/icons/16/export1.gif");
206 menuExport.setOnclick(tree.getJavascriptTree() + ".exportNode();");
207
208 ContextMenuItem menuImport = new ContextMenuItem("import");
209 menuImport.setLabel(msgs.get("tree.menu.import"));
210 menuImport.setIcon(request.getContextPath() + "/.resources/icons/16/import2.gif");
211 menuImport.setOnclick(tree.getJavascriptTree() + ".importNode(this);");
212
213
214 if (!hasAnyActiveSubscriber()) {
215 menuActivateExcl.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)");
216 menuActivateIncl.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)");
217 menuDeactivate.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)");
218 }
219
220 menuImport.addJavascriptCondition("new mgnlTreeMenuItemConditionPermissionWrite("
221 + tree.getJavascriptTree()
222 + ")");
223 menuImport.addJavascriptCondition("new mgnlTreeMenuItemConditionNotDeleted(" + tree.getJavascriptTree() + ")");
224
225 menuExport.addJavascriptCondition("new mgnlTreeMenuItemConditionPermissionWrite("
226 + tree.getJavascriptTree()
227 + ")");
228 menuExport.addJavascriptCondition("new mgnlTreeMenuItemConditionNotDeleted(" + tree.getJavascriptTree() + ")");
229
230 if (!browseMode) {
231 tree.addMenuItem(menuOpen);
232 tree.addMenuItem(menuNewPage);
233
234 tree.addSeparator();
235 tree.addMenuItem(menuDelete);
236
237 tree.addSeparator();
238 tree.addMenuItem(menuMove);
239 tree.addMenuItem(menuCopy);
240
241 tree.addSeparator();
242 tree.addMenuItem(menuVersions);
243
244 tree.addSeparator();
245 tree.addMenuItem(menuActivateExcl);
246 tree.addMenuItem(menuActivateIncl);
247 tree.addMenuItem(menuDeactivate);
248
249 tree.addSeparator();
250 tree.addMenuItem(menuExport);
251 tree.addMenuItem(menuImport);
252 }
253 else {
254 tree.addMenuItem(ContextMenuItem.getRefreshMenuItem(tree, msgs, request));
255 }
256
257 }
258
259
260
261
262
263 public void prepareFunctionBar(Tree tree, boolean browseMode, HttpServletRequest request) {
264 tree.addFunctionBarItemFromContextMenu("open");
265 tree.addFunctionBarItemFromContextMenu("new");
266 tree.addFunctionBarItem(null);
267 tree.addFunctionBarItemFromContextMenu("activate");
268 tree.addFunctionBarItemFromContextMenu("deactivate");
269 tree.addFunctionBarItem(null);
270
271 tree.addFunctionBarItem(FunctionBarItem.getRefreshFunctionBarItem(tree, getMessages(), request));
272
273 tree.getFunctionBar().setSearchable(true);
274 tree.getFunctionBar().setOnSearchFunction("mgnl.admininterface.WebsiteTree.search");
275 }
276 }