Search in sources :

Example 6 with WRow

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

the class WRowRenderer method doRender.

/**
 * Paints the given WButton.
 *
 * @param component the WRow to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WRow row = (WRow) component;
    XmlStringBuilder xml = renderContext.getWriter();
    int cols = row.getChildCount();
    Size gap = row.getSpace();
    String gapString = gap != null ? gap.toString() : null;
    if (cols > 0) {
        xml.appendTagOpen("ui:row");
        xml.appendAttribute("id", component.getId());
        xml.appendOptionalAttribute("class", component.getHtmlClass());
        xml.appendOptionalAttribute("track", component.isTracking(), "true");
        xml.appendOptionalAttribute("gap", gapString);
        xml.appendClose();
        // Render margin
        MarginRendererUtil.renderMargin(row, renderContext);
        paintChildren(row, renderContext);
        xml.appendEndTag("ui:row");
    }
}
Also used : Size(com.github.bordertech.wcomponents.Size) WRow(com.github.bordertech.wcomponents.WRow) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Example 7 with WRow

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

the class WRowRenderer_Test method testRenderedFormatWhenEmpty.

@Test
public void testRenderedFormatWhenEmpty() throws IOException, SAXException, XpathException {
    WRow row = new WRow();
    assertSchemaMatch(row);
    assertXpathNotExists("//ui:row", row);
}
Also used : WRow(com.github.bordertech.wcomponents.WRow) Test(org.junit.Test)

Example 8 with WRow

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

the class WRowRenderer_Test method testRenderedWithMargins.

@Test
public void testRenderedWithMargins() throws IOException, SAXException, XpathException {
    WRow row = new WRow();
    row.add(new WColumn(100));
    assertXpathNotExists("//ui:row/ui:margin", row);
    Margin margin = new Margin(0);
    row.setMargin(margin);
    assertXpathNotExists("//ui:row/ui:margin", row);
    margin = new Margin(GAP);
    row.setMargin(margin);
    assertSchemaMatch(row);
    assertXpathEvaluatesTo(GAP.toString(), "//ui:row/ui:margin/@all", row);
    assertXpathEvaluatesTo("", "//ui:row/ui:margin/@north", row);
    assertXpathEvaluatesTo("", "//ui:row/ui:margin/@east", row);
    assertXpathEvaluatesTo("", "//ui:row/ui:margin/@south", row);
    assertXpathEvaluatesTo("", "//ui:row/ui:margin/@west", row);
    margin = new Margin(Size.SMALL, Size.MEDIUM, Size.LARGE, Size.XL);
    row.setMargin(margin);
    assertSchemaMatch(row);
    assertXpathEvaluatesTo("", "//ui:row/ui:margin/@all", row);
    assertXpathEvaluatesTo(Size.SMALL.toString(), "//ui:row/ui:margin/@north", row);
    assertXpathEvaluatesTo(Size.MEDIUM.toString(), "//ui:row/ui:margin/@east", row);
    assertXpathEvaluatesTo(Size.LARGE.toString(), "//ui:row/ui:margin/@south", row);
    assertXpathEvaluatesTo(Size.XL.toString(), "//ui:row/ui:margin/@west", row);
}
Also used : WRow(com.github.bordertech.wcomponents.WRow) WColumn(com.github.bordertech.wcomponents.WColumn) Margin(com.github.bordertech.wcomponents.Margin) Test(org.junit.Test)

Example 9 with WRow

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

the class WRowRenderer_Test method testRendererCorrectlyConfigured.

@Test
public void testRendererCorrectlyConfigured() {
    WRow component = new WRow();
    Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(component) instanceof WRowRenderer);
}
Also used : WRow(com.github.bordertech.wcomponents.WRow) Test(org.junit.Test)

Example 10 with WRow

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

the class WRowRenderer_Test method testRenderedFormatWithColumn.

@Test
public void testRenderedFormatWithColumn() throws IOException, SAXException, XpathException {
    WRow row = new WRow();
    row.add(new WColumn(100));
    assertSchemaMatch(row);
    assertXpathExists("//ui:row/ui:column", row);
    assertXpathEvaluatesTo(row.getId(), "//ui:row/@id", row);
    assertXpathEvaluatesTo("", "//ui:row/@gap", row);
}
Also used : WRow(com.github.bordertech.wcomponents.WRow) WColumn(com.github.bordertech.wcomponents.WColumn) Test(org.junit.Test)

Aggregations

WRow (com.github.bordertech.wcomponents.WRow)11 WColumn (com.github.bordertech.wcomponents.WColumn)8 Test (org.junit.Test)7 WText (com.github.bordertech.wcomponents.WText)3 WPanel (com.github.bordertech.wcomponents.WPanel)2 Margin (com.github.bordertech.wcomponents.Margin)1 Size (com.github.bordertech.wcomponents.Size)1 WHeading (com.github.bordertech.wcomponents.WHeading)1 WLabel (com.github.bordertech.wcomponents.WLabel)1 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)1 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)1