Search in sources :

Example 11 with StepsRunContext

use of org.olat.core.gui.control.generic.wizard.StepsRunContext in project OpenOLAT by OpenOLAT.

the class AbstractBusinessGroupListController method doEmails.

/**
 * @param ureq
 * @param items
 */
private void doEmails(UserRequest ureq, List<? extends BusinessGroupRef> selectedItems) {
    removeAsListenerAndDispose(emailWizard);
    if (selectedItems == null || selectedItems.isEmpty()) {
        showWarning("error.select.one");
        return;
    }
    List<BusinessGroup> groups = toBusinessGroups(ureq, selectedItems, true);
    if (groups.isEmpty()) {
        showWarning("msg.alleastone.editable.group");
        return;
    }
    if (selectedItems.size() != groups.size()) {
        showWarning("msg.only.editable.group");
        return;
    }
    Step start = new BGEmailSelectReceiversStep(ureq, groups);
    StepRunnerCallback finish = new StepRunnerCallback() {

        @Override
        public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) {
            // mails are send by the last controller of the wizard
            return StepsMainRunController.DONE_MODIFIED;
        }
    };
    emailWizard = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("email.group"), "o_sel_groups_email_wizard");
    listenTo(emailWizard);
    getWindowControl().pushAsModalDialog(emailWizard.getInitialComponent());
}
Also used : BGCopyBusinessGroup(org.olat.group.ui.wizard.BGCopyBusinessGroup) BGConfigBusinessGroup(org.olat.group.ui.wizard.BGConfigBusinessGroup) BusinessGroup(org.olat.group.BusinessGroup) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) Step(org.olat.core.gui.control.generic.wizard.Step) BGCopyPreparationStep(org.olat.group.ui.wizard.BGCopyPreparationStep) BGMergeStep(org.olat.group.ui.wizard.BGMergeStep) BGConfigToolsStep(org.olat.group.ui.wizard.BGConfigToolsStep) BGEmailSelectReceiversStep(org.olat.group.ui.wizard.BGEmailSelectReceiversStep) WindowControl(org.olat.core.gui.control.WindowControl) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) BGEmailSelectReceiversStep(org.olat.group.ui.wizard.BGEmailSelectReceiversStep) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) UserRequest(org.olat.core.gui.UserRequest)

Example 12 with StepsRunContext

use of org.olat.core.gui.control.generic.wizard.StepsRunContext in project OpenOLAT by OpenOLAT.

the class AbstractBusinessGroupListController method doCopy.

/**
 * Make copies of a list of business groups
 * @param ureq
 * @param items
 */
