KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > tools > accounts > A_CmsGroupUsersList


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/accounts/A_CmsGroupUsersList.java,v $
3  * Date : $Date: 2006/03/27 14:52:49 $
4  * Version: $Revision: 1.16 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.workplace.tools.accounts;
33
34 import org.opencms.file.CmsUser;
35 import org.opencms.i18n.CmsMessageContainer;
36 import org.opencms.jsp.CmsJspActionElement;
37 import org.opencms.main.CmsException;
38 import org.opencms.util.CmsUUID;
39 import org.opencms.workplace.list.A_CmsListDialog;
40 import org.opencms.workplace.list.CmsListColumnAlignEnum;
41 import org.opencms.workplace.list.CmsListColumnDefinition;
42 import org.opencms.workplace.list.CmsListItem;
43 import org.opencms.workplace.list.CmsListMetadata;
44 import org.opencms.workplace.list.CmsListOrderEnum;
45
46 import java.io.IOException JavaDoc;
47 import java.util.ArrayList JavaDoc;
48 import java.util.Iterator JavaDoc;
49 import java.util.List JavaDoc;
50 import java.util.Map JavaDoc;
51
52 import javax.servlet.ServletException JavaDoc;
53 import javax.servlet.jsp.JspException JavaDoc;
54
55 /**
56  * Generalized user groups view.<p>
57  *
58  * @author Michael Moossen
59  *
60  * @version $Revision: 1.16 $
61  *
62  * @since 6.0.0
63  */

