Search in sources :

Example 1 with XmlStringBuilder

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

the class WTableRenderer method paintColumnHeadings.

/**
 * Paints the column headings for the given table.
 *
 * @param table the table to paint the headings for.
 * @param renderContext the RenderContext to paint to.
 */
private void paintColumnHeadings(final WTable table, final WebXmlRenderContext renderContext) {
    XmlStringBuilder xml = renderContext.getWriter();
    int[] columnOrder = table.getColumnOrder();
    TableModel model = table.getTableModel();
    final int columnCount = columnOrder == null ? table.getColumnCount() : columnOrder.length;
    xml.appendTagOpen("ui:thead");
    xml.appendOptionalAttribute("hidden", !table.isShowColumnHeaders(), "true");
    xml.appendClose();
    for (int i = 0; i < columnCount; i++) {
        int colIndex = columnOrder == null ? i : columnOrder[i];
        WTableColumn col = table.getColumn(colIndex);
        if (col.isVisible()) {
            boolean sortable = model.isSortable(colIndex);
            paintColumnHeading(col, sortable, renderContext);
        }
    }
    xml.appendEndTag("ui:thead");
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder) TableModel(com.github.bordertech.wcomponents.WTable.TableModel)

Example 2 with XmlStringBuilder

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

the class WCheckBoxRenderer method doRender.

/**
 * Paints the given WCheckBox.
 *
 * @param component the WCheckBox to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WCheckBox checkBox = (WCheckBox) component;
    XmlStringBuilder xml = renderContext.getWriter();
    boolean readOnly = checkBox.isReadOnly();
    xml.appendTagOpen(TAG_NAME);
    xml.appendAttribute("id", component.getId());
    xml.appendOptionalAttribute("class", component.getHtmlClass());
    xml.appendOptionalAttribute("track", component.isTracking(), "true");
    xml.appendOptionalAttribute("hidden", checkBox.isHidden(), "true");
    xml.appendOptionalAttribute("selected", checkBox.isSelected(), "true");
    if (readOnly) {
        xml.appendAttribute("readOnly", "true");
        xml.appendEnd();
        return;
    }
    WComponent submitControl = checkBox.getDefaultSubmitButton();
    String submitControlId = submitControl == null ? null : submitControl.getId();
    WComponentGroup<WCheckBox> group = checkBox.getGroup();
    String groupName = group == null ? null : group.getId();
    xml.appendOptionalAttribute("groupName", groupName);
    xml.appendOptionalAttribute("disabled", checkBox.isDisabled(), "true");
    xml.appendOptionalAttribute("required", checkBox.isMandatory(), "true");
    xml.appendOptionalAttribute("submitOnChange", checkBox.isSubmitOnChange(), "true");
    xml.appendOptionalAttribute("toolTip", checkBox.getToolTip());
    xml.appendOptionalAttribute("accessibleText", checkBox.getAccessibleText());
    xml.appendOptionalAttribute("buttonId", submitControlId);
    List<Diagnostic> diags = checkBox.getDiagnostics(Diagnostic.ERROR);
    if (diags == null || diags.isEmpty()) {
        xml.appendEnd();
        return;
    }
    xml.appendClose();
    DiagnosticRenderUtil.renderDiagnostics(checkBox, renderContext);
    xml.appendEndTag(TAG_NAME);
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) Diagnostic(com.github.bordertech.wcomponents.validation.Diagnostic) WCheckBox(com.github.bordertech.wcomponents.WCheckBox) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Example 3 with XmlStringBuilder

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

the class WCollapsibleRenderer method doRender.

/**
 * Paints the given WCollapsible.
 *
 * @param component the WCollapsible to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WCollapsible collapsible = (WCollapsible) component;
    XmlStringBuilder xml = renderContext.getWriter();
    WComponent content = collapsible.getContent();
    boolean collapsed = collapsible.isCollapsed();
    xml.appendTagOpen("ui:collapsible");
    xml.appendAttribute("id", component.getId());
    xml.appendOptionalAttribute("class", component.getHtmlClass());
    xml.appendOptionalAttribute("track", component.isTracking(), "true");
    xml.appendAttribute("groupName", collapsible.getGroupName());
    xml.appendOptionalAttribute("collapsed", collapsed, "true");
    xml.appendOptionalAttribute("hidden", collapsible.isHidden(), "true");
    switch(collapsible.getMode()) {
        case CLIENT:
            xml.appendAttribute("mode", "client");
            break;
        case LAZY:
            xml.appendAttribute("mode", "lazy");
            break;
        case EAGER:
            xml.appendAttribute("mode", "eager");
            break;
        case DYNAMIC:
            xml.appendAttribute("mode", "dynamic");
            break;
        case SERVER:
            xml.appendAttribute("mode", "server");
            break;
        default:
            throw new SystemException("Unknown collapsible mode: " + collapsible.getMode());
    }
    HeadingLevel level = collapsible.getHeadingLevel();
    if (level != null) {
        xml.appendAttribute("level", level.getLevel());
    }
    xml.appendClose();
    // Render margin
    MarginRendererUtil.renderMargin(collapsible, renderContext);
    // Label
    collapsible.getDecoratedLabel().paint(renderContext);
    // Content
    xml.appendTagOpen("ui:content");
    xml.appendAttribute("id", component.getId() + "-content");
    xml.appendClose();
    // Render content if not EAGER Mode or is EAGER and is the current AJAX trigger
    if (CollapsibleMode.EAGER != collapsible.getMode() || AjaxHelper.isCurrentAjaxTrigger(collapsible)) {
        // Visibility of content set in prepare paint
        content.paint(renderContext);
    }
    xml.appendEndTag("ui:content");
    xml.appendEndTag("ui:collapsible");
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) WCollapsible(com.github.bordertech.wcomponents.WCollapsible) SystemException(com.github.bordertech.wcomponents.util.SystemException) HeadingLevel(com.github.bordertech.wcomponents.HeadingLevel) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Example 4 with XmlStringBuilder

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

the class DebugStructureInterceptor method paint.

/**
 * Override paint to render additional information for debugging purposes.
 *
 * @param renderContext the renderContext to send the output to.
 */
