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.cms.util.NodeNameComparator;
44 import info.magnolia.module.admininterface.AbstractTreeConfiguration;
45
46 import javax.servlet.http.HttpServletRequest;
47
48
49
50
51
52 public class GroupsTreeConfiguration extends AbstractTreeConfiguration {
53
54
55
56
57
58 public void prepareTree(Tree tree, boolean browseMode, HttpServletRequest request) {
59 tree.setSortComparator(new NodeNameComparator());
60
61 tree.setDrawShifter(false);
62
63 tree.setIcon(ItemType.GROUP.getSystemName(), Tree.ICONDOCROOT + "group.gif");
64 tree.setIconOndblclick("mgnlTreeMenuOpenDialog("
65 + tree.getJavascriptTree()
66 + ",'.magnolia/dialogs/groupedit.html');");
67 tree.addItemType(ItemType.GROUP);
68
69 final Messages msgs = getMessages();
70 TreeColumn column0 = TreeColumn.createLabelColumn(tree, msgs.get("tree.groups.name"), !browseMode);
71 column0.setWidth(2);
72
73 TreeColumn column1 = TreeColumn.createNodeDataColumn(tree, msgs.get("tree.groups.fullname"), "title", !browseMode);
74 column1.setWidth(2);
75
76 TreeColumn columnIcons = TreeColumn.createActivationColumn(tree, msgs.get("tree.groups.status"));
77
78 TreeColumn column2 = TreeColumn.createMetaDataColumn(tree, msgs.get("tree.groups.date"), MetaData.LAST_MODIFIED, "yyyy-MM-dd, HH:mm");
79 column2.setWidth(2);
80
81 tree.addColumn(column0);
82 if (!browseMode) {
83 tree.addColumn(column1);
84 if (isAdminInstance() || hasAnyActiveSubscriber()) {
85 tree.addColumn(columnIcons);
86 }
87 tree.addColumn(column2);
88 }
89 }
90
91
92
93
94
95 public void prepareContextMenu(Tree tree, boolean browseMode, HttpServletRequest request) {
96 final Messages msgs = getMessages();
97
98 ContextMenuItem menuOpen = new ContextMenuItem("edit");
99 menuOpen.setLabel(msgs.get("tree.groups.menu.edit"));
100 menuOpen.setIcon(request.getContextPath() + "/.resources/icons/16/group.gif");
101 menuOpen.setOnclick("mgnlTreeMenuOpenDialog("
102 + tree.getJavascriptTree()
103 + ",'.magnolia/dialogs/groupedit.html');");
104 menuOpen.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot("
105 + tree.getJavascriptTree()
106 + ")");
107
108 ContextMenuItem menuNewPage = new ContextMenuItem("new");
109 menuNewPage.setLabel(msgs.get("tree.groups.menu.new"));
110 menuNewPage.setIcon(request.getContextPath() + "/.resources/icons/16/group_add.gif");
111 menuNewPage.setOnclick(tree.getJavascriptTree() + ".createRootNode('"
112 + ItemType.GROUP.getSystemName()
113 + "');");
114
115 ContextMenuItem menuDelete = new ContextMenuItem("delete");
116 menuDelete.setLabel(msgs.get("tree.groups.menu.delete"));
117 menuDelete.setIcon(request.getContextPath() + "/.resources/icons/16/delete2.gif");
118 menuDelete.setOnclick(tree.getJavascriptTree() + ".deleteNode();");
119 menuDelete.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot("
120 + tree.getJavascriptTree()
121 + ")");
122
123 ContextMenuItem menuMove = new ContextMenuItem("move");
124 menuMove.setLabel(msgs.get("tree.groups.menu.move"));
125 menuMove.setIcon(request.getContextPath() + "/.resources/icons/16/up_down.gif");
126 menuMove.setOnclick(tree.getJavascriptTree() + ".cutNode();");
127 menuMove.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot("
128 + tree.getJavascriptTree()
129 + ")");
130
131 ContextMenuItem menuCopy = new ContextMenuItem("copy");
132 menuCopy.setLabel(msgs.get("tree.groups.menu.copy"));
133 menuCopy.setIcon(request.getContextPath() + "/.resources/icons/16/copy.gif");
134 menuCopy.setOnclick(tree.getJavascriptTree() + ".copyNode();");
135 menuCopy.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot("
136 + tree.getJavascriptTree()
137 + ")");
138
139 ContextMenuItem menuActivateExcl = new ContextMenuItem("activate");
140 menuActivateExcl.setLabel(msgs.get("tree.groups.menu.activate"));
141 menuActivateExcl.setIcon(request.getContextPath() + "/.resources/icons/16/arrow_right_green.gif");
142 menuActivateExcl.setOnclick(tree.getJavascriptTree() + ".activateNode(" + Tree.ACTION_ACTIVATE + ",false);");
143 menuActivateExcl.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot("
144 + tree.getJavascriptTree()
145 + ")");
146
147 ContextMenuItem menuDeactivate = new ContextMenuItem("deactivate");
148 menuDeactivate.setLabel(msgs.get("tree.groups.menu.deactivate"));
149 menuDeactivate.setIcon(request.getContextPath() + "/.resources/icons/16/arrow_left_red.gif");
150 menuDeactivate.setOnclick(tree.getJavascriptTree() + ".deactivateNode(" + Tree.ACTION_DEACTIVATE + ");");
151 menuDeactivate.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot("
152 + tree.getJavascriptTree()
153 + ")");
154
155 if (!hasAnyActiveSubscriber()) {
156 menuActivateExcl.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)");
157 menuDeactivate.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)");
158 }
159
160 if (!browseMode) {
161 tree.addMenuItem(menuOpen);
162 tree.addMenuItem(menuNewPage);
163
164 tree.addMenuItem(null);
165 tree.addMenuItem(menuDelete);
166
167 tree.addMenuItem(null);
168 tree.addMenuItem(menuActivateExcl);
169 tree.addMenuItem(menuDeactivate);
170 }
171 else {
172 tree.addMenuItem(ContextMenuItem.getRefreshMenuItem(tree, msgs, request));
173 }
174 }
175
176
177
178
179
180 public void prepareFunctionBar(Tree tree, boolean browseMode, HttpServletRequest request) {
181 tree.addFunctionBarItemFromContextMenu("edit");
182 tree.addFunctionBarItemFromContextMenu("new");
183 tree.addFunctionBarItem(null);
184 tree.addFunctionBarItemFromContextMenu("activate");
185 tree.addFunctionBarItemFromContextMenu("deactivate");
186 tree.addFunctionBarItem(null);
187 tree.addFunctionBarItem(FunctionBarItem.getRefreshFunctionBarItem(tree, getMessages(), request));
188 }
189
190 }