Search in sources :

Example 41 with TableMultiSelectEvent

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

the class GroupController 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 sourceController, Event event) {
    if (sourceController == tableCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            // Single row selects
            TableEvent te = (TableEvent) event;
            String actionid = te.getActionId();
            final Identity identity = identitiesTableModel.getObject(te.getRowId()).getIdentity();
            if (actionid.equals(COMMAND_VCARD)) {
                // get identity and open new visiting card controller in new window
                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);
            // 
            } else if (actionid.equals(COMMAND_SELECTUSER)) {
                fireEvent(ureq, new SingleIdentityChosenEvent(identity));
            } else if (COMMAND_IM.equals(actionid)) {
                doIm(ureq, identity);
            }
        } else if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
            // Multiselect events
            TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
            if (tmse.getAction().equals(COMMAND_REMOVEUSER)) {
                if (tmse.getSelection().isEmpty()) {
                    // empty selection
                    showWarning("msg.selectionempty");
                    return;
                }
                int size = identitiesTableModel.getObjects().size();
                toRemove = identitiesTableModel.getIdentities(tmse.getSelection());
                // list is never null, but can be empty
                if (keepAtLeastOne && (size == 1 || size - toRemove.size() == 0)) {
                    // at least one must be kept
                    // do not delete the last one => ==1
                    // do not allow to delete all => size - selectedCnt == 0
                    showError("msg.atleastone");
                } else {
                    // valid selection to be deleted.
                    if (removeUserMailDefaultTempl == null) {
                        doBuildConfirmDeleteDialog(ureq);
                    } else {
                        removeAsListenerAndDispose(removeUserMailCtr);
                        removeUserMailCtr = new MailNotificationEditController(getWindowControl(), ureq, removeUserMailDefaultTempl, true, false, true);
                        listenTo(removeUserMailCtr);
                        removeAsListenerAndDispose(cmc);
                        cmc = new CloseableModalController(getWindowControl(), translate("close"), removeUserMailCtr.getInitialComponent());
                        listenTo(cmc);
                        cmc.activate();
                    }
                }
            }
        }
    } else if (sourceController == removeUserMailCtr) {
        if (event == Event.DONE_EVENT) {
            removeUserMailCustomTempl = removeUserMailCtr.getMailTemplate();
            cmc.deactivate();
            doBuildConfirmDeleteDialog(ureq);
        } else {
            cmc.deactivate();
        }
    } else if (sourceController == usc) {
        if (event == Event.CANCELLED_EVENT) {
            cmc.deactivate();
        } else {
            if (event instanceof SingleIdentityChosenEvent) {
                SingleIdentityChosenEvent singleEvent = (SingleIdentityChosenEvent) event;
                Identity choosenIdentity = singleEvent.getChosenIdentity();
                if (choosenIdentity == null) {
                    showError("msg.selectionempty");
                    return;
                }
                toAdd = new ArrayList<Identity>();
                toAdd.add(choosenIdentity);
            } else if (event instanceof MultiIdentityChosenEvent) {
                MultiIdentityChosenEvent multiEvent = (MultiIdentityChosenEvent) event;
                toAdd = multiEvent.getChosenIdentities();
                if (toAdd.size() == 0) {
                    showError("msg.selectionempty");
                    return;
                }
            } else {
                throw new RuntimeException("unknown event ::" + event.getCommand());
            }
            if (toAdd.size() == 1) {
                // check if already in group [makes only sense for a single choosen identity]
                if (securityManager.isIdentityInSecurityGroup(toAdd.get(0), securityGroup)) {
                    String fullName = userManager.getUserDisplayName(toAdd.get(0));
                    getWindowControl().setInfo(translate("msg.subjectalreadyingroup", new String[] { fullName }));
                    return;
                }
            } else if (toAdd.size() > 1) {
                // check if already in group
                List<Identity> alreadyInGroup = new ArrayList<Identity>();
                for (int i = 0; i < toAdd.size(); i++) {
                    if (securityManager.isIdentityInSecurityGroup(toAdd.get(i), securityGroup)) {
                        tableCtr.setMultiSelectSelectedAt(i, false);
                        alreadyInGroup.add(toAdd.get(i));
                    }
                }
                if (!alreadyInGroup.isEmpty()) {
                    StringBuilder names = new StringBuilder();
                    for (Identity ident : alreadyInGroup) {
                        if (names.length() > 0)
                            names.append(", ");
                        names.append(userManager.getUserDisplayName(ident));
                        toAdd.remove(ident);
                    }
                    getWindowControl().setInfo(translate("msg.subjectsalreadyingroup", names.toString()));
                }
                if (toAdd.isEmpty()) {
                    return;
                }
            }
            // in both cases continue adding the users or asking for the mail
            // template if available (=not null)
            cmc.deactivate();
            if (addUserMailDefaultTempl == null) {
                doAddIdentitiesToGroup(ureq, toAdd, null);
            } else {
                removeAsListenerAndDispose(addUserMailCtr);
                addUserMailCtr = new MailNotificationEditController(getWindowControl(), ureq, addUserMailDefaultTempl, true, mandatoryEmail, true);
                listenTo(addUserMailCtr);
                removeAsListenerAndDispose(cmc);
                cmc = new CloseableModalController(getWindowControl(), translate("close"), addUserMailCtr.getInitialComponent());
                listenTo(cmc);
                cmc.activate();
            }
        }
        // in any case cleanup this controller, not used anymore
        usc.dispose();
        usc = null;
    } else if (sourceController == addUserMailCtr) {
        if (event == Event.DONE_EVENT) {
            MailTemplate customTemplate = addUserMailCtr.getMailTemplate();
            doAddIdentitiesToGroup(ureq, toAdd, customTemplate);
            cmc.deactivate();
        } else if (event == Event.CANCELLED_EVENT) {
            cmc.deactivate();
        } else {
            throw new RuntimeException("unknown event ::" + event.getCommand());
        }
    } else if (sourceController == confirmDelete) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            // before deleting, assure it is allowed
            if (!mayModifyMembers)
                throw new AssertException("not allowed to remove member!");
            // list is never null, but can be empty
            // TODO: Theoretically it can happen that the table model here is not accurate!
            // the 'keep at least one' should be handled by the security manager that should
            // synchronizes the method on the group
            int size = identitiesTableModel.getObjects().size();
            if (keepAtLeastOne && (size - toRemove.size() == 0)) {
                showError("msg.atleastone");
            } else {
                doRemoveIdentitiesFromGroup(ureq, toRemove, removeUserMailCustomTempl);
            }
        }
    } else if (sourceController == userToGroupWizard) {
        if (event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            getWindowControl().pop();
            removeAsListenerAndDispose(userToGroupWizard);
            userToGroupWizard = null;
            if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
                reloadData();
            }
        }
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) WindowControl(org.olat.core.gui.control.WindowControl) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) TableEvent(org.olat.core.gui.components.table.TableEvent) UserInfoMainController(org.olat.user.UserInfoMainController) PopupBrowserWindow(org.olat.core.gui.control.generic.popup.PopupBrowserWindow) MailTemplate(org.olat.core.util.mail.MailTemplate) SingleIdentityChosenEvent(org.olat.basesecurity.events.SingleIdentityChosenEvent) List(java.util.List) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity) MailNotificationEditController(org.olat.core.util.mail.MailNotificationEditController) MultiIdentityChosenEvent(org.olat.basesecurity.events.MultiIdentityChosenEvent) UserRequest(org.olat.core.gui.UserRequest)

