use of com.github.bordertech.wcomponents.WColumn in project wcomponents by BorderTech.
the class WRowExample method createRow.
/**
* Creates a row containing columns with the given widths.
*
* @param hgap the horizontal gap between columns, in pixels.
* @param colWidths the percentage widths for each column.
* @return a WRow containing columns with the given widths.
*/
private WRow createRow(final int hgap, final int[] colWidths) {
WRow row = new WRow(hgap);
for (int i = 0; i < colWidths.length; i++) {
WColumn col = new WColumn(colWidths[i]);
WPanel box = new WPanel(WPanel.Type.BOX);
box.add(new WText(colWidths[i] + "%"));
col.add(box);
row.add(col);
}
return row;
}
use of com.github.bordertech.wcomponents.WColumn in project wcomponents by BorderTech.
the class WColumnRenderer method doRender.
/**
* Paints the given WButton.
*
* @param component the WColumn to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WColumn col = (WColumn) component;
XmlStringBuilder xml = renderContext.getWriter();
xml.appendTagOpen("ui:column");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
int width = col.getWidth();
xml.appendOptionalAttribute("width", width > 0, width);
switch(col.getAlignment()) {
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: " + col.getAlignment());
}
xml.appendClose();
// Paint column contents
paintChildren(col, renderContext);
xml.appendEndTag("ui:column");
}
use of com.github.bordertech.wcomponents.WColumn in project wcomponents by BorderTech.
the class WColumnRenderer_Test method testPaintWhenEmpty.
@Test
public void testPaintWhenEmpty() throws IOException, SAXException {
WColumn column = new WColumn(100);
// A Column is not valid by itself, so we must add it to a row.
WRow row = new WRow();
row.add(column);
assertSchemaMatch(row);
}
use of com.github.bordertech.wcomponents.WColumn in project wcomponents by BorderTech.
the class WColumnRenderer_Test method testPaint.
@Test
public void testPaint() throws IOException, SAXException, XpathException {
WRow row = new WRow();
WColumn column = new WColumn(100);
row.add(column);
column.add(new WLabel("dummy"));
assertSchemaMatch(row);
assertXpathEvaluatesTo(column.getId(), "//ui:column/@id", row);
assertXpathEvaluatesTo("100", "//ui:column/@width", row);
assertXpathNotExists("//ui:column/@align", row);
column.setAlignment(WColumn.Alignment.LEFT);
assertSchemaMatch(row);
assertXpathNotExists("//ui:column/@align", row);
column.setAlignment(WColumn.Alignment.CENTER);
assertSchemaMatch(row);
assertXpathEvaluatesTo("center", "//ui:column/@align", row);
column.setAlignment(WColumn.Alignment.RIGHT);
assertSchemaMatch(row);
assertXpathEvaluatesTo("right", "//ui:column/@align", row);
}
use of com.github.bordertech.wcomponents.WColumn in project wcomponents by BorderTech.
the class WRowExample method createRow.
/**
* Creates a row containing columns with the given widths.
*
* @param gap the horizontal gap between columns
* @param colWidths the percentage widths for each column
* @return a WRow containing columns with the given widths
*/
private WRow createRow(final Size gap, final int[] colWidths) {
WRow row = new WRow(gap);
for (int i = 0; i < colWidths.length; i++) {
WColumn col = new WColumn(colWidths[i]);
WPanel box = new WPanel(WPanel.Type.BOX);
box.add(new WText(colWidths[i] + "%"));
col.add(box);
row.add(col);
}
return row;
}
Aggregations