Search in sources :

Example 11 with Controller

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

the class DevelopmentController method renderDebugInfo.

/**
 * used by velocityrenderdecorator
 * @param target
 */
private void renderDebugInfo(Component root, StringOutput target) {
    target.append("<div>");
    int cnt = cntTree(root);
    int size = DefaultController.getControllerCount();
    target.append("<strong>Component Tree:</strong> count: " + cnt + "&nbsp;&nbsp;|&nbsp;&nbsp;Controllers (global: active and not disposed): <strong>" + size + "</strong>");
    target.append("</div><div>");
    Map<Controller, List<Component>> controllerInfos = new HashMap<Controller, List<Component>>();
    dumpTree(target, root, 0, controllerInfos);
    target.append("</div>");
    // now dump the controller info
    for (Controller controller : controllerInfos.keySet()) {
        try {
            Component initComp = controller.getInitialComponent();
            target.append("<div style=\"padding-bottom:2px; \"><strong>Controller " + controller.getClass().getName() + " :" + controller.hashCode());
            appendDivCodeForComponent("<i>Initial Component:</i> ", target, initComp, 20);
            List<Component> listenTo = controllerInfos.get(controller);
            for (Component component : listenTo) {
                appendDivCodeForComponent("", target, component, 20);
            }
            target.append("</strong></div><br />");
        } catch (Exception e) {
        // some components like window dont like being called for the initialcomponent
        // -> ignore
        }
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) FloatingResizableDialogController(org.olat.core.gui.control.floatingresizabledialog.FloatingResizableDialogController) ExpColController(org.olat.core.gui.control.generic.spacesaver.ExpColController) Controller(org.olat.core.gui.control.Controller) BasicController(org.olat.core.gui.control.controller.BasicController) DefaultController(org.olat.core.gui.control.DefaultController) Component(org.olat.core.gui.components.Component)

Example 12 with Controller

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

the class PortletContainer method addAdditonalTools.

private void addAdditonalTools(UserRequest ureq, boolean editModeEnabled) {
    if (!editModeEnabled)
        return;
    Controller additionalPortletTools = portlet.getTools(ureq, getWindowControl());
    if (additionalPortletTools != null) {
        toolboxContainer.contextPut("hasAdditional", Boolean.TRUE);
        toolboxContainer.put("additionalTools", additionalPortletTools.getInitialComponent());
    }
}
Also used : BasicController(org.olat.core.gui.control.controller.BasicController) Controller(org.olat.core.gui.control.Controller)

Example 13 with Controller

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

the class GuiDebugDispatcherController method createInterceptComponentRenderer.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.olat.core.gui.render.debug.DebugHandler#createDebugComponentRenderer(org.olat.core.gui.components.ComponentRenderer)
	 */
@Override
public ComponentRenderer createInterceptComponentRenderer(final ComponentRenderer originalRenderer) {
    return new ComponentRenderer() {

        @Override
        public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
            if (debugURLBuilder != null && !DebugHelper.isProtected(source)) {
                // remember source for later debug info access
                String did = source.getDispatchID();
                String didS = String.valueOf(did);
                idToComponent.put(didS, source);
                int lev = renderResult.getNestedLevel();
                String cname = source.getClass().getName();
                String cnameShort = cname.substring(cname.lastIndexOf('.') + 1);
                // header before component
                sb.append("<div class='o_dev_w'>");
                sb.append("<div class='o_dev_h'><span id='o_guidebugst").append(did).append("' onmouseover=\"o_debu_show(this.parentNode.parentNode, jQuery('#o_guidebugtt").append(did).append("'))\">");
                sb.append(source.getComponentName()).append(" (").append(cnameShort).append(")");
                sb.append("</span></div>");
                sb.append("<div class='o_dev_c'><div id='o_guidebugtt").append(did).append("' class='o_dev_i'>");
                sb.append("Info: <b>").append(source.getComponentName()).append("</b> (" + cnameShort + ") id:");
                sb.append(String.valueOf(source.getDispatchID())).append("&nbsp; level:").append(lev);
                Controller listC = Util.getListeningControllerFor(source);
                if (listC != null) {
                    sb.append("<br /><b>controller:</b> <a  target=\"_blank\" href=\"");
                    String controllerClassName = listC.getClass().getName();
                    debugURLBuilder.buildURI(sb, new String[] { "cid", "com", "class" }, new String[] { String.valueOf(did), "ojava", controllerClassName });
                    sb.append("\">");
                    sb.append(controllerClassName);
                    sb.append("</a>");
                }
                sb.append("<br /><i>listeners</i>: ");
                if (!source.isEnabled()) {
                    sb.append(" NOT ENABLED");
                }
                String listeners = source.getListenerInfo();
                sb.append(listeners);
                if (!source.isVisible()) {
                    sb.append("<br />INVISIBLE");
                }
                sb.append("<br />");
                // we must let the original renderer do its work so that the collecting translator is callbacked.
                // we save the result in a new var since it is too early to append it to the 'stream' right now.
                StringOutput sbOrig = new StringOutput();
                try {
                    originalRenderer.render(renderer, sbOrig, source, ubu, translator, renderResult, args);
                } catch (Exception e) {
                    String emsg = "exception while rendering component '" + source.getComponentName() + "' (" + source.getClass().getName() + ") " + source.getListenerInfo() + "<br />Message of exception: " + e.getMessage();
                    sbOrig.append("<span style=\"color:red\">Exception</span><br /><pre>" + emsg + "</pre>");
                }
                sb.append("</div>");
                // add original component
                sb.append(sbOrig);
                sb.append("</div></div>");
            } else {
                // e.g. when the render process take place before the delegating
                // component of this controller here was rendered.
                // the delegating component should be placed near the <html> tag in
                // order to be rendered first.
                // the contentpane of the window and the first implementing container
                // will not be provided with debug info, which is on purpose,
                // since those are contents from the chiefcontroller which control the
                // window.
                // render original component
                originalRenderer.render(renderer, sb, source, ubu, translator, renderResult, args);
            }
        }

        @Override
        public void renderHeaderIncludes(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderingState rstate) {
            originalRenderer.renderHeaderIncludes(renderer, sb, source, ubu, translator, rstate);
        }

        @Override
        public void renderBodyOnLoadJSFunctionCall(Renderer renderer, StringOutput sb, Component source, RenderingState rstate) {
            originalRenderer.renderBodyOnLoadJSFunctionCall(renderer, sb, source, rstate);
        }
    };
}
Also used : ComponentRenderer(org.olat.core.gui.components.ComponentRenderer) Translator(org.olat.core.gui.translator.Translator) ComponentRenderer(org.olat.core.gui.components.ComponentRenderer) Renderer(org.olat.core.gui.render.Renderer) RenderResult(org.olat.core.gui.render.RenderResult) RenderingState(org.olat.core.gui.render.RenderingState) StringOutput(org.olat.core.gui.render.StringOutput) Component(org.olat.core.gui.components.Component) DelegatingComponent(org.olat.core.gui.components.delegating.DelegatingComponent) Controller(org.olat.core.gui.control.Controller) BasicController(org.olat.core.gui.control.controller.BasicController) PlainTextEditorController(org.olat.core.commons.editor.plaintexteditor.PlainTextEditorController) SourceViewController(org.olat.core.gui.dev.controller.SourceViewController) IOException(java.io.IOException) URLBuilder(org.olat.core.gui.render.URLBuilder)