64 public abstract class A_CmsGroupUsersList extends A_CmsListDialog {
65
66     /** list action id constant. */
67     public static final String JavaDoc LIST_ACTION_ICON = "ai";
68
69     /** list action id constant. */
70     public static final String JavaDoc LIST_ACTION_STATE = "as";
71
72     /** list column id constant. */
73     public static final String JavaDoc LIST_COLUMN_FULLNAME = "cf";
74
75     /** list column id constant. */
76     public static final String JavaDoc LIST_COLUMN_ICON = "ci";
77
78     /** list column id constant. */
79     public static final String JavaDoc LIST_COLUMN_LOGIN = "cn";
80
81     /** list column id constant. */
82     public static final String JavaDoc LIST_COLUMN_STATE = "cs";
83
84     /** Stores the value of the request parameter for the user id. */
85     private String JavaDoc m_paramGroupid;
86
87     /** Stores the value of the request parameter for the user name. */
88     private String JavaDoc m_paramGroupname;
89
90     /**
91      * Public constructor.<p>
92      *
93      * @param jsp an initialized JSP action element
94      * @param listId the id of the list
95      * @param listName the name of the list
96      * @param searchable searchable flag
97      */

98     protected A_CmsGroupUsersList(
99         CmsJspActionElement jsp,
100         String JavaDoc listId,
101         CmsMessageContainer listName,
102         boolean searchable) {
103
104         super(
105             jsp,
106             listId,
107             listName,
108             LIST_COLUMN_LOGIN,
109             CmsListOrderEnum.ORDER_ASCENDING,
110             searchable ? LIST_COLUMN_LOGIN : null);
111     }
112
113     /**
114      * @see org.opencms.workplace.list.A_CmsListDialog#actionDialog()
115      */

116     public void actionDialog() throws JspException JavaDoc, ServletException JavaDoc, IOException JavaDoc {
117
118         updateGroupList();
119         super.actionDialog();
120     }
121
122     /**
123      * Returns the user id parameter value.<p>
124      *
125      * @return the user id parameter value
126      */

127     public String JavaDoc getParamGroupid() {
128
129         return m_paramGroupid;
130     }
131
132     /**
133      * Returns the Group name parameter.<p>
134      *
135      * @return the Group name paramter
136      */

137     public String JavaDoc getParamGroupname() {
138
139         return m_paramGroupname;
140     }
141
142     /**
143      * Sets the user id parameter value.<p>
144      *
145      * @param userId the user id parameter value
146      */

147     public void setParamGroupid(String JavaDoc userId) {
148
149         m_paramGroupid = userId;
150     }
151
152     /**
153      * Updates the main user list.<p>
154      */

155     public void updateGroupList() {
156
157         Map JavaDoc objects = (Map JavaDoc)getSettings().getListObject();
158         if (objects != null) {
159             objects.remove(CmsGroupsList.class.getName());
160             objects.remove(A_CmsUsersList.class.getName());
161         }
162     }
163
164     /**
165      * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String)
166      */

167     protected void fillDetails(String JavaDoc detailId) {
168
169         // noop
170
}
171
172     /**
173      * @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
174      */

175     protected List JavaDoc getListItems() throws CmsException {
176
177         List JavaDoc ret = new ArrayList JavaDoc();
178
179         // get content
180
List JavaDoc users = getUsers();
181         Iterator JavaDoc itUsers = users.iterator();
182         while (itUsers.hasNext()) {
183             CmsUser user = (CmsUser)itUsers.next();
184             CmsListItem item = getList().newItem(user.getId().toString());
185             item.set(LIST_COLUMN_LOGIN, user.getName());
186             item.set(LIST_COLUMN_FULLNAME, user.getFullName());
187             ret.add(item);
188         }
189
190         return ret;
191     }
192
193     /**
194      * Returns a list of users to display.<p>
195      *
196      * @return a list of <code><{@link CmsUser}</code>s
197      *
198      * @throws CmsException if something goes wrong
199      */

200     protected abstract List JavaDoc getUsers() throws CmsException;
201
202     /**
203      * @see org.opencms.workplace.CmsWorkplace#initMessages()
204      */

205     protected void initMessages() {
206
207         // add specific dialog resource bundle
208
addMessages(Messages.get().getBundleName());
209         // add default resource bundles
210
super.initMessages();
211     }
212
213     /**
214      * @see org.opencms.workplace.list.A_CmsListDialog#setColumns(org.opencms.workplace.list.CmsListMetadata)
215      */

216     protected void setColumns(CmsListMetadata metadata) {
217
218         // create column for icon display
219
CmsListColumnDefinition iconCol = new CmsListColumnDefinition(LIST_COLUMN_ICON);
220         iconCol.setName(Messages.get().container(Messages.GUI_USERS_LIST_COLS_ICON_0));
221         iconCol.setHelpText(Messages.get().container(Messages.GUI_USERS_LIST_COLS_ICON_HELP_0));
222         iconCol.setWidth("20");
223         iconCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
224         iconCol.setSorteable(false);
225         // set icon action
226
setIconAction(iconCol);
227         // add it to the list definition
228
metadata.addColumn(iconCol);
229
230         setStateActionCol(metadata);
231
232         // create column for login
233
CmsListColumnDefinition loginCol = new CmsListColumnDefinition(LIST_COLUMN_LOGIN);
234         loginCol.setName(Messages.get().container(Messages.GUI_USERS_LIST_COLS_LOGIN_0));
235         loginCol.setWidth("35%");
236         setDefaultAction(loginCol);
237         // add it to the list definition
238
metadata.addColumn(loginCol);
239
240         // create column for fullname
241
CmsListColumnDefinition fullnameCol = new CmsListColumnDefinition(LIST_COLUMN_FULLNAME);
242         fullnameCol.setName(Messages.get().container(Messages.GUI_USERS_LIST_COLS_FULLNAME_0));
243         fullnameCol.setWidth("65%");
244         fullnameCol.setTextWrapping(true);
245         // add it to the list definition
246
metadata.addColumn(fullnameCol);
247     }
248
249     /**
250      * Sets the optional login default action.<p>
251      *
252      * @param loginCol the login column
253      */

254     protected abstract void setDefaultAction(CmsListColumnDefinition loginCol);
255     
256     /**
257      * Sets the optional state change action column.<p>
258      *
259      * @param metadata the list metadata object
260      */

261     protected abstract void setStateActionCol(CmsListMetadata metadata);
262     
263     /**
264      * Sets the needed icon action(s).<p>
265      *
266      * @param iconCol the list column for edition.
267      */

268     protected abstract void setIconAction(CmsListColumnDefinition iconCol);
269
270     /**
271      * @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
272      */

273     protected void setIndependentActions(CmsListMetadata metadata) {
274
275         // noop
276
}
277
278     /**
279      * @see org.opencms.workplace.list.A_CmsListDialog#validateParamaters()
280      */

281     protected void validateParamaters() throws Exception JavaDoc {
282
283         // test the needed parameters
284
m_paramGroupname = getCms().readGroup(new CmsUUID(getParamGroupid())).getName();
285     }
286 }
Popular Tags