Search in sources :

Example 51 with TableEvent

use of org.olat.core.gui.components.table.TableEvent in project openolat by klemens.

the class UsermanagerUserSearchForm method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == searchform) {
        if (event == Event.DONE_EVENT) {
            // form validation was ok
            identitiesList = findIdentitiesFromSearchForm();
            initUserListCtr(ureq, identitiesList, null);
            userListVC.put("userlist", tableCtr.getInitialComponent());
            userListVC.contextPut("emptyList", (identitiesList.size() == 0 ? Boolean.TRUE : Boolean.FALSE));
            panel.setContent(userListVC);
            // fxdiff BAKS-7 Resume function
            ContextEntry currentEntry = getWindowControl().getBusinessControl().getCurrentContextEntry();
            if (currentEntry != null) {
                currentEntry.setTransientState(searchform.getStateEntry());
            }
            addToHistory(ureq, tableCtr);
        } else if (event == Event.CANCELLED_EVENT) {
            fireEvent(ureq, Event.CANCELLED_EVENT);
        }
    } else if (source == tableCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            String actionid = te.getActionId();
            if (actionid.equals(ExtendedIdentitiesTableDataModel.COMMAND_SELECTUSER)) {
                int rowid = te.getRowId();
                Identity foundIdentity = tdm.getObject(rowid);
                // Tell parentController that a subject has been found
                fireEvent(ureq, new SingleIdentityChosenEvent(foundIdentity));
            } else if (actionid.equals(ExtendedIdentitiesTableDataModel.COMMAND_VCARD)) {
                // get identity and open new visiting card controller in new window
                int rowid = te.getRowId();
                final Identity identity = tdm.getObject(rowid);
                ControllerCreator userInfoMainControllerCreator = new ControllerCreator() {

                    @Override
                    public Controller createController(UserRequest lureq, WindowControl lwControl) {
                        return new UserInfoMainController(lureq, lwControl, identity, true, false);
                    }
                };
                // wrap the content controller into a full header layout
                ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, userInfoMainControllerCreator);
                // open in new browser window
                PopupBrowserWindow pbw = getWindowControl().getWindowBackOffice().getWindowManager().createNewPopupBrowserWindowFor(ureq, layoutCtrlr);
                pbw.open(ureq);
            }
        }
        if (event instanceof TableMultiSelectEvent) {
            // Multiselect events
            TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
            if (tmse.getAction().equals(CMD_BULKEDIT)) {
                if (tmse.getSelection().isEmpty()) {
                    // empty selection
                    showWarning("msg.selectionempty");
                    return;
                }
                selectedIdentities = tdm.getIdentities(tmse.getSelection());
                // valid selection: load in wizard
                Step start = new UserBulkChangeStep00(ureq, selectedIdentities);
                // callback executed in case wizard is finished.
                StepRunnerCallback finish = new StepRunnerCallback() {

                    public Step execute(UserRequest ureq1, WindowControl wControl1, StepsRunContext runContext) {
                        // all information to do now is within the runContext saved
                        boolean hasChanges = false;
                        try {
                            if (runContext.containsKey("validChange") && ((Boolean) runContext.get("validChange")).booleanValue()) {
                                HashMap<String, String> attributeChangeMap = (HashMap<String, String>) runContext.get("attributeChangeMap");
                                HashMap<String, String> roleChangeMap = (HashMap<String, String>) runContext.get("roleChangeMap");
                                List<Long> ownGroups = (List<Long>) runContext.get("ownerGroups");
                                List<Long> partGroups = (List<Long>) runContext.get("partGroups");
                                // List<Long> mailGroups = (List<Long>) runContext.get("mailGroups");
                                if (attributeChangeMap.size() != 0 || roleChangeMap.size() != 0 || ownGroups.size() != 0 || partGroups.size() != 0) {
                                    Identity addingIdentity = ureq1.getIdentity();
                                    ubcMan.changeSelectedIdentities(selectedIdentities, attributeChangeMap, roleChangeMap, notUpdatedIdentities, isAdministrativeUser, ownGroups, partGroups, getTranslator(), addingIdentity);
                                    hasChanges = true;
                                }
                            }
                        } catch (Exception any) {
                        // return new ErrorStep
                        }
                        // signal correct completion and tell if changes were made or not.
                        return hasChanges ? StepsMainRunController.DONE_MODIFIED : StepsMainRunController.DONE_UNCHANGED;
                    }
                };
                removeAsListenerAndDispose(userBulkChangeStepsController);
                userBulkChangeStepsController = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("bulkChange.title"), "o_sel_user_bulk_change_wizard");
                listenTo(userBulkChangeStepsController);
                getWindowControl().pushAsModalDialog(userBulkChangeStepsController.getInitialComponent());
            } else if (tmse.getAction().equals(CMD_MAIL)) {
                if (tmse.getSelection().isEmpty()) {
                    // empty selection
                    showWarning("msg.selectionempty");
                    return;
                }
                // create e-mail message
                ContactMessage cmsg = new ContactMessage(ureq.getIdentity());
                selectedIdentities = tdm.getIdentities(tmse.getSelection());
                ContactList contacts = new ContactList(translate("mailto.userlist"));
                contacts.addAllIdentites(selectedIdentities);
                cmsg.addEmailTo(contacts);
                // create contact form controller with ContactMessage
                removeAsListenerAndDispose(contactCtr);
                contactCtr = new ContactFormController(ureq, getWindowControl(), true, false, false, cmsg);
                listenTo(contactCtr);
                mailVC.put("mailform", contactCtr.getInitialComponent());
                panel.setContent(mailVC);
            }
        }
    } else if (source == contactCtr) {
        // in any case go back to list (events: done, failed or cancel)
        panel.setContent(userListVC);
    } else if (source == userBulkChangeStepsController) {
        if (event == Event.CANCELLED_EVENT) {
            getWindowControl().pop();
        } else if (event == Event.CHANGED_EVENT) {
            getWindowControl().pop();
            Integer selIdentCount = selectedIdentities.size();
            if (notUpdatedIdentities.size() > 0) {
                Integer notUpdatedIdentCount = notUpdatedIdentities.size();
                Integer sucChanges = selIdentCount - notUpdatedIdentCount;
                String changeErrors = "";
                for (String err : notUpdatedIdentities) {
                    changeErrors += err + "<br />";
                }
                getWindowControl().setError(translate("bulkChange.partialsuccess", new String[] { sucChanges.toString(), selIdentCount.toString(), changeErrors }));
            } else {
                showInfo("bulkChange.success");
            }
            // update table model - has changed
            reloadDataModel(ureq);
        } else if (event == Event.DONE_EVENT) {
            showError("bulkChange.failed");
        }
    }
}
Also used : HashMap(java.util.HashMap) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) Step(org.olat.core.gui.control.generic.wizard.Step) WindowControl(org.olat.core.gui.control.WindowControl) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) ContextEntry(org.olat.core.id.context.ContextEntry) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) PopupBrowserWindow(org.olat.core.gui.control.generic.popup.PopupBrowserWindow) ContactFormController(org.olat.modules.co.ContactFormController) ContactList(org.olat.core.util.mail.ContactList) List(java.util.List) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity) UserRequest(org.olat.core.gui.UserRequest) ContactList(org.olat.core.util.mail.ContactList) UserBulkChangeStep00(org.olat.admin.user.bulkChange.UserBulkChangeStep00) ContactMessage(org.olat.core.util.mail.ContactMessage) TableEvent(org.olat.core.gui.components.table.TableEvent) UserInfoMainController(org.olat.user.UserInfoMainController) SingleIdentityChosenEvent(org.olat.basesecurity.events.SingleIdentityChosenEvent) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback)

