KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/accounts/A_CmsUsersList.java,v $
3  * Date : $Date: 2006/03/27 14:52:49 $
4  * Version: $Revision: 1.3 $
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.CmsGroup;
35 import org.opencms.file.CmsUser;
36 import org.opencms.i18n.CmsMessageContainer;
37 import org.opencms.jsp.CmsJspActionElement;
38 import org.opencms.main.CmsException;
39 import org.opencms.main.CmsRuntimeException;
40 import org.opencms.util.CmsUUID;
41 import org.opencms.workplace.CmsDialog;
42 import org.opencms.workplace.list.A_CmsListDialog;
43 import org.opencms.workplace.list.CmsListColumnAlignEnum;
44 import org.opencms.workplace.list.CmsListColumnDefinition;
45 import org.opencms.workplace.list.CmsListDateMacroFormatter;
46 import org.opencms.workplace.list.CmsListDefaultAction;
47 import org.opencms.workplace.list.CmsListDirectAction;
48 import org.opencms.workplace.list.CmsListItem;
49 import org.opencms.workplace.list.CmsListItemActionIconComparator;
50 import org.opencms.workplace.list.CmsListItemDetails;
51 import org.opencms.workplace.list.CmsListItemDetailsFormatter;
52 import org.opencms.workplace.list.CmsListMetadata;
53 import org.opencms.workplace.list.CmsListMultiAction;
54 import org.opencms.workplace.list.CmsListOrderEnum;
55 import org.opencms.workplace.list.CmsListSearchAction;
56
57 import java.io.IOException JavaDoc;
58 import java.util.ArrayList JavaDoc;
59 import java.util.Date JavaDoc;
60 import java.util.HashMap JavaDoc;
61 import java.util.HashSet JavaDoc;
62 import java.util.Iterator JavaDoc;
63 import java.util.List JavaDoc;
64 import java.util.Map JavaDoc;
65 import java.util.Set JavaDoc;
66
67 import javax.servlet.ServletException JavaDoc;
68
69 /**
70  * Main user account management view.<p>
71  *
72  * @author Michael Moossen
73  *
74  * @version $Revision: 1.3 $
75  *
76  * @since 6.0.0
77  */

