public void main(IWContext iwc) throws Exception { Form myForm = new Form(); myForm.maintainParameter(_PARAMETER_GROUP_ID); int groupId = -1; try { groupId = Integer.parseInt(iwc.getParameter(_PARAMETER_GROUP_ID)); } catch (Exception ex) { // do Nothing } if (iwc.getParameter("commit") != null) { // Save // System.out.println("----------------------------"); // System.out.println("users: "+iwc.getParameterValues(_USERS_RELATED)); UserGroupBusiness.updateUsersInGroup(groupId, iwc.getParameterValues(_USERS_RELATED)); this.setParentToReload(); this.close(); } else { UserList uList = new UserList(_USERS_RELATED); List lDirect = com.idega.core.user.business.UserGroupBusiness.getUsersContainedDirectlyRelated( groupId); Set direct = new HashSet(); if (lDirect != null) { Iterator iter = lDirect.iterator(); while (iter.hasNext()) { User item = (User) iter.next(); direct.add(Integer.toString(item.getGroupID())); } } uList.setDirectlyRelatedUserIds(direct); List lNotDirect = com.idega.core.user.business.UserGroupBusiness.getUsersContainedNotDirectlyRelated( groupId); Set notDirect = new HashSet(); if (lNotDirect != null) { Iterator iter2 = lNotDirect.iterator(); while (iter2.hasNext()) { User item = (User) iter2.next(); notDirect.add(Integer.toString(item.getGroupID())); } } uList.setRelatedUserIdsNotDirectly(notDirect); myForm.add(uList); myForm.add(new SubmitButton("commit", " OK ")); myForm.add(new CloseButton(" Cancel ")); this.add(myForm); } }
private void LineUpElements(IWContext iwc) { Form form = new Form(); Table frameTable = new Table(3, 3); frameTable.setWidth("100%"); frameTable.setHeight("100%"); // frameTable.setBorder(1); SelectionDoubleBox sdb = new SelectionDoubleBox(GroupGroupSetter.FIELDNAME_SELECTION_DOUBLE_BOX, "Not in", "In"); SelectionBox left = sdb.getLeftBox(); left.setHeight(8); left.selectAllOnSubmit(); SelectionBox right = sdb.getRightBox(); right.setHeight(8); right.selectAllOnSubmit(); String stringGroupId = iwc.getParameter(GroupGroupSetter.PARAMETER_GROUP_ID); int groupId = Integer.parseInt(stringGroupId); form.addParameter(GroupGroupSetter.PARAMETER_GROUP_ID, stringGroupId); List directGroups = UserGroupBusiness.getGroupsContainingDirectlyRelated(groupId); Iterator iter = null; if (directGroups != null) { iter = directGroups.iterator(); while (iter.hasNext()) { Object item = iter.next(); right.addElement( Integer.toString(((GenericGroup) item).getID()), ((GenericGroup) item).getName()); } } List notDirectGroups = UserGroupBusiness.getRegisteredGroupsNotDirectlyRelated(groupId, iwc); if (notDirectGroups != null) { iter = notDirectGroups.iterator(); while (iter.hasNext()) { Object item = iter.next(); left.addElement( Integer.toString(((GenericGroup) item).getID()), ((GenericGroup) item).getName()); } } // left.addSeparator(); // right.addSeparator(); frameTable.setAlignment(2, 2, "center"); frameTable.add("GroupId: " + groupId, 2, 1); frameTable.add(sdb, 2, 2); frameTable.add(new SubmitButton(" Save ", "save", "true"), 2, 3); frameTable.add(new CloseButton(" Cancel "), 2, 3); frameTable.setAlignment(2, 3, "right"); form.add(frameTable); this.add(form); }