KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > module > admininterface > trees > GroupsTreeConfiguration


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2005 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.module.admininterface.trees;
14
15 import info.magnolia.cms.beans.config.Server;
16 import info.magnolia.cms.beans.config.Subscriber;
17 import info.magnolia.cms.core.ItemType;
18 import info.magnolia.cms.core.MetaData;
19 import info.magnolia.cms.gui.control.ContextMenu;
20 import info.magnolia.cms.gui.control.ContextMenuItem;
21 import info.magnolia.cms.gui.control.FunctionBarItem;
22 import info.magnolia.cms.gui.control.Tree;
23 import info.magnolia.cms.gui.control.TreeColumn;
24 import info.magnolia.cms.i18n.Messages;
25 import info.magnolia.cms.i18n.MessagesManager;
26 import info.magnolia.module.admininterface.AdminTreeConfiguration;
27
28 import javax.servlet.http.HttpServletRequest JavaDoc;
29
30 import org.apache.commons.lang.StringUtils;
31
32
33 /**
34  * @author Philipp Bracher
35  * @version $Revision: 6341 $ ($Author: philipp $)
36  */

37 public class GroupsTreeConfiguration implements AdminTreeConfiguration {
38
39     /**
40      * @see info.magnolia.module.admininterface.AdminTreeConfiguration#prepareTree(info.magnolia.cms.gui.control.Tree,
41      * boolean, javax.servlet.http.HttpServletRequest)
42      */

43     public void prepareTree(Tree tree, boolean browseMode, HttpServletRequest JavaDoc request) {
44         Messages msgs = MessagesManager.getMessages();
45
46         tree.setDrawShifter(false);
47
48         tree.setIcon(ItemType.GROUP.getSystemName(), Tree.ICONDOCROOT + "group.gif"); //$NON-NLS-1$
49
tree.setIconOndblclick("mgnlTreeMenuOpenDialog(" //$NON-NLS-1$
50
+ tree.getJavascriptTree()
51             + ",'.magnolia/dialogs/groupedit.html');"); //$NON-NLS-1$
52
tree.addItemType(ItemType.GROUP);
53
54         TreeColumn column0 = new TreeColumn(tree.getJavascriptTree(), request);
55         column0.setIsLabel(true);
56         column0.setHtmlEdit();
57         column0.setWidth(2);
58         column0.setTitle(msgs.get("tree.groups.name")); //$NON-NLS-1$
59

60         TreeColumn column1 = new TreeColumn(tree.getJavascriptTree(), request);
61         column1.setName("title"); //$NON-NLS-1$
62
column1.setHtmlEdit();
63         column1.setWidth(2);
64         column1.setTitle(msgs.get("tree.groups.fullname")); //$NON-NLS-1$
65

66         TreeColumn columnIcons = new TreeColumn(tree.getJavascriptTree(), request);
67         columnIcons.setCssClass(StringUtils.EMPTY);
68         columnIcons.setWidth(1);
69         columnIcons.setIsIcons(true);
70         columnIcons.setIconsActivation(true);
71
72         TreeColumn column2 = new TreeColumn(tree.getJavascriptTree(), request);
73         column2.setName(MetaData.CREATION_DATE);
74         // column2.setName(MetaData.SEQUENCE_POS);
75
column2.setIsMeta(true);
76         column2.setDateFormat("yyyy-MM-dd, HH:mm"); //$NON-NLS-1$
77
column2.setTitle(msgs.get("tree.groups.date")); //$NON-NLS-1$
78
column2.setWidth(2);
79
80         tree.addColumn(column0);
81         if (!browseMode) {
82             tree.addColumn(column1);
83             if (Server.isAdmin() || Subscriber.isSubscribersEnabled()) {
84                 tree.addColumn(columnIcons);
85             }
86             tree.addColumn(column2);
87         }
88     }
89
90     /**
91      * @see info.magnolia.module.admininterface.AdminTreeConfiguration#prepareContextMenu(info.magnolia.cms.gui.control.Tree,
92      * boolean, javax.servlet.http.HttpServletRequest)
93      */

94     public void prepareContextMenu(Tree tree, boolean browseMode, HttpServletRequest JavaDoc request) {
95         Messages msgs = MessagesManager.getMessages();
96
97         ContextMenuItem menuOpen = new ContextMenuItem("edit");
98         menuOpen.setLabel(msgs.get("tree.groups.menu.edit")); //$NON-NLS-1$
99
menuOpen.setIcon(request.getContextPath() + "/.resources/icons/16/group.gif"); //$NON-NLS-1$
100
menuOpen.setOnclick("mgnlTreeMenuOpenDialog(" //$NON-NLS-1$
101
+ tree.getJavascriptTree()
102             + ",'.magnolia/dialogs/groupedit.html');"); //$NON-NLS-1$
103
menuOpen.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" //$NON-NLS-1$
104
+ tree.getJavascriptTree()
105             + ")"); //$NON-NLS-1$
106

107         ContextMenuItem menuNewPage = new ContextMenuItem("new");
108         menuNewPage.setLabel(msgs.get("tree.groups.menu.new")); //$NON-NLS-1$
109
menuNewPage.setIcon(request.getContextPath() + "/.resources/icons/16/group_add.gif"); //$NON-NLS-1$
110
menuNewPage.setOnclick(tree.getJavascriptTree() + ".createRootNode('" //$NON-NLS-1$
111
+ ItemType.GROUP.getSystemName()
112             + "');"); //$NON-NLS-1$
113

114         ContextMenuItem menuDelete = new ContextMenuItem("delete");
115         menuDelete.setLabel(msgs.get("tree.groups.menu.delete")); //$NON-NLS-1$
116
menuDelete.setIcon(request.getContextPath() + "/.resources/icons/16/delete2.gif"); //$NON-NLS-1$
117
menuDelete.setOnclick(tree.getJavascriptTree() + ".deleteNode();"); //$NON-NLS-1$
118
menuDelete.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" //$NON-NLS-1$
119
+ tree.getJavascriptTree()
120             + ")"); //$NON-NLS-1$
121

