Search in sources :

Example 71 with ControllerCreator

use of org.olat.core.gui.control.creator.ControllerCreator in project openolat by klemens.

the class NotesPortletRunController method event.

/**
 * @see org.olat.core.gui.control.ControllerEventListener#dispatchEvent(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) {
    super.event(ureq, source, event);
    if (source == tableCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            String actionid = te.getActionId();
            if (actionid.equals(CMD_LAUNCH)) {
                int rowid = te.getRowId();
                final NotePortletEntry pe = (NotePortletEntry) notesListModel.getObject(rowid);
                final Note note = pe.getValue();
                // will not be disposed on course run dispose, popus up as new browserwindow
                ControllerCreator ctrlCreator = new ControllerCreator() {

                    public Controller createController(UserRequest lureq, WindowControl lwControl) {
                        Controller nc = new NoteController(lureq, lwControl, note);
                        // use on column layout
                        LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, lwControl, nc);
                        // dispose content on layout dispose
                        layoutCtr.addDisposableChildController(nc);
                        return layoutCtr;
                    }
                };
                // wrap the content controller into a full header layout
                ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, ctrlCreator);
                // open in new browser window
                PopupBrowserWindow pbw = getWindowControl().getWindowBackOffice().getWindowManager().createNewPopupBrowserWindowFor(ureq, layoutCtrlr);
                pbw.open(ureq);
            // 
            }
        }
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) PopupBrowserWindow(org.olat.core.gui.control.generic.popup.PopupBrowserWindow) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) WindowControl(org.olat.core.gui.control.WindowControl) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) AbstractPortletRunController(org.olat.core.gui.control.generic.portal.AbstractPortletRunController) Controller(org.olat.core.gui.control.Controller) TableController(org.olat.core.gui.components.table.TableController) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) UserRequest(org.olat.core.gui.UserRequest)

Example 72 with ControllerCreator

use of org.olat.core.gui.control.creator.ControllerCreator in project openolat by klemens.

the class ParticipantLecturesOverviewController method doPrint.

private void doPrint(UserRequest ureq) {
    ControllerCreator printControllerCreator = new ControllerCreator() {

        @Override
        public Controller createController(UserRequest lureq, WindowControl lwControl) {
            lwControl.getWindowBackOffice().getChiefController().addBodyCssClass("o_lectures_print");
            Controller printCtrl = new ParticipantLecturesOverviewController(lureq, lwControl, assessedIdentity, false, false, false, true);
            listenTo(printCtrl);
            return printCtrl;
        }
    };
    ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createPrintPopupLayout(printControllerCreator);
    openInNewBrowserWindow(ureq, layoutCtrlr);
}
Also used : WindowControl(org.olat.core.gui.control.WindowControl) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) Controller(org.olat.core.gui.control.Controller) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) UserRequest(org.olat.core.gui.UserRequest)

Example 73 with ControllerCreator

use of org.olat.core.gui.control.creator.ControllerCreator 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 74 with ControllerCreator

use of org.olat.core.gui.control.creator.ControllerCreator in project openolat by klemens.

the class MembersAvatarDisplayRunController method doPrint.

private void doPrint(UserRequest ureq) {
    ControllerCreator printControllerCreator = new ControllerCreator() {

        @Override
        public Controller createController(UserRequest lureq, WindowControl lwControl) {
            lwControl.getWindowBackOffice().getChiefController().addBodyCssClass("o_cmembers_print");
            return new MembersPrintController(lureq, lwControl, getTranslator(), owners, coaches, participants, waiting, showOwners, showCoaches, showParticipants, showWaiting, courseEnv != null ? courseEnv.getCourseTitle() : businessGroup.getName());
        }
    };
    ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createPrintPopupLayout(printControllerCreator);
    openInNewBrowserWindow(ureq, layoutCtrlr);
}
Also used : WindowControl(org.olat.core.gui.control.WindowControl) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) UserRequest(org.olat.core.gui.UserRequest)

Example 75 with ControllerCreator

use of org.olat.core.gui.control.creator.ControllerCreator in project openolat by klemens.

the class BaseFullWebappMinimalLayoutControllerCreator method getFullWebappParts.

/**
 * @see org.olat.core.commons.fullWebApp.popup.BaseFullWebappPopupLayout#getFullWebappParts()
 */