Example 42 with TableMultiSelectEvent

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

the class WaitingGroupController 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 sourceController, Event event) {
    if (sourceController == tableCtr) {
        if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
            // Multiselect events
            TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
            if (tmse.getAction().equals(COMMAND_MOVE_USER_WAITINGLIST)) {
                if (tmse.getSelection().isEmpty()) {
                    getWindowControl().setWarning(translate("msg.selectionempty"));
                } else {
                    List<Identity> objects = identitiesTableModel.getIdentities(tmse.getSelection());
                    toTransfer = objects;
                    removeAsListenerAndDispose(transferMailCtr);
                    transferMailCtr = new MailNotificationEditController(getWindowControl(), ureq, transferUserMailTempl, true, mandatoryEmail, true);
                    listenTo(transferMailCtr);
                    removeAsListenerAndDispose(cmc);
                    cmc = new CloseableModalController(getWindowControl(), translate("close"), transferMailCtr.getInitialComponent());
                    listenTo(cmc);
                    cmc.activate();
                    // don't execute super method
                    return;
                }
            }
        }
    } else if (sourceController == transferMailCtr) {
        if (event == Event.DONE_EVENT) {
            // fetch configured mail template and finish this controller workflow
            MailTemplate customTransferTemplate = transferMailCtr.getMailTemplate();
            cmc.deactivate();
            IdentitiesMoveEvent identitiesMoveEvent = new IdentitiesMoveEvent(toTransfer);
            identitiesMoveEvent.setMailTemplate(customTransferTemplate);
            fireEvent(ureq, identitiesMoveEvent);
            StringBuilder infoMessage = new StringBuilder();
            for (Identity identity : identitiesMoveEvent.getNotMovedIdentities()) {
                String fullName = userManager.getUserDisplayName(identity);
                infoMessage.append(translate("msg.alreadyinwaiitinggroup", fullName)).append("<br />");
            }
            // report any errors on screen
            if (infoMessage.length() > 0)
                getWindowControl().setInfo(infoMessage.toString());
            // don't execute super method
            return;
        } else if (event == Event.CANCELLED_EVENT) {
            cmc.deactivate();
            // don't execute super method
            return;
        } else {
            throw new RuntimeException("unknown event ::" + event.getCommand());
        }
    }
    // it is no WaitingGroupController event, forward it to super class GroupController
    super.event(ureq, sourceController, event);
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) MailTemplate(org.olat.core.util.mail.MailTemplate) Identity(org.olat.core.id.Identity) MailNotificationEditController(org.olat.core.util.mail.MailNotificationEditController)

