use of com.github.bordertech.wcomponents.WList in project wcomponents by BorderTech.
the class WListExample method preparePaintComponent.
/**
* Override preparePaintComponent to perform initialisation the first time through.
*
* @param request the request being responded to.
*/
@Override
public void preparePaintComponent(final Request request) {
if (!isInitialised()) {
List<SimpleTableBean> items = new ArrayList<>();
items.add(new SimpleTableBean("A", "none", "thing"));
items.add(new SimpleTableBean("B", "some", "thing2"));
items.add(new SimpleTableBean("C", "little", "thing3"));
items.add(new SimpleTableBean("D", "lots", "thing4"));
for (WList list : lists) {
list.setData(items);
}
setInitialised(true);
}
}
use of com.github.bordertech.wcomponents.WList in project wcomponents by BorderTech.
the class WListExample method addList.
/**
* Adds a list to the example.
*
* @param type the list type.
* @param separator the list item separator.
* @param renderBorder true to render a border around the list, false otherwise.
* @param renderer the component to use to render items in the list.
*/
private void addList(final WList.Type type, final WList.Separator separator, final boolean renderBorder, final WComponent renderer) {
WList list = new WList(type);
if (separator != null) {
list.setSeparator(separator);
}
list.setRenderBorder(renderBorder);
list.setRepeatedComponent(renderer);
add(list);
lists.add(list);
}
use of com.github.bordertech.wcomponents.WList in project wcomponents by BorderTech.
the class WListRenderer method doRender.
/**
* Paints the given WList.
*
* @param component the WList to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WList list = (WList) component;
XmlStringBuilder xml = renderContext.getWriter();
WList.Type type = list.getType();
WList.Separator separator = list.getSeparator();
Size gap = list.getSpace();
String gapString = gap == null ? null : gap.toString();
xml.appendTagOpen("ui:panel");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("type", list.isRenderBorder(), "box");
xml.appendClose();
// Render margin
MarginRendererUtil.renderMargin(list, renderContext);
xml.appendTagOpen("ui:listlayout");
xml.appendOptionalAttribute("gap", gapString);
if (type != null) {
switch(type) {
case FLAT:
xml.appendAttribute("type", "flat");
break;
case STACKED:
xml.appendAttribute("type", "stacked");
break;
case STRIPED:
xml.appendAttribute("type", "striped");
break;
default:
throw new SystemException("Unknown list type: " + type);
}
}
if (separator != null) {
switch(separator) {
case BAR:
xml.appendAttribute("separator", "bar");
break;
case DOT:
xml.appendAttribute("separator", "dot");
break;
case NONE:
break;
default:
throw new SystemException("Unknown list type: " + type);
}
}
xml.appendClose();
paintRows(list, renderContext);
xml.appendEndTag("ui:listlayout");
xml.appendEndTag("ui:panel");
}
use of com.github.bordertech.wcomponents.WList in project wcomponents by BorderTech.
the class WListRenderer_Test method testRenderedFormatNoBorder.
@Test
public void testRenderedFormatNoBorder() throws IOException, SAXException {
// non-empty list, no border
WList list = new WList(WList.Type.STRIPED);
list.setRepeatedComponent(new WText());
setActiveContext(createUIContext());
list.setData(Arrays.asList(new String[] { "row1", "row2", "row3" }));
assertSchemaMatch(list);
}
use of com.github.bordertech.wcomponents.WList in project wcomponents by BorderTech.
the class WListOptionsExample method applySettings.
/**
* Apply settings is responsible for building the list to be displayed and adding it to the container.
*/
private void applySettings() {
container.reset();
WList list = new WList((com.github.bordertech.wcomponents.WList.Type) ddType.getSelected());
List<String> selected = (List<String>) cgBeanFields.getSelected();
SimpleListRenderer renderer = new SimpleListRenderer(selected, cbRenderUsingFieldLayout.isSelected());
list.setRepeatedComponent(renderer);
list.setSeparator((Separator) ddSeparator.getSelected());
list.setRenderBorder(cbRenderBorder.isSelected());
container.add(list);
List<SimpleTableBean> items = new ArrayList<>();
items.add(new SimpleTableBean("A", "none", "thing"));
items.add(new SimpleTableBean("B", "some", "thing2"));
items.add(new SimpleTableBean("C", "little", "thing3"));
items.add(new SimpleTableBean("D", "lots", "thing4"));
list.setData(items);
list.setVisible(cbVisible.isSelected());
}
Aggregations