private void doCopy(UserRequest ureq, List<? extends BusinessGroupRef> items) {
    removeAsListenerAndDispose(businessGroupWizard);
    if (items == null || items.isEmpty()) {
        showWarning("error.select.one");
        return;
    }
    List<BusinessGroup> groups = toBusinessGroups(ureq, items, true);
    if (groups.isEmpty()) {
        showWarning("msg.alleastone.editable.group");
        return;
    }
    if (items.size() != groups.size()) {
        showWarning("msg.only.editable.group");
        return;
    }
    boolean enableCoursesCopy = businessGroupService.hasResources(groups);
    boolean enableAreasCopy = areaManager.countBGAreasOfBusinessGroups(groups) > 0;
    boolean enableRightsCopy = rightManager.hasBGRight(groups);
    Step start = new BGCopyPreparationStep(ureq, groups, enableCoursesCopy, enableAreasCopy, enableRightsCopy);
    StepRunnerCallback finish = new StepRunnerCallback() {

        @Override
        public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) {
            @SuppressWarnings("unchecked") List<BGCopyBusinessGroup> copies = (List<BGCopyBusinessGroup>) runContext.get("groupsCopy");
            if (copies != null && !copies.isEmpty()) {
                boolean copyAreas = convertToBoolean(runContext, "areas");
                boolean copyCollabToolConfig = convertToBoolean(runContext, "tools");
                boolean copyRights = convertToBoolean(runContext, "rights");
                boolean copyOwners = convertToBoolean(runContext, "owners");
                boolean copyParticipants = convertToBoolean(runContext, "participants");
                boolean copyMemberVisibility = convertToBoolean(runContext, "membersvisibility");
                boolean copyWaitingList = convertToBoolean(runContext, "waitingList");
                boolean copyRelations = convertToBoolean(runContext, "resources");
                for (BGCopyBusinessGroup copy : copies) {
                    businessGroupService.copyBusinessGroup(getIdentity(), copy.getOriginal(), copy.getName(), copy.getDescription(), copy.getMinParticipants(), copy.getMaxParticipants(), copyAreas, copyCollabToolConfig, copyRights, copyOwners, copyParticipants, copyMemberVisibility, copyWaitingList, copyRelations);
                }
                return StepsMainRunController.DONE_MODIFIED;
            } else {
                return StepsMainRunController.DONE_UNCHANGED;
            }
        }
    };
    businessGroupWizard = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("copy.group"), "o_sel_group_copy_wizard");
    listenTo(businessGroupWizard);
    getWindowControl().pushAsModalDialog(businessGroupWizard.getInitialComponent());
}
Also used : BGCopyBusinessGroup(org.olat.group.ui.wizard.BGCopyBusinessGroup) BGCopyBusinessGroup(org.olat.group.ui.wizard.BGCopyBusinessGroup) BGConfigBusinessGroup(org.olat.group.ui.wizard.BGConfigBusinessGroup) BusinessGroup(org.olat.group.BusinessGroup) BGCopyPreparationStep(org.olat.group.ui.wizard.BGCopyPreparationStep) Step(org.olat.core.gui.control.generic.wizard.Step) BGCopyPreparationStep(org.olat.group.ui.wizard.BGCopyPreparationStep) BGMergeStep(org.olat.group.ui.wizard.BGMergeStep) BGConfigToolsStep(org.olat.group.ui.wizard.BGConfigToolsStep) BGEmailSelectReceiversStep(org.olat.group.ui.wizard.BGEmailSelectReceiversStep) WindowControl(org.olat.core.gui.control.WindowControl) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) ContactList(org.olat.core.util.mail.ContactList) List(java.util.List) ArrayList(java.util.ArrayList) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) UserRequest(org.olat.core.gui.UserRequest)

Example 13 with StepsRunContext

use of org.olat.core.gui.control.generic.wizard.StepsRunContext in project OpenOLAT by OpenOLAT.

the class AbstractBusinessGroupListController method doMerge.

/**
 * @param ureq
 * @param items
 */
private void doMerge(UserRequest ureq, List<? extends BusinessGroupRef> selectedItems) {
    removeAsListenerAndDispose(businessGroupWizard);
    if (selectedItems == null || selectedItems.size() < 2) {
        showWarning("error.select.one");
        return;
    }
    final List<BusinessGroup> groups = toBusinessGroups(ureq, selectedItems, true);
    if (groups.size() < 2) {
        showWarning("msg.alleasttwo.editable.group");
        return;
    }
    if (selectedItems.size() != groups.size()) {
        showWarning("msg.only.editable.group");
        return;
    }
    StringBuilder managedNames = new StringBuilder();
    for (BusinessGroup group : groups) {
        String gname = group.getName() == null ? "???" : StringHelper.escapeHtml(group.getName());
        if (StringHelper.containsNonWhitespace(group.getManagedFlagsString())) {
            if (managedNames.length() > 0)
                managedNames.append(", ");
            managedNames.append(gname);
        }
    }
    if (managedNames.length() > 0) {
        showWarning("error.managed.group", managedNames.toString());
        return;
    }
    Step start = new BGMergeStep(ureq, groups);
    StepRunnerCallback finish = new StepRunnerCallback() {

        @Override
        public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) {
            BusinessGroup targetGroup = (BusinessGroup) runContext.get("targetGroup");
            groups.remove(targetGroup);
            businessGroupService.mergeBusinessGroups(getIdentity(), targetGroup, groups, null);
            return StepsMainRunController.DONE_MODIFIED;
        }
    };
    businessGroupWizard = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("merge.group"), "o_sel_groups_merge_wizard");
    listenTo(businessGroupWizard);
    getWindowControl().pushAsModalDialog(businessGroupWizard.getInitialComponent());
}
Also used : BGCopyBusinessGroup(org.olat.group.ui.wizard.BGCopyBusinessGroup) BGConfigBusinessGroup(org.olat.group.ui.wizard.BGConfigBusinessGroup) BusinessGroup(org.olat.group.BusinessGroup) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) Step(org.olat.core.gui.control.generic.wizard.Step) BGCopyPreparationStep(org.olat.group.ui.wizard.BGCopyPreparationStep) BGMergeStep(org.olat.group.ui.wizard.BGMergeStep) BGConfigToolsStep(org.olat.group.ui.wizard.BGConfigToolsStep) BGEmailSelectReceiversStep(org.olat.group.ui.wizard.BGEmailSelectReceiversStep) WindowControl(org.olat.core.gui.control.WindowControl) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) UserRequest(org.olat.core.gui.UserRequest) BGMergeStep(org.olat.group.ui.wizard.BGMergeStep)

