KickJava   Java API By Example, From Geeks To Geeks.

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


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.ContextMenuItem;
20 import info.magnolia.cms.gui.control.Tree;
21 import info.magnolia.cms.gui.control.TreeColumn;
22 import info.magnolia.cms.i18n.Messages;
23 import info.magnolia.cms.i18n.MessagesManager;
24 import info.magnolia.module.admininterface.AdminTreeMVCHandler;
25
26 import javax.servlet.http.HttpServletRequest JavaDoc;
27 import javax.servlet.http.HttpServletResponse JavaDoc;
28
29 import org.apache.commons.lang.StringUtils;
30
31
32 /**
33  * Handles the tree rendering for the "roles" repository.
34  * @author Fabrizio Giustina
35  * @version $Id: AdminTreeRoles.java 685 2005-05-04 19:23:59Z philipp $
36  */

37 public class AdminTreeRoles extends AdminTreeMVCHandler {
38
39     /**
40      * @param name
41      * @param request
42      * @param response
43      */

44     public AdminTreeRoles(String JavaDoc name, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) {
45         super(name, request, response);
46     }
47
48     protected void prepareTree(Tree tree, HttpServletRequest JavaDoc request) {
49
50         Messages msgs = MessagesManager.getMessages(request);
51
52         tree.setDrawShifter(false);
53
54         tree.setIconPage(Tree.ICONDOCROOT + "hat_white.gif"); //$NON-NLS-1$
55
if (Server.isAdmin()) {
56             tree.setIconOndblclick("mgnlTreeMenuOpenDialog(" //$NON-NLS-1$
57
+ tree.getJavascriptTree() + ",'.magnolia/dialogs/roleedit.html');"); //$NON-NLS-1$
58
}
59         tree.addItemType(ItemType.CONTENT);
60
61         TreeColumn column0 = new TreeColumn(tree.getJavascriptTree(), request);
62         column0.setIsLabel(true);
63         if (Server.isAdmin()) {
64             column0.setHtmlEdit();
65         }
66         column0.setWidth(2);
67         column0.setTitle(msgs.get("tree.roles.name")); //$NON-NLS-1$
68
TreeColumn column1 = new TreeColumn(tree.getJavascriptTree(), request);
69         column1.setName("title"); //$NON-NLS-1$
70
if (Server.isAdmin()) {
71             column1.setHtmlEdit();
72         }
73         column1.setWidth(2);
74         column1.setTitle(msgs.get("tree.roles.fullname")); //$NON-NLS-1$
75
TreeColumn columnIcons = new TreeColumn(tree.getJavascriptTree(), request);
76         columnIcons.setCssClass(StringUtils.EMPTY);
77         columnIcons.setWidth(1);
78         columnIcons.setIsIcons(true);
79         columnIcons.setIconsActivation(true);
80         TreeColumn column2 = new TreeColumn(tree.getJavascriptTree(), request);
81         column2.setName(MetaData.CREATION_DATE);
82         // column2.setName(MetaData.SEQUENCE_POS);
83
column2.setIsMeta(true);
84         column2.setDateFormat("yyyy-MM-dd, HH:mm"); //$NON-NLS-1$
85
column2.setTitle(msgs.get("tree.roles.date")); //$NON-NLS-1$
86
column2.setWidth(2);
87
88         tree.addColumn(column0);
89         if (!this.isBrowseMode()) {
90             tree.addColumn(column1);
91             if (Server.isAdmin() || Subscriber.isSubscribersEnabled()) {
92                 tree.addColumn(columnIcons);
93             }
94             tree.addColumn(column2);
95         }
96
97     }
98
99     /*
100      * (non-Javadoc)
101      * @see info.magnolia.module.admininterface.AdminTreeMVCHandler#prepareContextMenu(info.magnolia.cms.gui.control.Tree,
102      * javax.servlet.http.HttpServletRequest)
103      */

104     protected void prepareContextMenu(Tree tree, HttpServletRequest JavaDoc request) {
105         Messages msgs = MessagesManager.getMessages(request);
106
107         ContextMenuItem menuOpen = new ContextMenuItem();
108         menuOpen.setLabel(msgs.get("tree.roles.menu.edit")); //$NON-NLS-1$
109
menuOpen.setIcon(request.getContextPath() + "/admindocroot/icons/16/hat_white.gif"); //$NON-NLS-1$
110
menuOpen.setOnclick("mgnlTreeMenuOpenDialog(" //$NON-NLS-1$
111
+ tree.getJavascriptTree() + ",'.magnolia/dialogs/roleedit.html');"); //$NON-NLS-1$
112
menuOpen.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" //$NON-NLS-1$
113
+ tree.getJavascriptTree() + ")"); //$NON-NLS-1$
114
ContextMenuItem menuNewPage = new ContextMenuItem();
115         menuNewPage.setLabel(msgs.get("tree.roles.menu.new")); //$NON-NLS-1$
116
menuNewPage.setIcon(request.getContextPath() + "/admindocroot/icons/16/hat_white_add.gif"); //$NON-NLS-1$
117
menuNewPage.setOnclick(tree.getJavascriptTree() + ".createRootNode('" //$NON-NLS-1$
118
+ ItemType.CONTENT.getSystemName() + "');"); //$NON-NLS-1$
119
ContextMenuItem menuDelete = new ContextMenuItem();
120         menuDelete.setLabel(msgs.get("tree.roles.menu.delete")); //$NON-NLS-1$
121
menuDelete.setIcon(request.getContextPath() + "/admindocroot/icons/16/delete2.gif"); //$NON-NLS-1$
122
menuDelete.setOnclick(tree.getJavascriptTree() + ".deleteNode();"); //$NON-NLS-1$
123
menuDelete.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" //$NON-NLS-1$
124
+ tree.getJavascriptTree() + ")"); //$NON-NLS-1$
125
ContextMenuItem menuMove = new ContextMenuItem();
126         menuMove.setLabel(msgs.get("tree.roles.menu.move")); //$NON-NLS-1$
127
menuMove.setIcon(request.getContextPath() + "/admindocroot/icons/16/up_down.gif"); //$NON-NLS-1$
128
menuMove.setOnclick(tree.getJavascriptTree() + ".cutNode();"); //$NON-NLS-1$
129
menuMove.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" //$NON-NLS-1$
130
+ tree.getJavascriptTree() + ")"); //$NON-NLS-1$
131
ContextMenuItem menuCopy = new ContextMenuItem();
132         menuCopy.setLabel(msgs.get("tree.roles.menu.copy")); //$NON-NLS-1$
133
menuCopy.setIcon(request.getContextPath() + "/admindocroot/icons/16/copy.gif"); //$NON-NLS-1$
134
menuCopy.setOnclick(tree.getJavascriptTree() + ".copyNode();"); //$NON-NLS-1$
135
menuCopy.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" //$NON-NLS-1$
136
+ tree.getJavascriptTree() + ")"); //$NON-NLS-1$
137
ContextMenuItem menuRefresh = new ContextMenuItem();
138         menuRefresh.setLabel(msgs.get("tree.menu.refresh")); //$NON-NLS-1$
139
menuRefresh.setIcon(request.getContextPath() + "/admindocroot/icons/16/refresh.gif"); //$NON-NLS-1$
140
menuRefresh.setOnclick(tree.getJavascriptTree() + ".refresh();"); //$NON-NLS-1$
141