Example 43 with TableMultiSelectEvent

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

the class ChecklistAuthorOptionsForm 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) {
    if (source == runChecklistTable) {
        if (event instanceof TableMultiSelectEvent) {
            TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
            selection = tmse.getSelection();
            boolean doUpdate = true;
            int size = visibleCheckpoints.size();
            // check for once editable checkpoints -> show confirmation dialog
            for (int i = 0; i < size; i++) {
                Checkpoint checkpoint = visibleCheckpoints.get(i);
                Boolean selected = checkpoint.getSelectionFor(ureq.getIdentity());
                if (checkpoint.getMode().equals(CheckpointMode.MODE_EDITABLE_ONCE) && selected.booleanValue() != selection.get(i)) {
                    removeAsListenerAndDispose(yesNoDialog);
                    yesNoDialog = DialogBoxUIFactory.createYesNoDialog(ureq, getWindowControl(), translate("dialog.save.title"), translate("dialog.save.text"));
                    listenTo(yesNoDialog);
                    yesNoDialog.activate();
                    doUpdate = false;
                    break;
                }
            }
            // no confirmation necessary, do update immediately
            if (doUpdate)
                updateCheckpoints(ureq);
        }
    } else if (source == yesNoDialog) {
        // do update after confirmation
        if (DialogBoxUIFactory.isYesEvent(event))
            updateCheckpoints(ureq);
        removeAsListenerAndDispose(yesNoDialog);
    } else if (source == authorOptions) {
        if (event == ChecklistAuthorOptionsForm.CONFIG_CHECKPOINT) {
            removeAsListenerAndDispose(editController);
            CheckpointComparator checkpointComparator = null;
            boolean asc = runChecklistTable.getTableSortAsc();
            switch(runChecklistTable.getTableSortCol()) {
                case 1:
                    if (asc) {
                        checkpointComparator = ChecklistUIFactory.comparatorTitleAsc;
                    } else {
                        checkpointComparator = ChecklistUIFactory.comparatorTitleDesc;
                    }
                    break;
                case 2:
                    if (asc) {
                        checkpointComparator = ChecklistUIFactory.comparatorDescriptionAsc;
                    } else {
                        checkpointComparator = ChecklistUIFactory.comparatorDescriptionDesc;
                    }
                    break;
                case 3:
                    if (asc) {
                        checkpointComparator = ChecklistUIFactory.comparatorModeAsc;
                    } else {
                        checkpointComparator = ChecklistUIFactory.comparatorModeDesc;
                    }
                    break;
            }
            editController = ChecklistUIFactory.getInstance().createEditCheckpointsController(ureq, getWindowControl(), checklist, "cl.save.close", checkpointComparator);
            listenTo(editController);
            removeAsListenerAndDispose(cmcEdit);
            cmcEdit = new CloseableModalController(getWindowControl(), translate("cl.close"), editController.getInitialComponent(), true, translate("cl.edit.title"));
            listenTo(cmcEdit);
            cmcEdit.activate();
        } else if (event == ChecklistAuthorOptionsForm.MANAGE_CHECKPOINT) {
            removeAsListenerAndDispose(manageController);
            manageController = new ChecklistManageCheckpointsController(ureq, getWindowControl(), checklist, course, readOnly);
            listenTo(manageController);
            removeAsListenerAndDispose(cmcManage);
            cmcManage = new CloseableModalController(getWindowControl(), translate("cl.close"), manageController.getInitialComponent(), true, translate("cl.manage.title"));
            listenTo(cmcManage);
            cmcManage.activate();
        }
    } else if (source == cmcEdit) {
        initTable(ureq);
    } else if (source == editController) {
        if (event == Event.CHANGED_EVENT | event == Event.CANCELLED_EVENT) {
            initTable(ureq);
            cmcEdit.deactivate();
        }
    } else if (source == cmcManage) {
        initTable(ureq);
    } else if (source == manageController && event == Event.DONE_EVENT) {
        initTable(ureq);
        cmcManage.deactivate();
    }
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent)