Example 52 with TableEvent

use of org.olat.core.gui.components.table.TableEvent in project openolat by klemens.

the class UserAuthenticationsEditorController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == confirmationDialog) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            Authentication auth = (Authentication) confirmationDialog.getUserObject();
            securityManager.deleteAuthentication(auth);
            getWindowControl().setInfo(getTranslator().translate("authedit.delete.success", new String[] { auth.getProvider(), changeableIdentity.getName() }));
            authTableModel.setObjects(securityManager.getAuthentications(changeableIdentity));
            tableCtr.modelChanged();
        }
    } else if (source == tableCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            String actionid = te.getActionId();
            if (actionid.equals("delete")) {
                int rowid = te.getRowId();
                Authentication auth = authTableModel.getObject(rowid);
                String fullname = userManager.getUserDisplayName(changeableIdentity);
                String msg = translate("authedit.delete.confirm", new String[] { auth.getProvider(), fullname });
                confirmationDialog = activateYesNoDialog(ureq, null, msg, confirmationDialog);
                confirmationDialog.setUserObject(auth);
            }
        }
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) Authentication(org.olat.basesecurity.Authentication)

Example 53 with TableEvent

use of org.olat.core.gui.components.table.TableEvent in project openolat by klemens.

the class UserSearchController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == tableCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            if (te.getActionId().equals(ACTION_SINGLESELECT_CHOOSE)) {
                int rowid = te.getRowId();
                Identity foundIdentity = tdm.getObject(rowid);
                foundIdentities.add(foundIdentity);
                // Tell parentController that a subject has been found
                fireEvent(ureq, new SingleIdentityChosenEvent(foundIdentity));
            }
        } else if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
            TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
            if (tmse.getAction().equals(ACTION_MULTISELECT_CHOOSE)) {
                foundIdentities = tdm.getObjects(tmse.getSelection());
                fireEvent(ureq, new MultiIdentityChosenEvent(foundIdentities));
            }
        }
    } else if (source == autocompleterC) {
        if (event instanceof EntriesChosenEvent) {
            EntriesChosenEvent ece = (EntriesChosenEvent) event;
            List<String> res = ece.getEntries();
            // if we get the event, we have a result or an incorrect selection see OLAT-5114 -> check for empty
            String mySel = res.isEmpty() ? null : (String) res.get(0);
            if ((mySel == null) || mySel.trim().equals("")) {
                getWindowControl().setWarning(translate("error.search.form.notempty"));
                return;
            }
            // default not found
            Long key = -1l;
            try {
                key = Long.valueOf(mySel);
                if (key > 0) {
                    Identity chosenIdent = BaseSecurityManager.getInstance().loadIdentityByKey(key);
                    // No need to check for null, exception is thrown when identity does not exist which really
                    // should not happen at all.
                    // Tell that an identity has been chosen
                    fireEvent(ureq, new SingleIdentityChosenEvent(chosenIdent));
                }
            } catch (NumberFormatException e) {
                getWindowControl().setWarning(translate("error.no.user.found"));
                return;
            }
        }
    } else if (source == searchform) {
        if (event == Event.DONE_EVENT) {
            // form validation was ok
            doSearch(ureq);
        } else if (event == Event.CANCELLED_EVENT) {
            fireEvent(ureq, Event.CANCELLED_EVENT);
        }
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) SingleIdentityChosenEvent(org.olat.basesecurity.events.SingleIdentityChosenEvent) ArrayList(java.util.ArrayList) List(java.util.List) Identity(org.olat.core.id.Identity) MultiIdentityChosenEvent(org.olat.basesecurity.events.MultiIdentityChosenEvent) EntriesChosenEvent(org.olat.core.gui.control.generic.ajax.autocompletion.EntriesChosenEvent)

