Search in sources :

Example 21 with XmlStringBuilder

use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.

the class WSectionRenderer method doRender.

/**
 * Paints the given WSection.
 *
 * @param component the WSection to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WSection section = (WSection) component;
    XmlStringBuilder xml = renderContext.getWriter();
    boolean renderChildren = isRenderContent(section);
    xml.appendTagOpen("ui:section");
    xml.appendAttribute("id", component.getId());
    xml.appendOptionalAttribute("class", component.getHtmlClass());
    xml.appendOptionalAttribute("track", component.isTracking(), "true");
    if (SectionMode.LAZY.equals(section.getMode())) {
        xml.appendOptionalAttribute("hidden", !renderChildren, "true");
    } else {
        xml.appendOptionalAttribute("hidden", component.isHidden(), "true");
    }
    SectionMode mode = section.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 section mode: " + section.getMode());
        }
    }
    xml.appendClose();
    // Render margin
    MarginRendererUtil.renderMargin(section, renderContext);
    if (renderChildren) {
        // Label
        section.getDecoratedLabel().paint(renderContext);
        // Content
        section.getContent().paint(renderContext);
    }
    xml.appendEndTag("ui:section");
}
Also used : WSection(com.github.bordertech.wcomponents.WSection) SectionMode(com.github.bordertech.wcomponents.WSection.SectionMode) SystemException(com.github.bordertech.wcomponents.util.SystemException) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Example 22 with XmlStringBuilder

use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.

the class WSeparatorRenderer method doRender.

/**
 * Paints the given WSeparator.
 *
 * @param component the WSeparator to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    XmlStringBuilder xml = renderContext.getWriter();
    xml.appendTagOpen("ui:separator");
    xml.appendOptionalAttribute("class", component.getHtmlClass());
    xml.appendEnd();
}
Also used : XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Example 23 with XmlStringBuilder

use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.

the class WSkipLinksRenderer method doRender.

/**
 * Paints the given WSkipLinks.
 *
 * @param component the WSkipLinks to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    XmlStringBuilder xml = renderContext.getWriter();
    xml.appendTagOpen("ui:skiplinks");
    xml.appendOptionalAttribute("class", component.getHtmlClass());
    xml.appendEnd();
}
Also used : XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Example 24 with XmlStringBuilder

use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.

the class WStyledTextRenderer method doRender.

/**
 * Paints the given WStyledText.
 *
 * @param component the WStyledText to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WStyledText text = (WStyledText) component;
    XmlStringBuilder xml = renderContext.getWriter();
    String textString = text.getText();
    if (textString != null && textString.length() > 0) {
        xml.appendTagOpen("ui:text");
        xml.appendOptionalAttribute("class", component.getHtmlClass());
        switch(text.getType()) {
            case EMPHASISED:
                xml.appendAttribute("type", "emphasised");
                break;
            case HIGH_PRIORITY:
                xml.appendAttribute("type", "highPriority");
                break;
            case LOW_PRIORITY:
                xml.appendAttribute("type", "lowPriority");
                break;
            case MEDIUM_PRIORITY:
                xml.appendAttribute("type", "mediumPriority");
                break;
            case ACTIVE_INDICATOR:
                xml.appendAttribute("type", "activeIndicator");
                break;
            case MATCH_INDICATOR:
                xml.appendAttribute("type", "matchIndicator");
                break;
            case INSERT:
                xml.appendAttribute("type", "insert");
                break;
            case DELETE:
                xml.appendAttribute("type", "delete");
                break;
            case MANDATORY_INDICATOR:
                xml.appendAttribute("type", "mandatoryIndicator");
                break;
            case PLAIN:
            default:
                xml.appendAttribute("type", "plain");
                break;
        }
        switch(text.getWhitespaceMode()) {
            case PARAGRAPHS:
                xml.appendAttribute("space", "paragraphs");
                break;
            case PRESERVE:
                xml.appendAttribute("space", "preserve");
                break;
            case DEFAULT:
                break;
            default:
                throw new IllegalArgumentException("Unknown white space mode: " + text.getWhitespaceMode());
        }
        xml.appendClose();
        if (WStyledText.WhitespaceMode.PARAGRAPHS.equals(text.getWhitespaceMode())) {
            textString = text.isEncodeText() ? WebUtilities.encode(textString) : HtmlToXMLUtil.unescapeToXML(textString);
            writeParagraphs(textString, xml);
        } else {
            xml.append(textString, text.isEncodeText());
        }
        xml.appendEndTag("ui:text");
    }
}
Also used : WStyledText(com.github.bordertech.wcomponents.WStyledText) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Example 25 with XmlStringBuilder

use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.

the class WSubordinateControlRenderer method doRender.

/**
 * Paints the given SubordinateControl.
 *
 * @param component the SubordinateControl to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WSubordinateControl subordinate = (WSubordinateControl) component;
    XmlStringBuilder xml = renderContext.getWriter();
    if (!subordinate.getRules().isEmpty()) {
        int seq = 0;
        for (Rule rule : subordinate.getRules()) {
            xml.appendTagOpen("ui:subordinate");
            xml.appendAttribute("id", subordinate.getId() + "-c" + seq++);
            xml.appendClose();
            paintRule(rule, xml);
            xml.appendEndTag("ui:subordinate");
        }
    }
}
Also used : WSubordinateControl(com.github.bordertech.wcomponents.subordinate.WSubordinateControl) Rule(com.github.bordertech.wcomponents.subordinate.Rule) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Aggregations

XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)102 WComponent (com.github.bordertech.wcomponents.WComponent)30 SystemException (com.github.bordertech.wcomponents.util.SystemException)17 Size (com.github.bordertech.wcomponents.Size)8 Diagnostic (com.github.bordertech.wcomponents.validation.Diagnostic)7 OptionGroup (com.github.bordertech.wcomponents.OptionGroup)6 UIContext (com.github.bordertech.wcomponents.UIContext)5 WPanel (com.github.bordertech.wcomponents.WPanel)5 WebXmlRenderContext (com.github.bordertech.wcomponents.servlet.WebXmlRenderContext)5 WButton (com.github.bordertech.wcomponents.WButton)4 WSuggestions (com.github.bordertech.wcomponents.WSuggestions)4 WTable (com.github.bordertech.wcomponents.WTable)4 WTableColumn (com.github.bordertech.wcomponents.WTableColumn)4 ComponentWithContext (com.github.bordertech.wcomponents.ComponentWithContext)3 TableDataModel (com.github.bordertech.wcomponents.TableDataModel)3 TreeTableDataModel (com.github.bordertech.wcomponents.TreeTableDataModel)3 WDataTable (com.github.bordertech.wcomponents.WDataTable)3 WRepeater (com.github.bordertech.wcomponents.WRepeater)3 TableModel (com.github.bordertech.wcomponents.WTable.TableModel)3 AjaxOperation (com.github.bordertech.wcomponents.AjaxOperation)2