Example 44 with TableMultiSelectEvent

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

the class CourseOverviewController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == courseListCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            CourseMemberView item = tableDataModel.getObject(te.getRowId());
            if (TABLE_ACTION_LAUNCH.equals(te.getActionId())) {
                launch(ureq, item.getRepoKey());
            } else if (TABLE_ACTION_UNSUBSCRIBE.equals(te.getActionId())) {
                doLeave(ureq, Collections.singletonList(item));
            } else if (TABLE_ACTION_EDIT.equals(te.getActionId())) {
                doOpenEdit(ureq, item);
            }
        } else if (event instanceof TableMultiSelectEvent) {
            TableMultiSelectEvent mse = (TableMultiSelectEvent) event;
            List<CourseMemberView> items = tableDataModel.getObjects(mse.getSelection());
            if (TABLE_ACTION_UNSUBSCRIBE.equals(mse.getAction())) {
                doLeave(ureq, items);
            }
        }
    } else if (source == repoSearchCtr) {
        SearchType type = (SearchType) repoSearchCtr.getUserObject();
        if (event == ReferencableEntriesSearchController.EVENT_REPOSITORY_ENTRY_SELECTED) {
            // repository search controller done
            RepositoryEntry re = repoSearchCtr.getSelectedEntry();
            removeAsListenerAndDispose(repoSearchCtr);
            cmc.deactivate();
            doConfirmSendEmail(ureq, Collections.singletonList(re), type);
        } else if (event == ReferencableEntriesSearchController.EVENT_REPOSITORY_ENTRIES_SELECTED) {
            // repository search controller done
            List<RepositoryEntry> res = repoSearchCtr.getSelectedEntries();
            removeAsListenerAndDispose(repoSearchCtr);
            cmc.deactivate();
            if (res != null && !res.isEmpty()) {
                doConfirmSendEmail(ureq, res, type);
            }
        }
    } else if (source == editSingleMemberCtrl) {
        cmc.deactivate();
        if (event instanceof MemberPermissionChangeEvent) {
            MemberPermissionChangeEvent e = (MemberPermissionChangeEvent) event;
            RepositoryEntry re = editSingleMemberCtrl.getRepositoryEntry();
            doConfirmChangePermission(ureq, e, re);
        }
    } else if (source == confirmSendMailBox) {
        boolean sendMail = DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event);
        Object confirmation = confirmSendMailBox.getUserObject();
        if (confirmation instanceof ConfirmAdd) {
            ConfirmAdd addInfos = (ConfirmAdd) confirmation;
            doAddToRepositoryEntry(ureq, addInfos.getEntries(), addInfos.getType(), sendMail);
        } else if (confirmation instanceof ConfirmEdit) {
            ConfirmEdit editInfos = (ConfirmEdit) confirmation;
            doChangePermission(ureq, editInfos.getChangeEvent(), editInfos.getEntry(), sendMail);
        }
        updateModel();
    } else if (source == removeFromCourseDlg) {
        if (event == Event.DONE_EVENT) {
            boolean sendMail = removeFromCourseDlg.isSendMail();
            List<BusinessGroup> groupsToDelete = removeFromCourseDlg.getGroupsToDelete();
            List<BusinessGroup> groupsToLeave = removeFromCourseDlg.getGroupsToLeave();
            List<RepositoryEntry> repoEntriesToLeave = removeFromCourseDlg.getRepoEntriesToLeave();
            removeUserFromCourse(ureq, repoEntriesToLeave, groupsToLeave, groupsToDelete, sendMail);
        }
        cmc.deactivate();
        cleanUp();
    } else if (source == cmc) {
        cleanUp();
    }
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) MemberPermissionChangeEvent(org.olat.group.ui.main.MemberPermissionChangeEvent) RepositoryEntry(org.olat.repository.RepositoryEntry) TableEvent(org.olat.core.gui.components.table.TableEvent) List(java.util.List) ArrayList(java.util.ArrayList)