Example 54 with TableEvent

use of org.olat.core.gui.components.table.TableEvent in project openolat by klemens.

the class GroupOverviewController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    super.event(ureq, source, event);
    if (source == groupListCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            GroupOverviewRow item = tableDataModel.getObject(te.getRowId());
            BusinessGroup currBusinessGroup = businessGroupService.loadBusinessGroup(item.getKey());
            if (currBusinessGroup == null) {
                // group seems to be removed meanwhile, reload table and show error
                showError("group.removed");
                updateModel();
            } else if (TABLE_ACTION_LAUNCH.equals(te.getActionId())) {
                NewControllerFactory.getInstance().launch("[BusinessGroup:" + currBusinessGroup.getKey() + "]", ureq, getWindowControl());
            } else if (TABLE_ACTION_UNSUBSCRIBE.equals(te.getActionId())) {
                doLeave(ureq, Collections.singletonList(currBusinessGroup));
            }
        } else if (event instanceof TableMultiSelectEvent) {
            TableMultiSelectEvent mse = (TableMultiSelectEvent) event;
            List<GroupOverviewRow> items = tableDataModel.getObjects(mse.getSelection());
            if (TABLE_ACTION_UNSUBSCRIBE.equals(mse.getAction())) {
                List<BusinessGroup> groups = toBusinessGroups(items);
                doLeave(ureq, groups);
            }
        }
    } else if (source == groupsCtrl && event instanceof AddToGroupsEvent) {
        AddToGroupsEvent groupsEv = (AddToGroupsEvent) event;
        if (groupsEv.isEmpty()) {
            // no groups selected
            showWarning("group.add.result.none");
        } else {
            if (cmc != null) {
                cmc.deactivate();
            }
            boolean mailMandatory = groupModule.isMandatoryEnrolmentEmail(ureq.getUserSession().getRoles());
            if (mailMandatory) {
                doAddToGroups(groupsEv, true);
                updateModel();
            } else {
                confirmSendMailBox = activateYesNoDialog(ureq, null, translate("dialog.modal.bg.send.mail"), confirmSendMailBox);
                confirmSendMailBox.setUserObject(groupsEv);
            }
        }
        cleanUpPopups();
    } else if (source == confirmSendMailBox) {
        boolean sendMail = DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event);
        AddToGroupsEvent groupsEv = (AddToGroupsEvent) confirmSendMailBox.getUserObject();
        doAddToGroups(groupsEv, sendMail);
        updateModel();
    } else if (source == removeFromGrpDlg) {
        if (event == Event.DONE_EVENT) {
            boolean sendMail = removeFromGrpDlg.isSendMail();
            List<BusinessGroup> groupsToDelete = removeFromGrpDlg.getGroupsToDelete();
            List<BusinessGroup> groupsToLeave = removeFromGrpDlg.getGroupsToLeave();
            removeUserFromGroup(ureq, groupsToLeave, groupsToDelete, sendMail);
        }
        cmc.deactivate();
        cleanUpPopups();
    } else if (source == cmc) {
        cleanUpPopups();
    }
}
Also used : AddToGroupsEvent(org.olat.group.model.AddToGroupsEvent) TableEvent(org.olat.core.gui.components.table.TableEvent) BusinessGroup(org.olat.group.BusinessGroup) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) ArrayList(java.util.ArrayList) List(java.util.List)