Example 14 with StepsRunContext

use of org.olat.core.gui.control.generic.wizard.StepsRunContext in project OpenOLAT by OpenOLAT.

the class BusinessGroupMembersController method doChooseMembers.

private void doChooseMembers(UserRequest ureq) {
    removeAsListenerAndDispose(importMembersWizard);
    Step start = new ImportMember_1b_ChooseMemberStep(ureq, null, businessGroup, false);
    StepRunnerCallback finish = new StepRunnerCallback() {

        @Override
        public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) {
            addMembers(runContext);
            return StepsMainRunController.DONE_MODIFIED;
        }
    };
    importMembersWizard = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("add.member"), "o_sel_group_import_1_wizard");
    listenTo(importMembersWizard);
    getWindowControl().pushAsModalDialog(importMembersWizard.getInitialComponent());
}
Also used : ImportMember_1b_ChooseMemberStep(org.olat.course.member.wizard.ImportMember_1b_ChooseMemberStep) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) ImportMember_1a_LoginListStep(org.olat.course.member.wizard.ImportMember_1a_LoginListStep) Step(org.olat.core.gui.control.generic.wizard.Step) ImportMember_1b_ChooseMemberStep(org.olat.course.member.wizard.ImportMember_1b_ChooseMemberStep) WindowControl(org.olat.core.gui.control.WindowControl) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) UserRequest(org.olat.core.gui.UserRequest)

Example 15 with StepsRunContext

use of org.olat.core.gui.control.generic.wizard.StepsRunContext 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)

Aggregations

StepsRunContext (org.olat.core.gui.control.generic.wizard.StepsRunContext)62 Step (org.olat.core.gui.control.generic.wizard.Step)58 StepRunnerCallback (org.olat.core.gui.control.generic.wizard.StepRunnerCallback)58 StepsMainRunController (org.olat.core.gui.control.generic.wizard.StepsMainRunController)58 UserRequest (org.olat.core.gui.UserRequest)56 WindowControl (org.olat.core.gui.control.WindowControl)56 ArrayList (java.util.ArrayList)16 List (java.util.List)14 ImportMember_1a_LoginListStep (org.olat.course.member.wizard.ImportMember_1a_LoginListStep)12 ImportMember_1b_ChooseMemberStep (org.olat.course.member.wizard.ImportMember_1b_ChooseMemberStep)12 Identity (org.olat.core.id.Identity)10 BusinessGroup (org.olat.group.BusinessGroup)10 QImport_1_InputStep (org.olat.ims.qti21.questionimport.QImport_1_InputStep)10 BGConfigBusinessGroup (org.olat.group.ui.wizard.BGConfigBusinessGroup)8 BGConfigToolsStep (org.olat.group.ui.wizard.BGConfigToolsStep)8 BGCopyBusinessGroup (org.olat.group.ui.wizard.BGCopyBusinessGroup)8 BGCopyPreparationStep (org.olat.group.ui.wizard.BGCopyPreparationStep)8 BGEmailSelectReceiversStep (org.olat.group.ui.wizard.BGEmailSelectReceiversStep)8 BGMergeStep (org.olat.group.ui.wizard.BGMergeStep)8 Export_1_TypeStep (org.olat.modules.qpool.ui.wizard.Export_1_TypeStep)8