Search in sources :

Example 26 with Controller

use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.

the class BaseFullWebappController method removeDTab.

public void removeDTab(UserRequest ureq, DTab delt) {
    // remove from tab list and mapper table
    synchronized (dtabs) {
        // o_clusterOK dtabs are per user session only - user session is always in the same vm
        // make dtabs and dtabsControllers access synchronized
        int dtabIndex = dtabs.indexOf(delt);
        if (dtabIndex == -1) {
            // NOTHING TO REMOVE, return
            return;
        }
        // Remove tab itself
        dtabs.remove(delt);
        dtabToBusinessPath.remove(delt);
        Integer tabId = dtabsLinkNames.remove(dtabIndex);
        Controller tabCtr = dtabsControllers.get(dtabIndex);
        dtabsControllers.remove(tabCtr);
        for (Iterator<TabState> it = siteAndTabs.iterator(); it.hasNext(); ) {
            if (it.next().getDtab() == delt) {
                it.remove();
            }
        }
        navTabsVc.setDirty(true);
        // remove created links for dtab out of container
        navTabsVc.remove(navTabsVc.getComponent("a" + tabId));
        navTabsVc.remove(navTabsVc.getComponent("c" + tabId));
        navTabsVc.remove(navTabsVc.getComponent("ca" + tabId));
        navTabsVc.remove(navTabsVc.getComponent("cp" + tabId));
        if (delt == curDTab && ureq != null) {
            // if we close the current tab -> return to the previous
            popTheTabState(ureq);
        }
        // else just remove the dtabs
        // dispose tab and controllers in tab
        delt.dispose();
    }
}
Also used : ResumeSessionController(org.olat.core.commons.controllers.resume.ResumeSessionController) AssessmentModeGuardController(org.olat.course.assessment.ui.mode.AssessmentModeGuardController) BasicController(org.olat.core.gui.control.controller.BasicController) ChiefController(org.olat.core.gui.control.ChiefController) BaseChiefController(org.olat.core.commons.chiefcontrollers.BaseChiefController) VetoableCloseController(org.olat.core.gui.control.VetoableCloseController) Controller(org.olat.core.gui.control.Controller) UserToolsMenuController(org.olat.gui.control.UserToolsMenuController) HistoryPoint(org.olat.core.id.context.HistoryPoint)

Example 27 with Controller

use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.

the class LinkFileCombiCalloutController method doOpenFileChanger.

public void doOpenFileChanger(UserRequest ureq, String tool) {
    // close callout and open appropriate file changer controller
    calloutCtr.deactivate();
    Controller toolCtr = null;
    if (tool.equals("chooseLink")) {
        VFSItemFilter filter = new SystemItemFilter();
        FileChooserController fileChooserCtr = FileChooserUIFactory.createFileChooserController(ureq, getWindowControl(), baseContainer, filter, true);
        fileChooserCtr.setShowTitle(true);
        fileChooserCtr.selectPath(relFilePath);
        toolCtr = fileChooserCtr;
    }
    if (tool.equals("createLink")) {
        String folderPath = null;
        if (StringHelper.containsNonWhitespace(relFilePath)) {
            // remove file name from relFilePath to represent directory path
            folderPath = relFilePath.substring(0, relFilePath.lastIndexOf("/"));
        }
        toolCtr = new FileCreatorController(ureq, getWindowControl(), baseContainer, folderPath);
    }
    if (tool.equals("uploadLink")) {
        long quotaLeftKB = VFSManager.getQuotaLeftKB(baseContainer);
        String folderPath = null;
        if (StringHelper.containsNonWhitespace(relFilePath)) {
            // remove file name from relFilePath to represent directory path
            folderPath = relFilePath.substring(0, relFilePath.lastIndexOf("/"));
        }
        toolCtr = new FileUploadController(getWindowControl(), baseContainer, ureq, quotaLeftKB, quotaLeftKB, null, false, true, false, false, true, true, folderPath);
    }
    displayModal(toolCtr);
}
Also used : VFSItemFilter(org.olat.core.util.vfs.filters.VFSItemFilter) FileUploadController(org.olat.core.commons.modules.bc.FileUploadController) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) LayoutMain3ColsPreviewController(org.olat.core.commons.fullWebApp.LayoutMain3ColsPreviewController) HTMLEditorController(org.olat.core.commons.editor.htmleditor.HTMLEditorController) Controller(org.olat.core.gui.control.Controller) BasicController(org.olat.core.gui.control.controller.BasicController) SinglePageController(org.olat.core.commons.modules.singlepage.SinglePageController) CloseableCalloutWindowController(org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController) SystemItemFilter(org.olat.core.util.vfs.filters.SystemItemFilter) FileUploadController(org.olat.core.commons.modules.bc.FileUploadController)