Example 14 with Controller

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

the class AssessmentCourseTreeController method activate.

@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    boolean emptyEntries = entries == null || entries.isEmpty();
    if (emptyEntries) {
        TreeNode rootNode = menuTree.getTreeModel().getRootNode();
        if (rootNode.getUserObject() instanceof CourseNode) {
            if (view == null) {
                view = View.users;
            }
            doSelectCourseNode(ureq, rootNode, (CourseNode) rootNode.getUserObject());
            menuTree.setSelectedNode(rootNode);
        }
    } else {
        ContextEntry entry = entries.get(0);
        String resourceTypeName = entry.getOLATResourceable().getResourceableTypeName();
        if ("Identity".equalsIgnoreCase(resourceTypeName)) {
            TreeNode treeNode = menuTree.getTreeModel().getRootNode();
            CourseNode courseNode = (CourseNode) treeNode.getUserObject();
            if (courseNode != null) {
                view = View.users;
                Controller ctrl = doSelectCourseNode(ureq, treeNode, courseNode);
                if (ctrl instanceof Activateable2) {
                    ((Activateable2) ctrl).activate(ureq, entries, null);
                }
                menuTree.setSelectedNode(treeNode);
            }
        } else if ("Node".equalsIgnoreCase(resourceTypeName) || "CourseNode".equalsIgnoreCase(resourceTypeName)) {
            Long nodeIdent = entries.get(0).getOLATResourceable().getResourceableId();
            CourseNode courseNode = CourseFactory.loadCourse(courseEntry).getRunStructure().getNode(nodeIdent.toString());
            TreeNode treeNode = TreeHelper.findNodeByUserObject(courseNode, menuTree.getTreeModel().getRootNode());
            if (courseNode != null) {
                if (view == null) {
                    view = View.users;
                }
                Controller ctrl = doSelectCourseNode(ureq, treeNode, courseNode);
                if (ctrl instanceof Activateable2) {
                    List<ContextEntry> subEntries = entries.subList(1, entries.size());
                    ((Activateable2) ctrl).activate(ureq, subEntries, entry.getTransientState());
                }
                menuTree.setSelectedNode(treeNode);
            }
        }
    }
}
Also used : Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) TreeNode(org.olat.core.gui.components.tree.TreeNode) List(java.util.List) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseNode(org.olat.course.nodes.CourseNode) GTACourseNode(org.olat.course.nodes.GTACourseNode) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) Controller(org.olat.core.gui.control.Controller) BasicController(org.olat.core.gui.control.controller.BasicController) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 15 with Controller

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

the class AssessmentCourseTreeController method processSelectCourseNodeWithMemory.

private void processSelectCourseNodeWithMemory(UserRequest ureq, TreeNode tn, CourseNode cn) {
    StateEntry listState = null;
    if (currentCtrl != null && currentCtrl == identityListCtrl) {
        listState = identityListCtrl.getListState();
    }
    Controller ctrl = doSelectCourseNode(ureq, tn, cn);
    if (ctrl instanceof Activateable2) {
        ((Activateable2) ctrl).activate(ureq, null, listState);
    }
}
Also used : StateEntry(org.olat.core.id.context.StateEntry) Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) Controller(org.olat.core.gui.control.Controller) BasicController(org.olat.core.gui.control.controller.BasicController)

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