KickJava   Java API By Example, From Geeks To Geeks.

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


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 "users" repository.
34  * @author Fabrizio Giustina
35  * @version $Id: AdminTreeUsers.java 685 2005-05-04 19:23:59Z philipp $
36  */

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

44     public AdminTreeUsers(String JavaDoc name, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) {
45         super(name, request, response);
46     }
47
48     /*
49      * (non-Javadoc)
50      * @see info.magnolia.module.admininterface.AdminTree#prepareTree(info.magnolia.cms.gui.control.Tree,
51      * javax.servlet.http.HttpServletRequest)
52      */

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

108     protected void prepareContextMenu(Tree tree, HttpServletRequest JavaDoc request) {
109         Messages msgs = MessagesManager.getMessages(request);
110         ContextMenuItem menuOpen = new ContextMenuItem();
111         menuOpen.setLabel(msgs.get("tree.users.menu.edit")); //$NON-NLS-1$
112
menuOpen.setIcon(request.getContextPath() + "/admindocroot/icons/16/pawn_glass_yellow.gif"); //$NON-NLS-1$
113
menuOpen.setOnclick("mgnlTreeMenuOpenDialog(" //$NON-NLS-1$
114
+ tree.getJavascriptTree() + ",'.magnolia/dialogs/useredit.html');"); //$NON-NLS-1$
115
menuOpen.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" //$NON-NLS-1$
116
+ tree.getJavascriptTree() + ")"); //$NON-NLS-1$
117
ContextMenuItem menuNewPage = new ContextMenuItem();
118         menuNewPage.setLabel(msgs.get("tree.users.menu.new")); //$NON-NLS-1$
119
menuNewPage.setIcon(request.getContextPath() + "/admindocroot/icons/16/pawn_glass_yellow_add.gif"); //$NON-NLS-1$
120
menuNewPage.setOnclick(tree.getJavascriptTree() + ".createRootNode('" //$NON-NLS-1$
121
+ ItemType.CONTENT.getSystemName() + "');"); //$NON-NLS-1$
122
ContextMenuItem menuDelete = new ContextMenuItem();
123         menuDelete.setLabel(msgs.get("tree.users.menu.delete")); //$NON-NLS-1$
124
menuDelete.setIcon(request.getContextPath() + "/admindocroot/icons/16/delete2.gif"); //$NON-NLS-1$
125
menuDelete.setOnclick(tree.getJavascriptTree() + ".deleteNode();"); //$NON-NLS-1$
126
menuDelete.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" //$NON-NLS-1$
127
+ tree.getJavascriptTree() + ")"); //$NON-NLS-1$
128
ContextMenuItem menuMove = new ContextMenuItem();
129         menuMove.setLabel(msgs.get("tree.users.menu.move")); //$NON-NLS-1$
130
menuMove.setIcon(request.getContextPath() + "/admindocroot/icons/16/up_down.gif"); //$NON-NLS-1$
131
menuMove.setOnclick(tree.getJavascriptTree() + ".cutNode();"); //$NON-NLS-1$
132
menuMove.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" //$NON-NLS-1$
133
+ tree.getJavascriptTree() + ")"); //$NON-NLS-1$
134
ContextMenuItem menuCopy = new ContextMenuItem();
135         menuCopy.setLabel(msgs.get("tree.users.menu.copy")); //$NON-NLS-1$
136
menuCopy.setIcon(request.getContextPath() + "/admindocroot/icons/16/copy.gif"); //$NON-NLS-1$
137
menuCopy.setOnclick(tree.getJavascriptTree() + ".copyNode();"); //$NON-NLS-1$
138
menuCopy.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" //$NON-NLS-1$
139
+ tree.getJavascriptTree() + ")"); //$NON-NLS-1$
140
ContextMenuItem menuActivateExcl = new ContextMenuItem();
141         menuActivateExcl.setLabel(msgs.get("tree.users.menu.activate")); //$NON-NLS-1$
142
menuActivateExcl.setIcon(request.getContextPath() + "/admindocroot/icons/16/arrow_right_green.gif"); //$NON-NLS-1$
143
menuActivateExcl.setOnclick(tree.getJavascriptTree() + ".activateNode(" + Tree.ACTION_ACTIVATE + ",false);"); //$NON-NLS-1$ //$NON-NLS-2$
144
menuActivateExcl.addJavascriptCondition("new mgnlTreeMenuItemConditionSelectedNotRoot(" //$NON-NLS-1$
145
+ tree.getJavascriptTree() + ")"); //$NON-NLS-1$
146
ContextMenuItem menuDeActivate = new ContextMenuItem();
147         menuDeActivate.setLabel(msgs.get("tree.users.menu.deactivate")); //$NON-NLS-1$
148
menuDeActivate.setIcon(request.getContextPath() + "/admindocroot/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() + ")"); //$NON-NLS-1$
152
ContextMenuItem menuRefresh = new ContextMenuItem();
153         menuRefresh.setLabel(msgs.get("tree.menu.refresh")); //$NON-NLS-1$
154
menuRefresh.setIcon(request.getContextPath() + "/admindocroot/icons/16/refresh.gif"); //$NON-NLS-1$
155
menuRefresh.setOnclick(tree.getJavascriptTree() + ".refresh();"); //$NON-NLS-1$
156

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