use of com.github.bordertech.wcomponents.layout.BorderLayout in project wcomponents by BorderTech.
the class ObjectGraphDump_Test method testDump.
@Test
public void testDump() {
WPanel component = new WPanel();
component.setLayout(new BorderLayout());
component.add(new WLabel(TEST_LABEL), BorderLayout.NORTH);
ObjectGraphNode graphNode = ObjectGraphDump.dump(component);
String result = graphNode.toXml();
// ObjectGraphNode tested independently
// for the input 'component' above - the dump result must at least contain the following
// and have run without exceptions
Assert.assertTrue("", result.indexOf("type=\"com.github.bordertech.wcomponents.WPanel\"") != -1);
Assert.assertTrue("", result.indexOf("field=\"label\" type=\"com.github.bordertech.wcomponents.WLabel\"") != -1);
Assert.assertTrue("", result.indexOf("field=\"text\" value=\""" + TEST_LABEL + ""\" type=\"java.io.Serializable\"") != -1);
Assert.assertTrue("", result.indexOf("field=\"value\" type=\"com.github.bordertech.wcomponents.layout.BorderLayout$BorderLayoutConstraint\"") != -1);
}
use of com.github.bordertech.wcomponents.layout.BorderLayout in project wcomponents by BorderTech.
the class RepeaterExampleWithStaticIDs method createButtonBar.
/**
* Create the UI artefacts for the update and reset buttons.
*/
private void createButtonBar() {
// Update and reset controls for the repeater.
WPanel buttonPanel = new WPanel(WPanel.Type.FEATURE);
buttonPanel.setMargin(new Margin(Size.MEDIUM, null, Size.LARGE, null));
buttonPanel.setLayout(new BorderLayout());
WButton updateButton = new WButton("Update");
updateButton.setImage("/image/document-save-5.png");
updateButton.setImagePosition(WButton.ImagePosition.EAST);
buttonPanel.add(updateButton, BorderLayout.EAST);
WButton resetButton = new WButton("Reset");
resetButton.setImage("/image/edit-undo-8.png");
resetButton.setImagePosition(WButton.ImagePosition.WEST);
resetButton.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
repeater.setData(fetchDataList());
}
});
buttonPanel.add(resetButton, BorderLayout.WEST);
add(buttonPanel);
add(new WAjaxControl(updateButton, repeater));
add(new WAjaxControl(resetButton, repeater));
}
use of com.github.bordertech.wcomponents.layout.BorderLayout in project wcomponents by BorderTech.
the class BorderLayoutRenderer 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();
BorderLayout layout = (BorderLayout) panel.getLayout();
Size hgap = layout.getHorizontalGap();
String hgapString = hgap == null ? null : hgap.toString();
Size vgap = layout.getVerticalGap();
String vgapString = vgap == null ? null : vgap.toString();
xml.appendTagOpen("ui:borderlayout");
xml.appendOptionalAttribute("hgap", hgapString);
xml.appendOptionalAttribute("vgap", vgapString);
xml.appendClose();
// Fetch the children and their constraints.
final int childCount = panel.getChildCount();
List<Duplet<WComponent, BorderLayoutConstraint>> children = new ArrayList<>(childCount);
for (int i = 0; i < childCount; i++) {
WComponent child = panel.getChildAt(i);
children.add(new Duplet<>(child, getConstraints(panel, child)));
}
// Now paint them
paintChildrenWithConstraint(children, renderContext, BorderLayout.NORTH);
paintChildrenWithConstraint(children, renderContext, BorderLayout.EAST);
paintChildrenWithConstraint(children, renderContext, BorderLayout.SOUTH);
paintChildrenWithConstraint(children, renderContext, BorderLayout.WEST);
paintChildrenWithConstraint(children, renderContext, BorderLayout.CENTER);
xml.appendEndTag("ui:borderlayout");
}
use of com.github.bordertech.wcomponents.layout.BorderLayout in project wcomponents by BorderTech.
the class BorderLayoutRenderer_Test method testDoRenderWhenEmpty.
@Test
public void testDoRenderWhenEmpty() throws IOException, SAXException, XpathException {
WPanel container = new WPanel();
container.setLayout(new BorderLayout());
assertSchemaMatch(container);
assertXpathExists("//ui:panel/ui:borderlayout", container);
assertXpathNotExists("//ui:panel/ui:borderlayout/@hgap", container);
assertXpathNotExists("//ui:panel/ui:borderlayout/@vgap", container);
assertXpathNotExists("//ui:panel/ui:borderlayout/ui:north", container);
assertXpathNotExists("//ui:panel/ui:borderlayout/ui:south", container);
assertXpathNotExists("//ui:panel/ui:borderlayout/ui:east", container);
assertXpathNotExists("//ui:panel/ui:borderlayout/ui:west", container);
assertXpathNotExists("//ui:panel/ui:borderlayout/ui:center", container);
}
use of com.github.bordertech.wcomponents.layout.BorderLayout in project wcomponents by BorderTech.
the class BorderLayoutRenderer_Test method testDoRender.
@Test
public void testDoRender() throws IOException, SAXException, XpathException {
final String northText = "BorderRenderer_Test.testPaint.northText";
final String westText = "BorderRenderer_Test.testPaint.westText";
final String southText = "BorderRenderer_Test.testPaint.southText";
final String eastText = "BorderRenderer_Test.testPaint.eastText";
final String centerText = "BorderRenderer_Test.testPaint.centerText";
WPanel container = new WPanel();
container.setLayout(new BorderLayout(GAP, BIG_GAP));
assertSchemaMatch(container);
assertXpathEvaluatesTo(GAP.toString(), "//ui:panel/ui:borderlayout/@hgap", container);
assertXpathEvaluatesTo(BIG_GAP.toString(), "//ui:panel/ui:borderlayout/@vgap", container);
assertXpathNotExists("//ui:panel/ui:borderlayout/ui:north", container);
assertXpathNotExists("//ui:panel/ui:borderlayout/ui:south", container);
assertXpathNotExists("//ui:panel/ui:borderlayout/ui:east", container);
assertXpathNotExists("//ui:panel/ui:borderlayout/ui:west", container);
assertXpathNotExists("//ui:panel/ui:borderlayout/ui:center", container);
container.add(new WText(northText), BorderLayout.NORTH);
container.add(new WText(westText), BorderLayout.WEST);
assertXpathEvaluatesTo(northText, "normalize-space(//ui:panel/ui:borderlayout/ui:north)", container);
assertXpathNotExists("//ui:panel/ui:borderlayout/ui:south", container);
assertXpathNotExists("//ui:panel/ui:borderlayout/ui:east", container);
assertXpathEvaluatesTo(westText, "normalize-space(//ui:panel/ui:borderlayout/ui:west)", container);
assertXpathNotExists("//ui:panel/ui:borderlayout/ui:center", container);
container.add(new WText(southText), BorderLayout.SOUTH);
container.add(new WText(eastText), BorderLayout.EAST);
container.add(new WText(centerText));
assertXpathEvaluatesTo(northText, "normalize-space(//ui:panel/ui:borderlayout/ui:north)", container);
assertXpathEvaluatesTo(westText, "normalize-space(//ui:panel/ui:borderlayout/ui:west)", container);
assertXpathEvaluatesTo(southText, "normalize-space(//ui:panel/ui:borderlayout/ui:south)", container);
assertXpathEvaluatesTo(eastText, "normalize-space(//ui:panel/ui:borderlayout/ui:east)", container);
assertXpathEvaluatesTo(centerText, "normalize-space(//ui:panel/ui:borderlayout/ui:center)", container);
}
Aggregations