78 public abstract class A_CmsUsersList extends A_CmsListDialog {
79
80     /** list action id constant. */
81     public static final String JavaDoc LIST_ACTION_ACTIVATE = "aa";
82
83     /** list action id constant. */
84     public static final String JavaDoc LIST_ACTION_DEACTIVATE = "ac";
85
86     /** list action id constant. */
87     public static final String JavaDoc LIST_ACTION_DELETE = "ad";
88
89     /** list action id constant. */
90     public static final String JavaDoc LIST_ACTION_EDIT = "ae";
91
92     /** list action id constant. */
93     public static final String JavaDoc LIST_ACTION_GROUPS = "ag";
94
95     /** list action id constant. */
96     public static final String JavaDoc LIST_ACTION_ROLES = "ar";
97
98     /** list column id constant. */
99     public static final String JavaDoc LIST_COLUMN_ACTIVATE = "ca";
100
101     /** list column id constant. */
102     public static final String JavaDoc LIST_COLUMN_DELETE = "cd";
103
104     /** list column id constant. */
105     public static final String JavaDoc LIST_COLUMN_EDIT = "ce";
106
107     /** list column id constant. */
108     public static final String JavaDoc LIST_COLUMN_EMAIL = "cm";
109
110     /** list column id constant. */
111     public static final String JavaDoc LIST_COLUMN_GROUPS = "cg";
112
113     /** list column id constant. */
114     public static final String JavaDoc LIST_COLUMN_LASTLOGIN = "cl";
115
116     /** list column id constant. */
117     public static final String JavaDoc LIST_COLUMN_LOGIN = "ci";
118
119     /** list column id constant. */
120     public static final String JavaDoc LIST_COLUMN_NAME = "cn";
121
122     /** list column id constant. */
123     public static final String JavaDoc LIST_COLUMN_ROLES = "cr";
124
125     /** list action id constant. */
126     public static final String JavaDoc LIST_DEFACTION_EDIT = "de";
127
128     /** list item detail id constant. */
129     public static final String JavaDoc LIST_DETAIL_ADDRESS = "da";
130
131     /** list item detail id constant. */
132     public static final String JavaDoc LIST_DETAIL_GROUPS = "dg";
133
134     /** list item detail id constant. */
135     public static final String JavaDoc LIST_DETAIL_ROLES = "dr";
136
137     /** list action id constant. */
138     public static final String JavaDoc LIST_MACTION_ACTIVATE = "ma";
139
140     /** list action id constant. */
141     public static final String JavaDoc LIST_MACTION_DEACTIVATE = "mc";
142
143     /** list action id constant. */
144     public static final String JavaDoc LIST_MACTION_DELETE = "md";
145
146     /** Path to the list buttons. */
147     public static final String JavaDoc PATH_BUTTONS = "tools/accounts/buttons/";
148
149     /** a set of action id's to use for deletion. */
150     private static Set JavaDoc m_deleteActionIds = new HashSet JavaDoc();
151
152     /** a set of action id's to use for edition. */
153     private static Set JavaDoc m_editActionIds = new HashSet JavaDoc();
154
155     /**
156      * Public constructor.<p>
157      *
158      * @param jsp an initialized JSP action element
159      * @param listId the id of the list
160      * @param listName the list name
161      */

162     public A_CmsUsersList(CmsJspActionElement jsp, String JavaDoc listId, CmsMessageContainer listName) {
163
164         super(jsp, listId, listName, LIST_COLUMN_LOGIN, CmsListOrderEnum.ORDER_ASCENDING, null);
165     }
166
167     /**
168      * This method should handle every defined list multi action,
169      * by comparing <code>{@link #getParamListAction()}</code> with the id
170      * of the action to execute.<p>
171      *
172      * @throws CmsRuntimeException to signal that an action is not supported
173      *
174      */

175     public void executeListMultiActions() throws CmsRuntimeException {
176
177         if (getParamListAction().equals(LIST_MACTION_DELETE)) {
178             // execute the delete multiaction
179
Map JavaDoc params = new HashMap JavaDoc();
180             params.put(A_CmsEditUserDialog.PARAM_USERID, getParamSelItems());
181             // set action parameter to initial dialog call
182
params.put(CmsDialog.PARAM_ACTION, CmsDialog.DIALOG_INITIAL);
183
184             try {
185                 getToolManager().jspForwardTool(this, getCurrentToolPath() + "/delete", params);
186             } catch (Exception JavaDoc e) {
187                 throw new CmsRuntimeException(Messages.get().container(Messages.ERR_DELETE_SELECTED_USERS_0), e);
188             }
189         } else if (getParamListAction().equals(LIST_MACTION_ACTIVATE)) {
190             // execute the activate multiaction
191
try {
192                 Iterator JavaDoc itItems = getSelectedItems().iterator();
193                 while (itItems.hasNext()) {
194                     CmsListItem listItem = (CmsListItem)itItems.next();
195                     String JavaDoc usrName = listItem.get(LIST_COLUMN_LOGIN).toString();
196                     CmsUser user = readUser(usrName);
197                     if (!user.isEnabled()) {
198                         user.setEnabled(true);
199                         getCms().writeUser(user);
200                     }
201                 }
202             } catch (CmsException e) {
203                 throw new CmsRuntimeException(Messages.get().container(Messages.ERR_ACTIVATE_SELECTED_USERS_0), e);
204             }
205             // refreshing no needed becaus the activate action does not add/remove rows to the list
206
} else if (getParamListAction().equals(LIST_MACTION_DEACTIVATE)) {
207             // execute the activate multiaction
208
try {
209                 Iterator JavaDoc itItems = getSelectedItems().iterator();
210                 while (itItems.hasNext()) {
211                     CmsListItem listItem = (CmsListItem)itItems.next();
212                     String JavaDoc usrName = listItem.get(LIST_COLUMN_LOGIN).toString();
213                     CmsUser user = readUser(usrName);
214                     if (user.isEnabled()) {
215                         user.setEnabled(false);
216                         getCms().writeUser(user);
217                     }
218                 }
219             } catch (CmsException e) {
220                 throw new CmsRuntimeException(Messages.get().container(Messages.ERR_DEACTIVATE_SELECTED_USERS_0), e);
221             }
222             // refreshing no needed becaus the activate action does not add/remove rows to the list
223
} else {
224             throwListUnsupportedActionException();
225         }
226         listSave();
227     }
228
229     /**
230      * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions()
231      */

232     public void executeListSingleActions() throws IOException JavaDoc, ServletException JavaDoc {
233
234         String JavaDoc userId = getSelectedItem().getId();
235         String JavaDoc userName = getSelectedItem().get(LIST_COLUMN_LOGIN).toString();
236
237         Map JavaDoc params = new HashMap JavaDoc();
238         params.put(A_CmsEditUserDialog.PARAM_USERID, userId);
239         // set action parameter to initial dialog call
240
params.put(CmsDialog.PARAM_ACTION, CmsDialog.DIALOG_INITIAL);
241
242         if (getParamListAction().equals(LIST_DEFACTION_EDIT)) {
243             // forward to the edit user screen
244
getToolManager().jspForwardTool(this, getCurrentToolPath() + "/edit", params);
245         } else if (m_editActionIds.contains(getParamListAction())) {
246             getToolManager().jspForwardTool(this, getCurrentToolPath() + "/edit/user", params);
247         } else if (getParamListAction().equals(LIST_ACTION_GROUPS)) {
248             getToolManager().jspForwardTool(this, getCurrentToolPath() + "/edit/groups", params);
249         } else if (getParamListAction().equals(LIST_ACTION_ROLES)) {
250             getToolManager().jspForwardTool(this, getCurrentToolPath() + "/edit/roles", params);
251         } else if (m_deleteActionIds.contains(getParamListAction())) {
252             getToolManager().jspForwardTool(this, getCurrentToolPath() + "/edit/delete", params);
253         } else if (getParamListAction().equals(LIST_ACTION_ACTIVATE)) {
254             // execute the activate action
255
try {
256                 CmsUser user = readUser(userName);
257                 user.setEnabled(true);
258                 getCms().writeUser(user);
259             } catch (CmsException e) {
260                 throw new CmsRuntimeException(Messages.get().container(Messages.ERR_ACTIVATE_USER_1, userName), e);
261             }
262         } else if (getParamListAction().equals(LIST_ACTION_DEACTIVATE)) {
263             // execute the activate action
264
try {
265                 CmsUser user = readUser(userName);
266                 user.setEnabled(false);
267                 getCms().writeUser(user);
268             } catch (CmsException e) {
269                 throw new CmsRuntimeException(Messages.get().container(Messages.ERR_DEACTIVATE_USER_1, userName), e);
270             }
271         } else {
272             throwListUnsupportedActionException();
273         }
274         listSave();
275     }
276
277     /**
278      * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String)
279      */

280     protected void fillDetails(String JavaDoc detailId) {
281
282         // get content
283
List JavaDoc users = getList().getAllContent();
284         Iterator JavaDoc itUsers = users.iterator();
285         while (itUsers.hasNext()) {
286             CmsListItem item = (CmsListItem)itUsers.next();
287             String JavaDoc userName = item.get(LIST_COLUMN_LOGIN).toString();
288             StringBuffer JavaDoc html = new StringBuffer JavaDoc(512);
289             try {
290                 if (detailId.equals(LIST_DETAIL_ADDRESS)) {
291                     CmsUser user = readUser(userName);
292                     // address
293
html.append(user.getAddress());
294                     if (user.getCity() != null) {
295                         html.append("<br>");
296                         if (user.getZipcode() != null) {
297                             html.append(user.getZipcode());
298                             html.append(" ");
299                         }
300                         html.append(user.getCity());
301                     }
302                     if (user.getCountry() != null) {
303                         html.append("<br>");
304                         html.append(user.getCountry());
305                     }
306                 } else if (detailId.equals(LIST_DETAIL_GROUPS)) {
307                     // groups
308
Iterator JavaDoc itGroups = getCms().getGroupsOfUser(userName).iterator();
309                     while (itGroups.hasNext()) {
310                         html.append(((CmsGroup)itGroups.next()).getName());
311                         if (itGroups.hasNext()) {
312                             html.append("<br>");
313                         }
314                         html.append("\n");
315                     }
316                 } else {
317                     continue;
318                 }
319             } catch (Exception JavaDoc e) {
320                 // noop
321
}
322             item.set(detailId, html.toString());
323         }
324     }
325
326     /**
327      * Returns the path the group icon.<p>
328      *
329      * @return the path to the group icon
330      */

331     protected abstract String JavaDoc getGroupIcon();
332
333     /**
334      * @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
335      */

336     protected List JavaDoc getListItems() throws CmsException {
337
338         List JavaDoc ret = new ArrayList JavaDoc();
339         // get content
340
List JavaDoc users = getUsers();
341         Iterator JavaDoc itUsers = users.iterator();
342         while (itUsers.hasNext()) {
343             CmsUser user = (CmsUser)itUsers.next();
344             CmsListItem item = getList().newItem(user.getId().toString());
345             item.set(LIST_COLUMN_LOGIN, user.getName());
346             item.set(LIST_COLUMN_NAME, user.getFullName());
347             item.set(LIST_COLUMN_EMAIL, user.getEmail());
348             item.set(LIST_COLUMN_LASTLOGIN, new Date JavaDoc(user.getLastlogin()));
349             ret.add(item);
350         }
351         return ret;
352     }
353
354     /**
355      * Returns a list of users.<p>
356      *
357      * @return the list of all users
358      *
359      * @throws CmsException if something goes wrong
360      */

361     protected abstract List JavaDoc getUsers() throws CmsException;
362
363     /**
364      * @see org.opencms.workplace.CmsWorkplace#initMessages()
365      */

366     protected void initMessages() {
367
368         // add specific dialog resource bundle
369
addMessages(Messages.get().getBundleName());
370         // add default resource bundles
371
super.initMessages();
372     }
373
374     /**
375      * Reads the user.<p>
376      *
377      * @param name the name of the user to read
378      *
379      * @return the user
380      *
381      * @throws CmsException if something goes wrong
382      */

383     protected abstract CmsUser readUser(String JavaDoc name) throws CmsException;
384
385     /**
386      * @see org.opencms.workplace.list.A_CmsListDialog#setColumns(org.opencms.workplace.list.CmsListMetadata)
387      */

388     protected void setColumns(CmsListMetadata metadata) {
389
390         // create column for edit
391
CmsListColumnDefinition editCol = new CmsListColumnDefinition(LIST_COLUMN_EDIT);
392         editCol.setName(Messages.get().container(Messages.GUI_USERS_LIST_COLS_EDIT_0));
393         editCol.setHelpText(Messages.get().container(Messages.GUI_USERS_LIST_COLS_EDIT_HELP_0));
394         editCol.setWidth("20");
395         editCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
396         editCol.setSorteable(false);
397
398         // add edit action
399
setEditAction(editCol);
400         m_editActionIds.addAll(editCol.getDirectActionIds());
401         // add it to the list definition
402
metadata.addColumn(editCol);
403
404         // create column for group edition
405
CmsListColumnDefinition groupCol = new CmsListColumnDefinition(LIST_COLUMN_GROUPS);
406         groupCol.setName(Messages.get().container(Messages.GUI_USERS_LIST_COLS_GROUPS_0));
407         groupCol.setHelpText(Messages.get().container(Messages.GUI_USERS_LIST_COLS_GROUPS_HELP_0));
408         groupCol.setWidth("20");
409         groupCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
410         groupCol.setSorteable(false);
411         // add groups action
412
CmsListDirectAction groupAction = new CmsListDirectAction(LIST_ACTION_GROUPS);
413         groupAction.setName(Messages.get().container(Messages.GUI_USERS_LIST_ACTION_GROUPS_NAME_0));
414         groupAction.setHelpText(Messages.get().container(Messages.GUI_USERS_LIST_ACTION_GROUPS_HELP_0));
415         groupAction.setIconPath(getGroupIcon());
416         groupCol.addDirectAction(groupAction);
417         // add it to the list definition
418
metadata.addColumn(groupCol);
419
420         // create column for activation/deactivation
421
CmsListColumnDefinition actCol = new CmsListColumnDefinition(LIST_COLUMN_ACTIVATE);
422         actCol.setName(Messages.get().container(Messages.GUI_USERS_LIST_COLS_ACTIVATE_0));
423         actCol.setHelpText(Messages.get().container(Messages.GUI_USERS_LIST_COLS_ACTIVATE_HELP_0));
424         actCol.setWidth("20");
425         actCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
426         actCol.setListItemComparator(new CmsListItemActionIconComparator());
427
428         // activate action
429
CmsListDirectAction actAction = new CmsListDirectAction(LIST_ACTION_ACTIVATE) {
430
431             /**
432              * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible()
433              */

434             public boolean isVisible() {
435
436                 if (getItem() != null) {
437                     String JavaDoc usrId = getItem().getId();
438                     try {
439                         return !getCms().readUser(new CmsUUID(usrId)).isEnabled();
440                     } catch (CmsException e) {
441                         return false;
442                     }
443                 }
444                 return super.isVisible();
445             }
446         };
447         actAction.setName(Messages.get().container(Messages.GUI_USERS_LIST_ACTION_ACTIVATE_NAME_0));
448         actAction.setHelpText(Messages.get().container(Messages.GUI_USERS_LIST_ACTION_ACTIVATE_HELP_0));
449         actAction.setConfirmationMessage(Messages.get().container(Messages.GUI_USERS_LIST_ACTION_ACTIVATE_CONF_0));
450         actAction.setIconPath(ICON_INACTIVE);
451         actCol.addDirectAction(actAction);
452
453         // deactivate action
454
CmsListDirectAction deactAction = new CmsListDirectAction(LIST_ACTION_DEACTIVATE) {
455
456             /**
457              * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible()
458              */

459             public boolean isVisible() {
460
461                 if (getItem() != null) {
462                     String JavaDoc usrId = getItem().getId();
463                     try {
464                         return getCms().readUser(new CmsUUID(usrId)).isEnabled();
465                     } catch (CmsException e) {
466                         return false;
467                     }
468                 }
469                 return super.isVisible();
470             }
471         };
472         deactAction.setName(Messages.get().container(Messages.GUI_USERS_LIST_ACTION_DEACTIVATE_NAME_0));
473         deactAction.setHelpText(Messages.get().container(Messages.GUI_USERS_LIST_ACTION_DEACTIVATE_HELP_0));
474         deactAction.setConfirmationMessage(Messages.get().container(Messages.GUI_USERS_LIST_ACTION_DEACTIVATE_CONF_0));
475         deactAction.setIconPath(ICON_ACTIVE);
476         actCol.addDirectAction(deactAction);
477
478         // add it to the list definition
479
metadata.addColumn(actCol);
480
481         // create column for deletion
482
CmsListColumnDefinition deleteCol = new CmsListColumnDefinition(LIST_COLUMN_DELETE);
483         deleteCol.setName(Messages.get().container(Messages.GUI_USERS_LIST_COLS_DELETE_0));
484         deleteCol.setHelpText(Messages.get().container(Messages.GUI_USERS_LIST_COLS_DELETE_HELP_0));
485         deleteCol.setWidth("20");
486         deleteCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
487         deleteCol.setSorteable(false);
488         // add delete action
489
setDeleteAction(deleteCol);
490         m_deleteActionIds.addAll(deleteCol.getDirectActionIds());
491
492         // add it to the list definition
493
metadata.addColumn(deleteCol);
494
495         // create column for login
496
CmsListColumnDefinition loginCol = new CmsListColumnDefinition(LIST_COLUMN_LOGIN);
497         loginCol.setName(Messages.get().container(Messages.GUI_USERS_LIST_COLS_LOGIN_0));
498         loginCol.setWidth("20%");
499
500         // create default edit action
501
CmsListDefaultAction defEditAction = new CmsListDefaultAction(LIST_DEFACTION_EDIT);
502         defEditAction.setName(Messages.get().container(Messages.GUI_USERS_LIST_DEFACTION_EDIT_NAME_0));
503         defEditAction.setHelpText(Messages.get().container(Messages.GUI_USERS_LIST_DEFACTION_EDIT_HELP_0));
504         loginCol.addDefaultAction(defEditAction);
505
506         // add it to the list definition
507
metadata.addColumn(loginCol);
508
509         // add column for name
510
CmsListColumnDefinition nameCol = new CmsListColumnDefinition(LIST_COLUMN_NAME);
511         nameCol.setName(Messages.get().container(Messages.GUI_USERS_LIST_COLS_USERNAME_0));
512         nameCol.setWidth("30%");
513         metadata.addColumn(nameCol);
514
515         // add column for email
516
CmsListColumnDefinition emailCol = new CmsListColumnDefinition(LIST_COLUMN_EMAIL);
517         emailCol.setName(Messages.get().container(Messages.GUI_USERS_LIST_COLS_EMAIL_0));
518         emailCol.setWidth("30%");
519         metadata.addColumn(emailCol);
520
521         // add column for last login date
522
CmsListColumnDefinition lastLoginCol = new CmsListColumnDefinition(LIST_COLUMN_LASTLOGIN);
523         lastLoginCol.setName(Messages.get().container(Messages.GUI_USERS_LIST_COLS_LASTLOGIN_0));
524         lastLoginCol.setWidth("20%");
525         lastLoginCol.setFormatter(CmsListDateMacroFormatter.getDefaultDateFormatter());
526         metadata.addColumn(lastLoginCol);
527     }
528
529     /**
530      * Sets the needed delete action(s).<p>
531      *
532      * @param deleteCol the list column for deletion.
533      */

534     protected abstract void setDeleteAction(CmsListColumnDefinition deleteCol);
535
536     /**
537      * Sets the needed edit action(s).<p>
538      *
539      * @param editCol the list column for edition.
540      */

541     protected abstract void setEditAction(CmsListColumnDefinition editCol);
542
543     /**
544      * @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
545      */

546     protected void setIndependentActions(CmsListMetadata metadata) {
547
548         // add user address details
549
CmsListItemDetails userAddressDetails = new CmsListItemDetails(LIST_DETAIL_ADDRESS);
550         userAddressDetails.setAtColumn(LIST_COLUMN_LOGIN);
551         userAddressDetails.setVisible(false);
552         userAddressDetails.setShowActionName(Messages.get().container(Messages.GUI_USERS_DETAIL_SHOW_ADDRESS_NAME_0));
553         userAddressDetails.setShowActionHelpText(Messages.get().container(Messages.GUI_USERS_DETAIL_SHOW_ADDRESS_HELP_0));
554         userAddressDetails.setHideActionName(Messages.get().container(Messages.GUI_USERS_DETAIL_HIDE_ADDRESS_NAME_0));
555         userAddressDetails.setHideActionHelpText(Messages.get().container(Messages.GUI_USERS_DETAIL_HIDE_ADDRESS_HELP_0));
556         userAddressDetails.setName(Messages.get().container(Messages.GUI_USERS_DETAIL_ADDRESS_NAME_0));
557         userAddressDetails.setFormatter(new CmsListItemDetailsFormatter(Messages.get().container(
558             Messages.GUI_USERS_DETAIL_ADDRESS_NAME_0)));
559         metadata.addItemDetails(userAddressDetails);
560
561         // add user groups details
562
CmsListItemDetails userGroupsDetails = new CmsListItemDetails(LIST_DETAIL_GROUPS);
563         userGroupsDetails.setAtColumn(LIST_COLUMN_LOGIN);
564         userGroupsDetails.setVisible(false);
565         userGroupsDetails.setShowActionName(Messages.get().container(Messages.GUI_USERS_DETAIL_SHOW_GROUPS_NAME_0));
566         userGroupsDetails.setShowActionHelpText(Messages.get().container(Messages.GUI_USERS_DETAIL_SHOW_GROUPS_HELP_0));
567         userGroupsDetails.setHideActionName(Messages.get().container(Messages.GUI_USERS_DETAIL_HIDE_GROUPS_NAME_0));
568         userGroupsDetails.setHideActionHelpText(Messages.get().container(Messages.GUI_USERS_DETAIL_HIDE_GROUPS_HELP_0));
569         userGroupsDetails.setName(Messages.get().container(Messages.GUI_USERS_DETAIL_GROUPS_NAME_0));
570         userGroupsDetails.setFormatter(new CmsListItemDetailsFormatter(Messages.get().container(
571             Messages.GUI_USERS_DETAIL_GROUPS_NAME_0)));
572         metadata.addItemDetails(userGroupsDetails);
573
574         // makes the list searchable
575
CmsListSearchAction searchAction = new CmsListSearchAction(metadata.getColumnDefinition(LIST_COLUMN_LOGIN));
576         searchAction.addColumn(metadata.getColumnDefinition(LIST_COLUMN_NAME));
577         metadata.setSearchAction(searchAction);
578     }
579
580     /**
581      * @see org.opencms.workplace.list.A_CmsListDialog#setMultiActions(org.opencms.workplace.list.CmsListMetadata)
582      */

583     protected void setMultiActions(CmsListMetadata metadata) {
584
585         // add delete multi action
586
CmsListMultiAction deleteMultiAction = new CmsListMultiAction(LIST_MACTION_DELETE);
587         deleteMultiAction.setName(Messages.get().container(Messages.GUI_USERS_LIST_MACTION_DELETE_NAME_0));
588         deleteMultiAction.setHelpText(Messages.get().container(Messages.GUI_USERS_LIST_MACTION_DELETE_HELP_0));
589         deleteMultiAction.setConfirmationMessage(Messages.get().container(Messages.GUI_USERS_LIST_MACTION_DELETE_CONF_0));
590         deleteMultiAction.setIconPath(ICON_MULTI_DELETE);
591         metadata.addMultiAction(deleteMultiAction);
592
593         // add the activate user multi action
594
CmsListMultiAction activateUser = new CmsListMultiAction(LIST_MACTION_ACTIVATE);
595         activateUser.setName(Messages.get().container(Messages.GUI_USERS_LIST_MACTION_ACTIVATE_NAME_0));
596         activateUser.setHelpText(Messages.get().container(Messages.GUI_USERS_LIST_MACTION_ACTIVATE_HELP_0));
597         activateUser.setConfirmationMessage(Messages.get().container(Messages.GUI_USERS_LIST_MACTION_ACTIVATE_CONF_0));
598         activateUser.setIconPath(ICON_MULTI_ACTIVATE);
599         metadata.addMultiAction(activateUser);
600
601         // add the deactivate user multi action
602
CmsListMultiAction deactivateUser = new CmsListMultiAction(LIST_MACTION_DEACTIVATE);
603         deactivateUser.setName(Messages.get().container(Messages.GUI_USERS_LIST_MACTION_DEACTIVATE_NAME_0));
604         deactivateUser.setHelpText(Messages.get().container(Messages.GUI_USERS_LIST_MACTION_DEACTIVATE_HELP_0));
605         deactivateUser.setConfirmationMessage(Messages.get().container(
606             Messages.GUI_USERS_LIST_MACTION_DEACTIVATE_CONF_0));
607         deactivateUser.setIconPath(ICON_MULTI_DEACTIVATE);
608         metadata.addMultiAction(deactivateUser);
609     }
610 }
Popular Tags