1 31 32 package org.opencms.workplace.tools.accounts; 33 34 import org.opencms.jsp.CmsJspActionElement; 35 import org.opencms.main.CmsException; 36 import org.opencms.main.CmsRuntimeException; 37 import org.opencms.workplace.list.CmsListColumnAlignEnum; 38 import org.opencms.workplace.list.CmsListColumnDefinition; 39 import org.opencms.workplace.list.CmsListDefaultAction; 40 import org.opencms.workplace.list.CmsListDirectAction; 41 import org.opencms.workplace.list.CmsListItem; 42 import org.opencms.workplace.list.CmsListMetadata; 43 import org.opencms.workplace.list.CmsListMultiAction; 44 45 import java.util.HashSet ; 46 import java.util.Iterator ; 47 import java.util.List ; 48 import java.util.Set ; 49 50 import javax.servlet.http.HttpServletRequest ; 51 import javax.servlet.http.HttpServletResponse ; 52 import javax.servlet.jsp.PageContext ; 53 54 63 public class CmsGroupUsersList extends A_CmsGroupUsersList { 64 65 66 public static final String LIST_ACTION_REMOVE = "ar"; 67 68 69 public static final String LIST_DEFACTION_REMOVE = "dr"; 70 71 72 public static final String LIST_ID = "lgu"; 73 74 75 public static final String LIST_MACTION_REMOVE = "mr"; 76 77 78 protected static Set m_removeActionIds = new HashSet (); 79 80 85 public CmsGroupUsersList(CmsJspActionElement jsp) { 86 87 this(jsp, LIST_ID); 88 } 89 90 97 public CmsGroupUsersList(PageContext context, HttpServletRequest req, HttpServletResponse res) { 98 99 this(new CmsJspActionElement(context, req, res)); 100 } 101 102 107 protected CmsGroupUsersList(CmsJspActionElement jsp, String listId) { 108 109 super(jsp, listId, Messages.get().container(Messages.GUI_GROUPUSERS_LIST_NAME_0), true); 110 } 111 112 115 public void executeListMultiActions() throws CmsRuntimeException { 116 117 if (getParamListAction().equals(LIST_MACTION_REMOVE)) { 118 Iterator itItems = getSelectedItems().iterator(); 120 while (itItems.hasNext()) { 121 CmsListItem listItem = (CmsListItem)itItems.next(); 122 String userName = (String )listItem.get(LIST_COLUMN_LOGIN); 123 try { 124 getCms().removeUserFromGroup(userName, getParamGroupname()); 125 } catch (CmsException e) { 126 } 128 } 129 } else { 130 throwListUnsupportedActionException(); 131 } 132 listSave(); 133 } 134 135 138 public void executeListSingleActions() throws CmsRuntimeException { 139 140 if (m_removeActionIds.contains(getParamListAction())) { 141 CmsListItem listItem = getSelectedItem(); 142 try { 143 getCms().removeUserFromGroup((String )listItem.get(LIST_COLUMN_LOGIN), getParamGroupname()); 144 } catch (CmsException e) { 145 throw new CmsRuntimeException(Messages.get().container(Messages.ERR_REMOVE_SELECTED_GROUP_0), e); 147 } 148 } else { 149 throwListUnsupportedActionException(); 150 } 151 listSave(); 152 } 153 154 157 protected List getUsers() throws CmsException { 158 159 return getCms().getUsersOfGroup(getParamGroupname()); 160 } 161 162 165 protected void setDefaultAction(CmsListColumnDefinition loginCol) { 166 167 CmsListDefaultAction removeAction = new CmsListDefaultAction(LIST_DEFACTION_REMOVE); 169 removeAction.setName(Messages.get().container(Messages.GUI_USERS_LIST_DEFACTION_REMOVE_NAME_0)); 170 removeAction.setHelpText(Messages.get().container(Messages.GUI_USERS_LIST_DEFACTION_REMOVE_HELP_0)); 171 loginCol.addDefaultAction(removeAction); 172 m_removeActionIds.add(removeAction.getId()); 174 } 175 176 179 protected void setIconAction(CmsListColumnDefinition iconCol) { 180 181 CmsListDirectAction iconAction = new CmsListDirectAction(LIST_ACTION_ICON); 182 iconAction.setName(Messages.get().container(Messages.GUI_USERS_LIST_INGROUP_NAME_0)); 183 iconAction.setHelpText(Messages.get().container(Messages.GUI_USERS_LIST_INGROUP_HELP_0)); 184 iconAction.setIconPath(A_CmsUsersList.PATH_BUTTONS + "user.png"); 185 iconAction.setEnabled(false); 186 iconCol.addDirectAction(iconAction); 187 } 188 189 192 protected void setMultiActions(CmsListMetadata metadata) { 193 194 CmsListMultiAction removeMultiAction = new CmsListMultiAction(LIST_MACTION_REMOVE); 196 removeMultiAction.setName(Messages.get().container(Messages.GUI_USERS_LIST_MACTION_REMOVE_NAME_0)); 197 removeMultiAction.setHelpText(Messages.get().container(Messages.GUI_USERS_LIST_MACTION_REMOVE_HELP_0)); 198 removeMultiAction.setConfirmationMessage(Messages.get().container(Messages.GUI_USERS_LIST_MACTION_REMOVE_CONF_0)); 199 removeMultiAction.setIconPath(ICON_MULTI_MINUS); 200 metadata.addMultiAction(removeMultiAction); 201 } 202 203 206 protected void setStateActionCol(CmsListMetadata metadata) { 207 208 CmsListColumnDefinition stateCol = new CmsListColumnDefinition(LIST_COLUMN_STATE); 210 stateCol.setName(Messages.get().container(Messages.GUI_USERS_LIST_COLS_STATE_0)); 211 stateCol.setHelpText(Messages.get().container(Messages.GUI_USERS_LIST_COLS_STATE_HELP_0)); 212 stateCol.setWidth("20"); 213 stateCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER); 214 stateCol.setSorteable(false); 215 CmsListDirectAction stateAction = new CmsListDirectAction(LIST_ACTION_REMOVE); 217 stateAction.setName(Messages.get().container(Messages.GUI_USERS_LIST_DEFACTION_REMOVE_NAME_0)); 218 stateAction.setHelpText(Messages.get().container(Messages.GUI_USERS_LIST_DEFACTION_REMOVE_HELP_0)); 219 stateAction.setIconPath(ICON_MINUS); 220 stateCol.addDirectAction(stateAction); 221 metadata.addColumn(stateCol); 223 m_removeActionIds.add(stateAction.getId()); 225 } 226 } 227 | Popular Tags |