122         ContextMenuItem menuMove = new ContextMenuItem("move");
123         menuMove.setLabel(msgs.get("tree.groups.menu.move")); //$NON-NLS-1$
124
menuMove.setIcon(request.getContextPath() + "/.resources/icons/16/up_down.gif"); //$NON-NLS-1$
125
menuMove.setOnclick(tree.getJavascriptTree() + ".cutNode();"); //$NON-NLS-1$
126
menuMove.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" //$NON-NLS-1$
127
+ tree.getJavascriptTree()
128             + ")"); //$NON-NLS-1$
129

130         ContextMenuItem menuCopy = new ContextMenuItem("copy");
131         menuCopy.setLabel(msgs.get("tree.groups.menu.copy")); //$NON-NLS-1$
132
menuCopy.setIcon(request.getContextPath() + "/.resources/icons/16/copy.gif"); //$NON-NLS-1$
133
menuCopy.setOnclick(tree.getJavascriptTree() + ".copyNode();"); //$NON-NLS-1$
134
menuCopy.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" //$NON-NLS-1$
135
+ tree.getJavascriptTree()
136             + ")"); //$NON-NLS-1$
137

138         ContextMenuItem menuActivateExcl = new ContextMenuItem("activate");
139         menuActivateExcl.setLabel(msgs.get("tree.groups.menu.activate")); //$NON-NLS-1$
140
menuActivateExcl.setIcon(request.getContextPath() + "/.resources/icons/16/arrow_right_green.gif"); //$NON-NLS-1$
141
menuActivateExcl.setOnclick(tree.getJavascriptTree() + ".activateNode(" + Tree.ACTION_ACTIVATE + ",false);"); //$NON-NLS-1$ //$NON-NLS-2$
142
menuActivateExcl.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" //$NON-NLS-1$
143
+ tree.getJavascriptTree()
144             + ")"); //$NON-NLS-1$
145

