use of com.github.bordertech.wcomponents.Margin in project wcomponents by BorderTech.
the class WFigureRenderer_Test method testRenderedWithMargins.
@Test
public void testRenderedWithMargins() throws IOException, SAXException, XpathException {
WFigure figure = new WFigure(new WText(FIGURE_CONTENT), FIGURE_HEADING);
assertXpathNotExists("//ui:figure/ui:margin", figure);
Margin margin = new Margin(0);
figure.setMargin(margin);
assertXpathNotExists("//ui:figure/ui:margin", figure);
margin = new Margin(Size.SMALL);
figure.setMargin(margin);
assertSchemaMatch(figure);
assertXpathEvaluatesTo("sm", "//ui:figure/ui:margin/@all", figure);
assertXpathEvaluatesTo("", "//ui:figure/ui:margin/@north", figure);
assertXpathEvaluatesTo("", "//ui:figure/ui:margin/@east", figure);
assertXpathEvaluatesTo("", "//ui:figure/ui:margin/@south", figure);
assertXpathEvaluatesTo("", "//ui:figure/ui:margin/@west", figure);
margin = new Margin(Size.SMALL, Size.MEDIUM, Size.LARGE, Size.XL);
figure.setMargin(margin);
assertSchemaMatch(figure);
assertXpathEvaluatesTo("", "//ui:figure/ui:margin/@all", figure);
assertXpathEvaluatesTo("sm", "//ui:figure/ui:margin/@north", figure);
assertXpathEvaluatesTo("med", "//ui:figure/ui:margin/@east", figure);
assertXpathEvaluatesTo("lg", "//ui:figure/ui:margin/@south", figure);
assertXpathEvaluatesTo("xl", "//ui:figure/ui:margin/@west", figure);
}
use of com.github.bordertech.wcomponents.Margin in project wcomponents by BorderTech.
the class WHeadingRenderer_Test method testRenderedWithMargins.
@Test
public void testRenderedWithMargins() throws IOException, SAXException, XpathException {
WHeading heading = new WHeading(WHeading.TITLE, "test");
assertXpathNotExists("//ui:heading/ui:margin", heading);
Margin margin = new Margin(0);
heading.setMargin(margin);
assertXpathNotExists("//ui:heading/ui:margin", heading);
margin = new Margin(Size.SMALL);
heading.setMargin(margin);
assertSchemaMatch(heading);
assertXpathEvaluatesTo("sm", "//ui:heading/ui:margin/@all", heading);
assertXpathEvaluatesTo("", "//ui:heading/ui:margin/@north", heading);
assertXpathEvaluatesTo("", "//ui:heading/ui:margin/@east", heading);
assertXpathEvaluatesTo("", "//ui:heading/ui:margin/@south", heading);
assertXpathEvaluatesTo("", "//ui:heading/ui:margin/@west", heading);
margin = new Margin(Size.SMALL, Size.MEDIUM, Size.LARGE, Size.XL);
heading.setMargin(margin);
assertSchemaMatch(heading);
assertXpathEvaluatesTo("", "//ui:heading/ui:margin/@all", heading);
assertXpathEvaluatesTo("sm", "//ui:heading/ui:margin/@north", heading);
assertXpathEvaluatesTo("med", "//ui:heading/ui:margin/@east", heading);
assertXpathEvaluatesTo("lg", "//ui:heading/ui:margin/@south", heading);
assertXpathEvaluatesTo("xl", "//ui:heading/ui:margin/@west", heading);
}
use of com.github.bordertech.wcomponents.Margin in project wcomponents by BorderTech.
the class WMenuRenderer_Test method testRenderedWithMargins.
@Test
public void testRenderedWithMargins() throws IOException, SAXException, XpathException {
WMenu menu = new WMenu();
menu.add(new WMenuItem(""));
assertXpathNotExists("//ui:menu/ui:margin", menu);
Margin margin = new Margin(0);
menu.setMargin(margin);
assertXpathNotExists("//ui:menu/ui:margin", menu);
margin = new Margin(Size.SMALL);
menu.setMargin(margin);
assertSchemaMatch(menu);
assertXpathEvaluatesTo("sm", "//ui:menu/ui:margin/@all", menu);
assertXpathEvaluatesTo("", "//ui:menu/ui:margin/@north", menu);
assertXpathEvaluatesTo("", "//ui:menu/ui:margin/@east", menu);
assertXpathEvaluatesTo("", "//ui:menu/ui:margin/@south", menu);
assertXpathEvaluatesTo("", "//ui:menu/ui:margin/@west", menu);
margin = new Margin(Size.SMALL, Size.MEDIUM, Size.LARGE, Size.XL);
menu.setMargin(margin);
assertSchemaMatch(menu);
assertXpathEvaluatesTo("", "//ui:menu/ui:margin/@all", menu);
assertXpathEvaluatesTo("sm", "//ui:menu/ui:margin/@north", menu);
assertXpathEvaluatesTo("med", "//ui:menu/ui:margin/@east", menu);
assertXpathEvaluatesTo("lg", "//ui:menu/ui:margin/@south", menu);
assertXpathEvaluatesTo("xl", "//ui:menu/ui:margin/@west", menu);
}
use of com.github.bordertech.wcomponents.Margin in project wcomponents by BorderTech.
the class WPanelRenderer_Test method testRenderedWithMargins.
@Test
public void testRenderedWithMargins() throws IOException, SAXException, XpathException {
WPanel panel = new WPanel();
assertXpathNotExists("//ui:panel/ui:margin", panel);
Margin margin = new Margin(0);
panel.setMargin(margin);
assertXpathNotExists("//ui:panel/ui:margin", panel);
margin = new Margin(Size.SMALL);
panel.setMargin(margin);
assertSchemaMatch(panel);
assertXpathEvaluatesTo("sm", "//ui:panel/ui:margin/@all", panel);
assertXpathEvaluatesTo("", "//ui:panel/ui:margin/@north", panel);
assertXpathEvaluatesTo("", "//ui:panel/ui:margin/@east", panel);
assertXpathEvaluatesTo("", "//ui:panel/ui:margin/@south", panel);
assertXpathEvaluatesTo("", "//ui:panel/ui:margin/@west", panel);
margin = new Margin(0, 0, 0, 0);
panel.setMargin(margin);
assertXpathNotExists("//ui:panel/ui:margin", panel);
margin = new Margin(1, 0, 0, 0);
panel.setMargin(margin);
assertXpathExists("//ui:panel/ui:margin", panel);
margin = new Margin(0, 1, 0, 0);
panel.setMargin(margin);
assertXpathExists("//ui:panel/ui:margin", panel);
margin = new Margin(0, 0, 1, 0);
panel.setMargin(margin);
assertXpathExists("//ui:panel/ui:margin", panel);
margin = new Margin(0, 0, 0, 1);
panel.setMargin(margin);
assertXpathExists("//ui:panel/ui:margin", panel);
margin = new Margin(Size.SMALL, Size.MEDIUM, Size.LARGE, Size.XL);
panel.setMargin(margin);
assertSchemaMatch(panel);
assertXpathEvaluatesTo("", "//ui:panel/ui:margin/@all", panel);
assertXpathEvaluatesTo("sm", "//ui:panel/ui:margin/@north", panel);
assertXpathEvaluatesTo("med", "//ui:panel/ui:margin/@east", panel);
assertXpathEvaluatesTo("lg", "//ui:panel/ui:margin/@south", panel);
assertXpathEvaluatesTo("xl", "//ui:panel/ui:margin/@west", panel);
}
use of com.github.bordertech.wcomponents.Margin in project wcomponents by BorderTech.
the class WAudioExample method buildUI.
/**
* Build the UI for this example.
*/
private void buildUI() {
// build the configuration options UI.
WFieldLayout layout = new WFieldLayout(WFieldLayout.LAYOUT_STACKED);
layout.setMargin(new Margin(null, null, Size.LARGE, null));
add(layout);
layout.addField("Autoplay", cbAutoPlay);
layout.addField("Loop", cbLoop);
layout.addField("Disable", cbDisable);
layout.addField("Show only play/pause", cbControls);
layout.addField((WLabel) null, btnApply);
// enable disable option only when control PLAY_PAUSE is used.
WSubordinateControl control = new WSubordinateControl();
add(control);
Rule rule = new Rule();
rule.setCondition(new Equal(cbControls, Boolean.TRUE.toString()));
rule.addActionOnTrue(new Enable(cbDisable));
rule.addActionOnFalse(new Disable(cbDisable));
control.addRule(rule);
// allow config to change without reloading the whole page.
add(new WAjaxControl(btnApply, audio));
// add the audio to the UI
add(audio);
}
Aggregations