@Override
public void paint(final RenderContext renderContext) {
    super.paint(renderContext);
    if (!DebugUtil.isDebugFeaturesEnabled() || !(renderContext instanceof WebXmlRenderContext)) {
        return;
    }
    XmlStringBuilder xml = ((WebXmlRenderContext) renderContext).getWriter();
    xml.appendTag("ui:debug");
    writeDebugInfo(getUI(), xml);
    xml.appendEndTag("ui:debug");
}
Also used : WebXmlRenderContext(com.github.bordertech.wcomponents.servlet.WebXmlRenderContext) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Example 5 with XmlStringBuilder

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

the class ColumnLayoutRenderer method doRender.

/**
 * Paints the given WPanel's children.
 *
 * @param component the container to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WPanel panel = (WPanel) component;
    XmlStringBuilder xml = renderContext.getWriter();
    ColumnLayout layout = (ColumnLayout) panel.getLayout();
    int childCount = panel.getChildCount();
    Size hgap = layout.getHorizontalGap();
    String hgapString = hgap == null ? null : hgap.toString();
    Size vgap = layout.getVerticalGap();
    String vgapString = vgap == null ? null : vgap.toString();
    int cols = layout.getColumnCount();
    xml.appendTagOpen("ui:columnlayout");
    xml.appendOptionalAttribute("hgap", hgapString);
    xml.appendOptionalAttribute("vgap", vgapString);
    xml.appendClose();
    // Column Definitions
    for (int col = 0; col < cols; col++) {
        xml.appendTagOpen("ui:column");
        int width = layout.getColumnWidth(col);
        xml.appendOptionalAttribute("width", width > 0, width);
        switch(layout.getColumnAlignment(col)) {
            case LEFT:
                // left is assumed if omitted
                break;
            case RIGHT:
                xml.appendAttribute("align", "right");
                break;
            case CENTER:
                xml.appendAttribute("align", "center");
                break;
            default:
                throw new IllegalArgumentException("Invalid alignment: " + layout.getColumnAlignment(col));
        }
        xml.appendEnd();
    }
    for (int i = 0; i < childCount; i++) {
        xml.appendTag("ui:cell");
        WComponent child = panel.getChildAt(i);
        child.paint(renderContext);
        xml.appendEndTag("ui:cell");
    }
    xml.appendEndTag("ui:columnlayout");
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) Size(com.github.bordertech.wcomponents.Size) WPanel(com.github.bordertech.wcomponents.WPanel) ColumnLayout(com.github.bordertech.wcomponents.layout.ColumnLayout) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Aggregations

XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)105 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)8 OptionGroup (com.github.bordertech.wcomponents.OptionGroup)6 UIContext (com.github.bordertech.wcomponents.UIContext)5 WPanel (com.github.bordertech.wcomponents.WPanel)5 WTableColumn (com.github.bordertech.wcomponents.WTableColumn)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 TableModel (com.github.bordertech.wcomponents.WTable.TableModel)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 AjaxOperation (com.github.bordertech.wcomponents.AjaxOperation)2