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 UsersTreeConfiguration 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(true);
62
63
64 tree.setIcon(ItemType.USER.getSystemName(), Tree.ICONDOCROOT + "pawn_glass_yellow.gif");
65 tree.setIconOndblclick("mgnlTreeMenuOpenDialog(" + tree.getJavascriptTree()
66
67 + ",'.magnolia/dialogs/useredit.html');");
68 tree.addItemType(ItemType.USER);
69
70 tree.addItemType("nt:folder", Tree.ICONDOCROOT + "folder_inactive.gif");
71 tree.addItemType(ItemType.NT_FOLDER, Tree.ICONDOCROOT + "folder.gif");
72
73 final Messages msgs = getMessages();
74 TreeColumn column0 = TreeColumn.createLabelColumn(tree, msgs.get("tree.users.name"), !browseMode);
75 column0.setWidth(2);
76
77 TreeColumn column1 = TreeColumn.createNodeDataColumn(tree, msgs.get("tree.users.fullname"), "title", !browseMode);
78 column1.setWidth(2);
79
80 TreeColumn columnIcons = TreeColumn.createActivationColumn(tree, msgs.get("tree.users.status"));
81
82 TreeColumn column2 = TreeColumn.createMetaDataColumn(tree, msgs.get("tree.users.date"), MetaData.LAST_MODIFIED, "yyyy-MM-dd, HH:mm");
83 column2.setWidth(2);
84
85 tree.addColumn(column0);
86 if (!browseMode) {
87 tree.addColumn(column1);
88 if (isAdminInstance() || hasAnyActiveSubscriber()) {
89 tree.addColumn(columnIcons);
90 }
91 tree.addColumn(column2);
92 }
93 }
94
95
96
97
98
99 public void prepareContextMenu(Tree tree, boolean browseMode, HttpServletRequest request) {
100 final Messages msgs = getMessages();
101
102
103 ContextMenuItem menuNewFolder = new ContextMenuItem("newFolder");
104 menuNewFolder.setLabel(msgs.get("tree.users.menu.newFolder"));
105 menuNewFolder.setIcon(request.getContextPath() + "/.resources/icons/16/folder_add.gif");
106 menuNewFolder.setOnclick(tree.getJavascriptTree() + ".createNode('"
107 + ItemType.NT_FOLDER + "');");
108
109 menuNewFolder.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotItemType("
110 + tree.getJavascriptTree()
111 + ", '" + ItemType.USER.getSystemName() + "')");
112
113
114 ContextMenuItem menuOpen = new ContextMenuItem("edit");
115 menuOpen.setLabel(msgs.get("tree.users.menu.edit"));
116 menuOpen.setIcon(request.getContextPath() + "/.resources/icons/16/pawn_glass_yellow.gif");
117 menuOpen.setOnclick("mgnlTreeMenuOpenDialog("
118 + tree.getJavascriptTree()
119 + ",'.magnolia/dialogs/useredit.html');");
120 menuOpen.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedItemType("
121 + tree.getJavascriptTree()
122 + ",'mgnl:user')");
123
124 ContextMenuItem menuNew = new ContextMenuItem("new");
125 menuNew.setLabel(msgs.get("tree.users.menu.new"));
126 menuNew.setIcon(request.getContextPath() + "/.resources/icons/16/pawn_glass_yellow_add.gif");
127 menuNew.setOnclick(tree.getJavascriptTree() + ".createNode('"
128 + ItemType.USER.getSystemName()
129 + "');");
130 menuNew.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotItemType("
131 + tree.getJavascriptTree() + ","
132 + "'" + ItemType.USER.getSystemName() + "'"
133 + ")");
134
135 ContextMenuItem menuDelete = new ContextMenuItem("delete");
136 menuDelete.setLabel(msgs.get("tree.users.menu.delete"));
137 menuDelete.setIcon(request.getContextPath() + "/.resources/icons/16/delete2.gif");
138 menuDelete.setOnclick(tree.getJavascriptTree() + ".deleteNode();");
139 menuDelete.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot("
140 + tree.getJavascriptTree()
141 + ")");
142
143 ContextMenuItem menuMove = new ContextMenuItem("move");
144 menuMove.setLabel(msgs.get("tree.users.menu.move"));
145 menuMove.setIcon(request.getContextPath() + "/.resources/icons/16/up_down.gif");
146 menuMove.setOnclick(tree.getJavascriptTree() + ".cutNode();");
147 menuMove.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot("
148 + tree.getJavascriptTree()
149 + ")");
150
151 ContextMenuItem menuCopy = new ContextMenuItem("copy");
152 menuCopy.setLabel(msgs.get("tree.users.menu.copy"));
153 menuCopy.setIcon(request.getContextPath() + "/.resources/icons/16/copy.gif");
154 menuCopy.setOnclick(tree.getJavascriptTree() + ".copyNode();");
155 menuCopy.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot("
156 + tree.getJavascriptTree()
157 + ")");
158
159 ContextMenuItem menuActivateExcl = new ContextMenuItem("activate");
160 menuActivateExcl.setLabel(msgs.get("tree.users.menu.activate"));
161 menuActivateExcl.setIcon(request.getContextPath() + "/.resources/icons/16/arrow_right_green.gif");
162 menuActivateExcl.setOnclick(tree.getJavascriptTree() + ".activateNode(" + Tree.ACTION_ACTIVATE + ",false);");
163 menuActivateExcl.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot("
164 + tree.getJavascriptTree()
165 + ")");
166
167 ContextMenuItem menuDeactivate = new ContextMenuItem("deactivate");
168 menuDeactivate.setLabel(msgs.get("tree.users.menu.deactivate"));
169 menuDeactivate.setIcon(request.getContextPath() + "/.resources/icons/16/arrow_left_red.gif");
170 menuDeactivate.setOnclick(tree.getJavascriptTree() + ".deactivateNode(" + Tree.ACTION_DEACTIVATE + ");");
171 menuDeactivate.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot("
172 + tree.getJavascriptTree()
173 + ")");
174
175 if (!hasAnyActiveSubscriber()) {
176 menuActivateExcl.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)");
177 menuDeactivate.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)");
178 }
179
180 if (!browseMode) {
181 tree.addMenuItem(menuOpen);
182 if(!tree.getRootPath().equals("/system")){
183 tree.addMenuItem(menuNew);
184 tree.addMenuItem(menuNewFolder);
185 tree.addMenuItem(null);
186 tree.addMenuItem(menuDelete);
187 }
188 tree.addMenuItem(null);
189 tree.addMenuItem(menuActivateExcl);
190 tree.addMenuItem(menuDeactivate);
191 }
192 else {
193 tree.addMenuItem(ContextMenuItem.getRefreshMenuItem(tree, msgs, request));
194 }
195 }
196
197
198
199
200
201 public void prepareFunctionBar(Tree tree, boolean browseMode, HttpServletRequest request) {
202 tree.addFunctionBarItemFromContextMenu("edit");
203 if(!tree.getRootPath().equals("/system")){
204 tree.addFunctionBarItemFromContextMenu("new");
205 tree.addFunctionBarItemFromContextMenu("newFolder");
206 }
207 tree.addFunctionBarItem(null);
208 tree.addFunctionBarItemFromContextMenu("activate");
209 tree.addFunctionBarItemFromContextMenu("deactivate");
210 tree.addFunctionBarItem(null);
211
212 tree.addFunctionBarItem(FunctionBarItem.getRefreshFunctionBarItem(tree, getMessages(), request));
213 }
214
215 }