Example 28 with Controller

use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.

the class LinkFileCombiCalloutController method doOpenWysiwygEditor.

// ///////////////// helper methods to implement event loop
private void doOpenWysiwygEditor(UserRequest ureq) {
    if (relFilPathIsProposal) {
        file = VFSManager.resolveOrCreateLeafFromPath(baseContainer, relFilePath);
    }
    if (file == null) {
        // huh? no idea what happend, do nothing and log error
        logError("Could not load or create file with relFilePath::" + relFilePath + " in baseContainer::" + VFSManager.getRealPath(baseContainer), null);
        return;
    }
    // Configure editor depending on limitEditorToRelativeFiles flag
    // either based on baseContainer or the files direct parent
    VFSContainer editorBaseContainer = baseContainer;
    String editorRelPath = relFilePath;
    if (!allowEditorRelativeLinks && relFilePath.indexOf("/", 1) != 0) {
        editorBaseContainer = file.getParentContainer();
        editorRelPath = file.getName();
    }
    // Open HTML editor in dialog
    Controller wysiwygCtr = WysiwygFactory.createWysiwygControllerWithInternalLink(ureq, getWindowControl(), editorBaseContainer, editorRelPath, true, customLinkTreeModel);
    displayModal(wysiwygCtr);
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) FileUploadController(org.olat.core.commons.modules.bc.FileUploadController) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) LayoutMain3ColsPreviewController(org.olat.core.commons.fullWebApp.LayoutMain3ColsPreviewController) HTMLEditorController(org.olat.core.commons.editor.htmleditor.HTMLEditorController) Controller(org.olat.core.gui.control.Controller) BasicController(org.olat.core.gui.control.controller.BasicController) SinglePageController(org.olat.core.commons.modules.singlepage.SinglePageController) CloseableCalloutWindowController(org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController)

Example 29 with Controller

use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.

the class GTACoachController method initContainer.

@Override
protected void initContainer(UserRequest ureq) {
    mainVC = createVelocityContainer("coach");
    reviewedButton = LinkFactory.createCustomLink("coach.reviewed.button", "reviewed", "coach.reviewed.button", Link.BUTTON, mainVC, this);
    reviewedButton.setElementCssClass("o_sel_course_gta_reviewed");
    reviewedButton.setIconLeftCSS("o_icon o_icon_accepted");
    reviewedButton.setPrimary(true);
    reviewedButton.setVisible(!coachCourseEnv.isCourseReadOnly());
    if (config.getBooleanSafe(GTACourseNode.GTASK_REVISION_PERIOD)) {
        needRevisionsButton = LinkFactory.createCustomLink("coach.need.revision.button", "need-revision", "coach.need.revision.button", Link.BUTTON, mainVC, this);
        needRevisionsButton.setElementCssClass("o_sel_course_gta_need_revision");
        needRevisionsButton.setPrimary(true);
        needRevisionsButton.setVisible(!coachCourseEnv.isCourseReadOnly());
        needRevisionsButton.setIconLeftCSS("o_icon o_icon_rejected");
    }
    if (withTitle) {
        if (assessedGroup != null) {
            mainVC.contextPut("groupName", assessedGroup.getName());
            emailLink = LinkFactory.createButtonXSmall("mailto.group", mainVC, this);
            emailLink.setIconLeftCSS("o_icon o_icon_mail");
        } else if (assessedIdentity != null) {
            mainVC.contextPut("identityFullName", userManager.getUserDisplayName(assessedIdentity));
            Controller dpc = new DisplayPortraitController(ureq, getWindowControl(), assessedIdentity, false, true, true, true);
            // auto dispose, no need to keep local reference
            listenTo(dpc);
            mainVC.put("image", dpc.getInitialComponent());
            emailLink = LinkFactory.createButtonXSmall("mailto.user", mainVC, this);
            emailLink.setIconLeftCSS("o_icon o_icon_mail");
        }
    }
    if (withReset) {
        resetTaskButton = LinkFactory.createCustomLink("coach.reset.button", "reset", "coach.reset.button", Link.BUTTON, mainVC, this);
        resetTaskButton.setElementCssClass("o_sel_course_gta_reset");
        resetTaskButton.setVisible(false);
    }
    putInitialPanel(mainVC);
}
Also used : DisplayPortraitController(org.olat.user.DisplayPortraitController) DisplayPortraitController(org.olat.user.DisplayPortraitController) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) DialogBoxController(org.olat.core.gui.control.generic.modal.DialogBoxController) Controller(org.olat.core.gui.control.Controller) ContactFormController(org.olat.modules.co.ContactFormController)