142         ContextMenuItem menuActivateExcl = new ContextMenuItem();
143         menuActivateExcl.setLabel(msgs.get("tree.roles.menu.activate")); //$NON-NLS-1$
144
menuActivateExcl.setIcon(request.getContextPath() + "/admindocroot/icons/16/arrow_right_green.gif"); //$NON-NLS-1$
145
menuActivateExcl.setOnclick(tree.getJavascriptTree() + ".activateNode(" + Tree.ACTION_ACTIVATE + ",false);"); //$NON-NLS-1$ //$NON-NLS-2$
146
menuActivateExcl.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" //$NON-NLS-1$
147
+ tree.getJavascriptTree() + ")"); //$NON-NLS-1$
148
ContextMenuItem menuDeActivate = new ContextMenuItem();
149         menuDeActivate.setLabel(msgs.get("tree.roles.menu.deactivate")); //$NON-NLS-1$
150
menuDeActivate.setIcon(request.getContextPath() + "/admindocroot/icons/16/arrow_left_red.gif"); //$NON-NLS-1$
151
menuDeActivate.setOnclick(tree.getJavascriptTree() + ".deActivateNode(" + Tree.ACTION_DEACTIVATE + ");"); //$NON-NLS-1$ //$NON-NLS-2$
152
menuDeActivate.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" //$NON-NLS-1$
153
+ tree.getJavascriptTree() + ")"); //$NON-NLS-1$
154

155         if (!Server.isAdmin()) {
156             menuOpen.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)"); //$NON-NLS-1$
157
menuNewPage.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)"); //$NON-NLS-1$
158
}
159
160         if (!Subscriber.isSubscribersEnabled()) {
161             menuActivateExcl.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)"); //$NON-NLS-1$
162
menuDeActivate.addJavascriptCondition("new mgnlTreeMenuItemConditionBoolean(false)"); //$NON-NLS-1$
163
}
164
165         if (!this.isBrowseMode()) {
166             tree.addMenuItem(menuOpen);
167             tree.addMenuItem(menuNewPage);
168
169             tree.addMenuItem(null); // line
170
tree.addMenuItem(menuDelete);
171
172             tree.addMenuItem(null); // line
173
tree.addMenuItem(menuActivateExcl);
174             tree.addMenuItem(menuDeActivate);
175
176             tree.addMenuItem(null); // line
177
}
178         tree.addMenuItem(menuRefresh);
179     }
180 }
Popular Tags