Search in sources :

Example 1 with FigureMode

use of com.github.bordertech.wcomponents.WFigure.FigureMode in project wcomponents by BorderTech.

the class WFigureRenderer method doRender.

/**
 * Paints the given WFigure.
 *
 * @param component the WFigure to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WFigure figure = (WFigure) component;
    XmlStringBuilder xml = renderContext.getWriter();
    boolean renderChildren = isRenderContent(figure);
    xml.appendTagOpen("ui:figure");
    xml.appendAttribute("id", component.getId());
    xml.appendOptionalAttribute("class", component.getHtmlClass());
    xml.appendOptionalAttribute("track", component.isTracking(), "true");
    if (FigureMode.LAZY.equals(figure.getMode())) {
        xml.appendOptionalAttribute("hidden", !renderChildren, "true");
    } else {
        xml.appendOptionalAttribute("hidden", component.isHidden(), "true");
    }
    FigureMode mode = figure.getMode();
    if (mode != null) {
        switch(mode) {
            case LAZY:
                xml.appendAttribute("mode", "lazy");
                break;
            case EAGER:
                xml.appendAttribute("mode", "eager");
                break;
            default:
                throw new SystemException("Unknown figure mode: " + figure.getMode());
        }
    }
    xml.appendClose();
    // Render margin
    MarginRendererUtil.renderMargin(figure, renderContext);
    if (renderChildren) {
        // Label
        figure.getDecoratedLabel().paint(renderContext);
        // Content
        xml.appendTagOpen("ui:content");
        xml.appendAttribute("id", component.getId() + "-content");
        xml.appendClose();
        figure.getContent().paint(renderContext);
        xml.appendEndTag("ui:content");
    }
    xml.appendEndTag("ui:figure");
}
Also used : WFigure(com.github.bordertech.wcomponents.WFigure) FigureMode(com.github.bordertech.wcomponents.WFigure.FigureMode) SystemException(com.github.bordertech.wcomponents.util.SystemException) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Aggregations

WFigure (com.github.bordertech.wcomponents.WFigure)1 FigureMode (com.github.bordertech.wcomponents.WFigure.FigureMode)1 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)1 SystemException (com.github.bordertech.wcomponents.util.SystemException)1