Example 45 with TableMultiSelectEvent

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

the class ReadyToDeleteController method 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);
                UserDeletionManager.getInstance().setIdentityAsActiv(foundIdentity);
                updateUserList();
            }
        } else if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
            TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
            if (tmse.getAction().equals(ACTION_MULTISELECT_CHOOSE)) {
                handleDeleteButtonEvent(ureq, tmse);
            }
        }
    } else if (source == deleteConfirmController) {
        if (DialogBoxUIFactory.isOkEvent(event)) {
            List<String> errors = new ArrayList<String>();
            deleteIdentities(readyToDeleteIdentities, errors);
            if (errors.isEmpty()) {
                showInfo("deleted.feedback.msg");
            } else {
                StringBuilder sb = new StringBuilder();
                for (String error : errors) {
                    if (sb.length() > 0)
                        sb.append(", ");
                    sb.append(error);
                }
                showWarning("error.delete", sb.toString());
            }
            initializeContent();
        }
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) ArrayList(java.util.ArrayList) List(java.util.List) Identity(org.olat.core.id.Identity)

Aggregations

TableMultiSelectEvent (org.olat.core.gui.components.table.TableMultiSelectEvent)48 TableEvent (org.olat.core.gui.components.table.TableEvent)40 ArrayList (java.util.ArrayList)34 List (java.util.List)34 Identity (org.olat.core.id.Identity)18 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)16 BitSet (java.util.BitSet)12 SingleIdentityChosenEvent (org.olat.basesecurity.events.SingleIdentityChosenEvent)10 MultiIdentityChosenEvent (org.olat.basesecurity.events.MultiIdentityChosenEvent)8 UserRequest (org.olat.core.gui.UserRequest)6 WindowControl (org.olat.core.gui.control.WindowControl)6 ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)6 PopupBrowserWindow (org.olat.core.gui.control.generic.popup.PopupBrowserWindow)6 MailNotificationEditController (org.olat.core.util.mail.MailNotificationEditController)6 MailTemplate (org.olat.core.util.mail.MailTemplate)6 UserInfoMainController (org.olat.user.UserInfoMainController)6 MediaResource (org.olat.core.gui.media.MediaResource)4 AssertException (org.olat.core.logging.AssertException)4 MailerResult (org.olat.core.util.mail.MailerResult)4 VFSRevisionMediaResource (org.olat.core.util.vfs.VFSRevisionMediaResource)4