146         ContextMenuItem menuDeActivate = new ContextMenuItem("deactivate");
147         menuDeActivate.setLabel(msgs.get("tree.groups.menu.deactivate")); //$NON-NLS-1$
148
menuDeActivate.setIcon(request.getContextPath() + "/.resources/icons/16/arrow_left_red.gif"); //$NON-NLS-1$
149
menuDeActivate.setOnclick(tree.getJavascriptTree() + ".deActivateNode(" + Tree.ACTION_DEACTIVATE + ");"); //$NON-NLS-1$ //$NON-NLS-2$
150
menuDeActivate.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" //$NON-NLS-1$
151
+ tree.getJavascriptTree()
152             + ")"); //$NON-NLS-1$
153

154         if (!Subscriber.isSubscribersEnabled()) {
155             menuActivateExcl.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)"); //$NON-NLS-1$
156
menuDeActivate.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)"); //$NON-NLS-1$
157
}
158
159         if (!browseMode) {
160             tree.addMenuItem(menuOpen);
161             tree.addMenuItem(menuNewPage);
162
163             tree.addMenuItem(null); // line
164
tree.addMenuItem(menuDelete);
165
166             tree.addMenuItem(null); // line
167
tree.addMenuItem(menuActivateExcl);
168             tree.addMenuItem(menuDeActivate);
169         }
170         else {
171             ContextMenuItem menuRefresh = new ContextMenuItem("refresh");
172             menuRefresh.setLabel(msgs.get("tree.menu.refresh")); //$NON-NLS-1$
173
menuRefresh.setIcon(request.getContextPath() + "/.resources/icons/16/refresh.gif"); //$NON-NLS-1$
174
menuRefresh.setOnclick(tree.getJavascriptTree() + ".refresh();"); //$NON-NLS-1$
175
tree.addMenuItem(menuRefresh);
176         }
177     }
178
179     /**
180      * @see info.magnolia.module.admininterface.AdminTreeConfiguration#prepareFunctionBar(info.magnolia.cms.gui.control.Tree,
181      * boolean, javax.servlet.http.HttpServletRequest)
182      */

183     public void prepareFunctionBar(Tree tree, boolean browseMode, HttpServletRequest JavaDoc request) {
184         // AbstractMessagesImpl msgs = MessagesManager.getMessages();
185
ContextMenu cm = tree.getMenu();
186         ContextMenuItem cmItem = cm.getMenuItemByName("edit");
187         if (cmItem != null) {
188             tree.addFunctionBarItem(new FunctionBarItem(cmItem));
189         }
190         cmItem = cm.getMenuItemByName("new");
191         if (cmItem != null) {
192             tree.addFunctionBarItem(new FunctionBarItem(cmItem));
193         }
194         // null is separator :)
195
tree.addFunctionBarItem(null);
196         cmItem = cm.getMenuItemByName("activate");
197         if (cmItem != null) {
198             tree.addFunctionBarItem(new FunctionBarItem(cmItem));
199         }
200         cmItem = cm.getMenuItemByName("deactivate");
201         if (cmItem != null) {
202             tree.addFunctionBarItem(new FunctionBarItem(cmItem));
203         }
204         tree.addFunctionBarItem(null);
205         ContextMenuItem menuRefresh = new ContextMenuItem("refresh");
206         menuRefresh.setLabel("refresh"); //$NON-NLS-1$
207
menuRefresh.setIcon(request.getContextPath() + "/.resources/icons/16/refresh.gif"); //$NON-NLS-1$
208
menuRefresh.setOnclick(tree.getJavascriptTree() + ".refresh();"); //$NON-NLS-1$
209
tree.addFunctionBarItem(new FunctionBarItem(menuRefresh));
210     }
211
212 }
213
Popular Tags