Search in sources :

Example 16 with StringOutput

use of org.olat.core.gui.render.StringOutput 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 17 with StringOutput

use of org.olat.core.gui.render.StringOutput in project OpenOLAT by OpenOLAT.

the class VelocityRenderDecorator method getCId.

/**
 * @return the componentid (e.g.) o_c32645732
 */
public StringOutput getCId() {
    StringOutput sb = new StringOutput(16);
    sb.append("o_c").append(vc.getDispatchID());
    return sb;
}
Also used : StringOutput(org.olat.core.gui.render.StringOutput)

Example 18 with StringOutput

use of org.olat.core.gui.render.StringOutput in project OpenOLAT by OpenOLAT.

the class VelocityRenderDecorator method formURIbg.

/**
 * Use it to create the action for a handmade form in a velocity template,
 * e.g. '<form method="post" action="$r.formURIgb("viewswitch")">'
 * @param command
 * @return
 */
public StringOutput formURIbg(String command) {
    StringOutput sb = new StringOutput(100);
    renderer.getUrlBuilder().buildURI(sb, new String[] { VelocityContainer.COMMAND_ID }, new String[] { command }, isIframePostEnabled ? AJAXFlags.MODE_TOBGIFRAME : AJAXFlags.MODE_NORMAL);
    return sb;
}
Also used : StringOutput(org.olat.core.gui.render.StringOutput)

Example 19 with StringOutput

use of org.olat.core.gui.render.StringOutput in project OpenOLAT by OpenOLAT.

the class VelocityRenderDecorator method getId.

public static String getId(String prefix, VelocityContainer vc) {
    StringOutput sb = StringOutputPool.allocStringBuilder(24);
    sb.append("o_s").append(prefix).append(vc.getDispatchID());
    return StringOutputPool.freePop(sb);
}
Also used : StringOutput(org.olat.core.gui.render.StringOutput)

Example 20 with StringOutput

use of org.olat.core.gui.render.StringOutput in project OpenOLAT by OpenOLAT.

the class VelocityRenderDecorator method mathJaxConfig.

public StringOutput mathJaxConfig() {
    StringOutput sb = new StringOutput(100);
    sb.append(WebappHelper.getMathJaxConfig());
    return sb;
}
Also used : StringOutput(org.olat.core.gui.render.StringOutput)

Aggregations

StringOutput (org.olat.core.gui.render.StringOutput)188 IOException (java.io.IOException)48 URLBuilder (org.olat.core.gui.render.URLBuilder)30 Renderer (org.olat.core.gui.render.Renderer)26 Block (uk.ac.ed.ph.jqtiplus.node.content.basic.Block)24 RenderResult (org.olat.core.gui.render.RenderResult)22 Component (org.olat.core.gui.components.Component)10 Translator (org.olat.core.gui.translator.Translator)10 Locale (java.util.Locale)8 Window (org.olat.core.gui.components.Window)8 Form (org.olat.core.gui.components.form.flexible.impl.Form)8 VelocityRenderDecorator (org.olat.core.gui.render.velocity.VelocityRenderDecorator)8 ArrayList (java.util.ArrayList)6 StreamResult (javax.xml.transform.stream.StreamResult)6 Test (org.junit.Test)6 GlobalSettings (org.olat.core.gui.GlobalSettings)6 ComponentRenderer (org.olat.core.gui.components.ComponentRenderer)6 DefaultColumnDescriptor (org.olat.core.gui.components.table.DefaultColumnDescriptor)6 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)6 Matcher (java.util.regex.Matcher)5