Example 55 with TableEvent

use of org.olat.core.gui.components.table.TableEvent in project openolat by klemens.

the class OrphanVersionsController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == tableCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            String actionid = te.getActionId();
            int rowid = te.getRowId();
            OrphanVersion orphan = (OrphanVersion) tableCtr.getTableDataModel().getObject(rowid);
            if (actionid.equals(CMD_DELETE)) {
                VersionsManager.getInstance().delete(orphan);
                orphans.remove(orphan);
                tableCtr.modelChanged();
            }
        } else if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
            // Multiselect events
            TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
            BitSet selectedOrphans = tmse.getSelection();
            String actionid = tmse.getAction();
            if (CMD_DELETE.equals(actionid)) {
                List<OrphanVersion> toRemove = new ArrayList<OrphanVersion>();
                for (int i = selectedOrphans.nextSetBit(0); i >= 0; i = selectedOrphans.nextSetBit(i + 1)) {
                    int rowCount = tableCtr.getTableDataModel().getRowCount();
                    if (i >= 0 && i < rowCount) {
                        OrphanVersion orphan = (OrphanVersion) tableCtr.getTableDataModel().getObject(i);
                        VersionsManager.getInstance().delete(orphan);
                        toRemove.add(orphan);
                    }
                }
                for (OrphanVersion orphan : toRemove) {
                    orphans.remove(orphan);
                }
                tableCtr.setTableDataModel(new OrphanTableModel(orphans));
                tableCtr.modelChanged();
            }
        }
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) BitSet(java.util.BitSet) ArrayList(java.util.ArrayList) List(java.util.List) OrphanVersion(org.olat.core.util.vfs.version.OrphanVersion)

Aggregations

TableEvent (org.olat.core.gui.components.table.TableEvent)114 ArrayList (java.util.ArrayList)42 List (java.util.List)40 TableMultiSelectEvent (org.olat.core.gui.components.table.TableMultiSelectEvent)40 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)16 Identity (org.olat.core.id.Identity)16 BitSet (java.util.BitSet)12 WindowControl (org.olat.core.gui.control.WindowControl)12 SingleIdentityChosenEvent (org.olat.basesecurity.events.SingleIdentityChosenEvent)10 UserRequest (org.olat.core.gui.UserRequest)10 ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)10 PopupBrowserWindow (org.olat.core.gui.control.generic.popup.PopupBrowserWindow)10 MultiIdentityChosenEvent (org.olat.basesecurity.events.MultiIdentityChosenEvent)8 BusinessGroup (org.olat.group.BusinessGroup)8 RepositoryEntry (org.olat.repository.RepositoryEntry)8 AssertException (org.olat.core.logging.AssertException)6 UserInfoMainController (org.olat.user.UserInfoMainController)6 KalendarEvent (org.olat.commons.calendar.model.KalendarEvent)4 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)4 Subscriber (org.olat.core.commons.services.notifications.Subscriber)4