Example 30 with Controller

use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.

the class NavigationHandler method doEvaluateJumpTo.

private NodeClickedRef doEvaluateJumpTo(UserRequest ureq, WindowControl wControl, CourseNode courseNode, ControllerEventListener listeningController, String nodecmd, String nodeSubCmd, Controller currentNodeController) {
    NodeClickedRef nclr;
    if (log.isDebug()) {
        log.debug("evaluateJumpTo courseNode = " + courseNode.getIdent() + ", " + courseNode.getShortName());
    }
    // build the new treemodel by evaluating the preconditions
    TreeEvaluation treeEval = new TreeEvaluation();
    GenericTreeModel treeModel = new GenericTreeModel();
    CourseNode rootCn = userCourseEnv.getCourseEnvironment().getRunStructure().getRootNode();
    NodeEvaluation rootNodeEval = rootCn.eval(userCourseEnv.getConditionInterpreter(), treeEval, filter);
    TreeNode treeRoot = rootNodeEval.getTreeNode();
    treeModel.setRootNode(treeRoot);
    // find the treenode that corresponds to the node (!= selectedTreeNode since
    // we built the TreeModel anew in the meantime
    TreeNode newCalledTreeNode = treeEval.getCorrespondingTreeNode(courseNode);
    if (newCalledTreeNode == null) {
        // the clicked node is not visible anymore!
        // if the new calculated model does not contain the selected node anymore
        // (because of visibility changes of at least one of the ancestors
        // -> issue an user infomative msg
        // nclr: the new treemodel, not visible, no selected nodeid, no
        // calledcoursenode, no nodeconstructionresult
        nclr = new NodeClickedRef(treeModel, false, null, null, null, null, false);
    } else {
        // calculate the NodeClickedRef
        // 1. get the correct (new) nodeevaluation
        NodeEvaluation nodeEval = (NodeEvaluation) newCalledTreeNode.getUserObject();
        if (nodeEval.getCourseNode() != courseNode) {
            throw new AssertException("error in structure");
        }
        if (!nodeEval.isVisible()) {
            throw new AssertException("node eval not visible!!");
        }
        // 2. start with the current NodeEvaluation, evaluate overall accessiblity
        // per node bottom-up to see if all ancestors still grant access to the
        // desired node
        boolean mayAccessWholeTreeUp = mayAccessWholeTreeUp(nodeEval);
        String newSelectedNodeId = newCalledTreeNode.getIdent();
        Controller controller;
        AdditionalConditionManager addMan = null;
        if (courseNode instanceof AbstractAccessableCourseNode) {
            Long courseId = userCourseEnv.getCourseEnvironment().getCourseResourceableId();
            CourseNodePasswordManager cnpm = CourseNodePasswordManagerImpl.getInstance();
            Identity identity = userCourseEnv.getIdentityEnvironment().getIdentity();
            AdditionalConditionAnswerContainer answerContainer = cnpm.getAnswerContainer(identity);
            addMan = new AdditionalConditionManager((AbstractAccessableCourseNode) courseNode, courseId, answerContainer);
        }
        if (!mayAccessWholeTreeUp || (addMan != null && !addMan.evaluateConditions())) {
            if (nodeEval.oldStyleConditionsOk()) {
                controller = addMan.nextUserInputController(ureq, wControl, userCourseEnv);
                if (listeningController != null) {
                    controller.addControllerListener(listeningController);
                }
            } else {
                // NOTE: we do not take into account what node caused the non-access by
                // being !isAtLeastOneAccessible, but always state the
                // NoAccessExplanation of the Node originally called by the user
                String explan = courseNode.getNoAccessExplanation();
                String sExplan = (explan == null ? "" : Formatter.formatLatexFormulas(explan));
                controller = MessageUIFactory.createInfoMessage(ureq, wControl, null, sExplan);
                // write log information
                ThreadLocalUserActivityLogger.log(CourseLoggingAction.COURSE_NAVIGATION_NODE_NO_ACCESS, getClass(), LoggingResourceable.wrap(courseNode));
            }
            NodeRunConstructionResult ncr = new NodeRunConstructionResult(controller, null, null, null);
            // nclr: the new treemodel, visible, selected nodeid, calledcoursenode,
            // nodeconstructionresult
            nclr = new NodeClickedRef(treeModel, true, newSelectedNodeId, null, courseNode, ncr, false);
        } else if (!CourseNodeFactory.getInstance().getCourseNodeConfigurationEvenForDisabledBB(courseNode.getType()).isEnabled()) {
            Translator pT = Util.createPackageTranslator(EditorMainController.class, ureq.getLocale());
            controller = MessageUIFactory.createInfoMessage(ureq, wControl, null, pT.translate("course.building.block.disabled.user"));
            NodeRunConstructionResult ncr = new NodeRunConstructionResult(controller, null, null, null);
            nclr = new NodeClickedRef(treeModel, true, newSelectedNodeId, null, courseNode, ncr, false);
        } else {
            if (STCourseNode.isDelegatingSTCourseNode(courseNode) && (courseNode.getChildCount() > 0)) {
                // the clicked node is a STCourse node and is set to "delegate", so
                // delegate to its first visible child; if no child is visible, just skip and do normal eval
                INode child;
                for (int i = 0; i < courseNode.getChildCount(); i++) {
                    child = courseNode.getChildAt(i);
                    if (child instanceof CourseNode) {
                        CourseNode cn = (CourseNode) child;
                        NodeEvaluation cnEval = cn.eval(userCourseEnv.getConditionInterpreter(), treeEval, filter);
                        if (cnEval.isVisible()) {
                            return doEvaluateJumpTo(ureq, wControl, cn, listeningController, nodecmd, nodeSubCmd, currentNodeController);
                        }
                    }
                }
            }
            // access the node, display its result in the right pane
            NodeRunConstructionResult ncr;
            // calculate the new businesscontext for the coursenode being called.
            // type: class of node; key = node.getIdent;
            // don't use the concrete instance since for the course: to jump to a coursenode with a given id is all there is to know
            Class<CourseNode> oresC = CourseNode.class;
            Long oresK = new Long(Long.parseLong(courseNode.getIdent()));
            final OLATResourceable ores = OresHelper.createOLATResourceableInstance(oresC, oresK);
            ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(ores);
            WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ce, wControl);
            if (previewMode) {
                ncr = new NodeRunConstructionResult(courseNode.createPreviewController(ureq, bwControl, userCourseEnv, nodeEval));
            } else {
                // cleanup already existing controllers with external models for this node first, never disposed otherwise
                if (externalTreeModels.containsKey(courseNode.getIdent()) && !(TreeEvent.COMMAND_TREENODE_OPEN.equals(nodeSubCmd) || TreeEvent.COMMAND_TREENODE_CLOSE.equals(nodeSubCmd))) {
                    SubTree subTree = externalTreeModels.get(courseNode.getIdent());
                    ControllerEventListener existingSubtreemodelListener = subTree.getTreeModelListener();
                    if (existingSubtreemodelListener != null && currentNodeController != null && !currentNodeController.isDisposed()) {
                        currentNodeController.dispose();
                    }
                }
                ncr = courseNode.createNodeRunConstructionResult(ureq, bwControl, userCourseEnv, nodeEval, nodecmd);
                // remember as instance variable for next click
                ControllerEventListener subtreemodelListener = ncr.getSubTreeListener();
                if (subtreemodelListener != null) {
                    GenericTreeModel subTreeModel = (GenericTreeModel) ncr.getSubTreeModel();
                    externalTreeModels.put(courseNode.getIdent(), new SubTree(ncr.getRunController(), subTreeModel, subtreemodelListener));
                    if (!newSelectedNodeId.equals(ncr.getSelectedTreeNodeId())) {
                        if (ncr.getSelectedTreeNodeId() != null) {
                            TreeNode selectedNode = subTreeModel.getNodeById(ncr.getSelectedTreeNodeId());
                            if (selectedNode != null && selectedNode.getUserObject() instanceof String) {
                                openCourseNodeIds.add((String) selectedNode.getUserObject());
                            }
                        }
                    }
                }
            }
            if (TreeEvent.COMMAND_TREENODE_OPEN.equals(nodeSubCmd)) {
                openCourseNodeIds.add(courseNode.getIdent());
                newSelectedNodeId = convertToTreeNodeId(treeEval, selectedCourseNodeId);
            } else if (TreeEvent.COMMAND_TREENODE_CLOSE.equals(nodeSubCmd)) {
                removeChildrenFromOpenNodes(courseNode);
                newSelectedNodeId = convertToTreeNodeId(treeEval, selectedCourseNodeId);
                if (!isInParentLine(courseNode)) {
                    selectedCourseNodeId = courseNode.getIdent();
                } else {
                    selectedCourseNodeId = null;
                    newSelectedNodeId = null;
                }
            } else {
                // add the selected node to the open one, if not, strange behaviour
                selectedCourseNodeId = courseNode.getIdent();
                openCourseNodeIds.add(selectedCourseNodeId);
                if (ncr != null) {
                    String subNodeId = ncr.getSelectedTreeNodeId();
                    if (subNodeId != null) {
                        openCourseNodeIds.add(subNodeId);
                    }
                }
            }
            openTreeNodeIds = convertToTreeNodeIds(treeEval, openCourseNodeIds);
            reattachExternalTreeModels(treeEval);
            if ((TreeEvent.COMMAND_TREENODE_OPEN.equals(nodeSubCmd) || TreeEvent.COMMAND_TREENODE_CLOSE.equals(nodeSubCmd)) && currentNodeController != null && !currentNodeController.isDisposed()) {
                nclr = new NodeClickedRef(treeModel, true, null, openTreeNodeIds, null, null, false);
            } else {
                // nclr: the new treemodel, visible, selected nodeid, calledcoursenode,
                // nodeconstructionresult
                nclr = new NodeClickedRef(treeModel, true, newSelectedNodeId, openTreeNodeIds, courseNode, ncr, false);
                // attach listener; we know we have a runcontroller here
                if (listeningController != null) {
                    nclr.getRunController().addControllerListener(listeningController);
                }
            }
            // write log information
            ThreadLocalUserActivityLogger.log(CourseLoggingAction.COURSE_NAVIGATION_NODE_ACCESS, getClass(), LoggingResourceable.wrap(courseNode));
        }
    }
    return nclr;
}
Also used : INode(org.olat.core.util.nodes.INode) OLATResourceable(org.olat.core.id.OLATResourceable) AdditionalConditionManager(org.olat.course.condition.additionalconditions.AdditionalConditionManager) WindowControl(org.olat.core.gui.control.WindowControl) ContextEntry(org.olat.core.id.context.ContextEntry) ControllerEventListener(org.olat.core.gui.control.ControllerEventListener) Translator(org.olat.core.gui.translator.Translator) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) CourseNode(org.olat.course.nodes.CourseNode) AbstractAccessableCourseNode(org.olat.course.nodes.AbstractAccessableCourseNode) STCourseNode(org.olat.course.nodes.STCourseNode) Identity(org.olat.core.id.Identity) EditorMainController(org.olat.course.editor.EditorMainController) AssertException(org.olat.core.logging.AssertException) EditorMainController(org.olat.course.editor.EditorMainController) TitledWrapperController(org.olat.core.gui.control.generic.title.TitledWrapperController) CPRunController(org.olat.course.nodes.cp.CPRunController) Controller(org.olat.core.gui.control.Controller) CourseNodePasswordManager(de.bps.course.nodes.CourseNodePasswordManager) TreeEvaluation(org.olat.course.run.userview.TreeEvaluation) AbstractAccessableCourseNode(org.olat.course.nodes.AbstractAccessableCourseNode) NodeEvaluation(org.olat.course.run.userview.NodeEvaluation) AdditionalConditionAnswerContainer(org.olat.course.condition.additionalconditions.AdditionalConditionAnswerContainer)

Aggregations

Controller (org.olat.core.gui.control.Controller)372 BasicController (org.olat.core.gui.control.controller.BasicController)114 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)82 NodeEditController (org.olat.course.editor.NodeEditController)82 WindowControl (org.olat.core.gui.control.WindowControl)78 TabbableController (org.olat.core.gui.control.generic.tabbable.TabbableController)74 NodeRunConstructionResult (org.olat.course.run.navigation.NodeRunConstructionResult)62 RepositoryEntry (org.olat.repository.RepositoryEntry)60 Translator (org.olat.core.gui.translator.Translator)54 UserRequest (org.olat.core.gui.UserRequest)52 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)50 OLATResourceable (org.olat.core.id.OLATResourceable)46 ArrayList (java.util.ArrayList)40 ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)40 MainLayoutBasicController (org.olat.core.gui.control.controller.MainLayoutBasicController)36 Component (org.olat.core.gui.components.Component)34 Roles (org.olat.core.id.Roles)34 Activateable2 (org.olat.core.gui.control.generic.dtabs.Activateable2)32 FormBasicController (org.olat.core.gui.components.form.flexible.impl.FormBasicController)30 ContextEntry (org.olat.core.id.context.ContextEntry)30