@Override
public BaseFullWebappControllerParts getFullWebappParts() {
    return new BaseFullWebappControllerParts() {

        @Override
        public List<SiteInstance> getSiteInstances(UserRequest ureq, WindowControl control) {
            // no static sites
            return null;
        }

        @Override
        public Controller getContentController(UserRequest ureq, WindowControl wControl) {
            // the content for the Pop-up Window
            return contentControllerCreator.createController(ureq, wControl);
        }

        @Override
        public LockableController createTopNavController(UserRequest ureq, WindowControl wControl) {
            LockableController topnavCtr = null;
            // ----------- topnav, optional (e.g. for imprint, logout) ------------------
            if (CoreSpringFactory.containsBean("fullWebApp.MinimalTopNavControllerCreator")) {
                ControllerCreator topnavControllerCreator = (ControllerCreator) CoreSpringFactory.getBean("fullWebApp.MinimalTopNavControllerCreator");
                topnavCtr = (LockableController) topnavControllerCreator.createController(ureq, wControl);
            }
            return topnavCtr;
        }

        @Override
        public Controller createHeaderController(UserRequest ureq, WindowControl control) {
            Controller headerCtr = null;
            // ----------- header, optional (e.g. for logo, advertising ) ------------------
            if (CoreSpringFactory.containsBean("fullWebApp.MinimalHeaderControllerCreator")) {
                ControllerCreator headerControllerCreator = (ControllerCreator) CoreSpringFactory.getBean("fullWebApp.MinimalHeaderControllerCreator");
                headerCtr = headerControllerCreator.createController(ureq, control);
            }
            return headerCtr;
        }

        @Override
        public LockableController createFooterController(UserRequest ureq, WindowControl control) {
            Controller footerCtr = null;
            // ----------- footer, optional (e.g. for copyright, powerd by) ------------------
            if (CoreSpringFactory.containsBean("fullWebApp.MinimalFooterControllerCreator")) {
                ControllerCreator footerCreator = (ControllerCreator) CoreSpringFactory.getBean("fullWebApp.MinimalFooterControllerCreator");
                footerCtr = footerCreator.createController(ureq, control);
            }
            return (LockableController) footerCtr;
        }
    };
}
Also used : SiteInstance(org.olat.core.gui.control.navigation.SiteInstance) LockableController(org.olat.core.commons.fullWebApp.LockableController) BaseFullWebappControllerParts(org.olat.core.commons.fullWebApp.BaseFullWebappControllerParts) WindowControl(org.olat.core.gui.control.WindowControl) LockableController(org.olat.core.commons.fullWebApp.LockableController) Controller(org.olat.core.gui.control.Controller) UserRequest(org.olat.core.gui.UserRequest) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator)

Aggregations

ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)92 UserRequest (org.olat.core.gui.UserRequest)72 WindowControl (org.olat.core.gui.control.WindowControl)72 Controller (org.olat.core.gui.control.Controller)42 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)28 PopupBrowserWindow (org.olat.core.gui.control.generic.popup.PopupBrowserWindow)28 LockableController (org.olat.core.commons.fullWebApp.LockableController)20 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)12 Identity (org.olat.core.id.Identity)12 ArrayList (java.util.ArrayList)10 List (java.util.List)10 FormBasicController (org.olat.core.gui.components.form.flexible.impl.FormBasicController)10 TableEvent (org.olat.core.gui.components.table.TableEvent)10 AssertException (org.olat.core.logging.AssertException)10 UserInfoMainController (org.olat.user.UserInfoMainController)10 OlatFooterController (org.olat.gui.control.OlatFooterController)8 HashMap (java.util.HashMap)6 SingleIdentityChosenEvent (org.olat.basesecurity.events.SingleIdentityChosenEvent)6 TableMultiSelectEvent (org.olat.core.gui.components.table.TableMultiSelectEvent)6 Event (org.olat.core.gui.control.Event)6