Search in sources :

Example 11 with Margin

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);
}
Also used : WFigure(com.github.bordertech.wcomponents.WFigure) WText(com.github.bordertech.wcomponents.WText) Margin(com.github.bordertech.wcomponents.Margin) Test(org.junit.Test)

Example 12 with Margin

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);
}
Also used : WHeading(com.github.bordertech.wcomponents.WHeading) Margin(com.github.bordertech.wcomponents.Margin) Test(org.junit.Test)

Example 13 with Margin

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);
}
Also used : WMenuItem(com.github.bordertech.wcomponents.WMenuItem) WMenu(com.github.bordertech.wcomponents.WMenu) Margin(com.github.bordertech.wcomponents.Margin) Test(org.junit.Test)

Example 14 with Margin

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);
}
Also used : WPanel(com.github.bordertech.wcomponents.WPanel) Margin(com.github.bordertech.wcomponents.Margin) Test(org.junit.Test)

Example 15 with Margin

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);
}
Also used : WAjaxControl(com.github.bordertech.wcomponents.WAjaxControl) Equal(com.github.bordertech.wcomponents.subordinate.Equal) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) WSubordinateControl(com.github.bordertech.wcomponents.subordinate.WSubordinateControl) Enable(com.github.bordertech.wcomponents.subordinate.Enable) Rule(com.github.bordertech.wcomponents.subordinate.Rule) Disable(com.github.bordertech.wcomponents.subordinate.Disable) Margin(com.github.bordertech.wcomponents.Margin)

Aggregations

Margin (com.github.bordertech.wcomponents.Margin)25 Test (org.junit.Test)13 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)10 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)6 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)4 WFieldSet (com.github.bordertech.wcomponents.WFieldSet)4 WHeading (com.github.bordertech.wcomponents.WHeading)4 WText (com.github.bordertech.wcomponents.WText)4 WTextField (com.github.bordertech.wcomponents.WTextField)4 Action (com.github.bordertech.wcomponents.Action)3 WButton (com.github.bordertech.wcomponents.WButton)3 WPanel (com.github.bordertech.wcomponents.WPanel)3 WLabel (com.github.bordertech.wcomponents.WLabel)2 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)2 FlowLayout (com.github.bordertech.wcomponents.layout.FlowLayout)2 Disable (com.github.bordertech.wcomponents.subordinate.Disable)2 Enable (com.github.bordertech.wcomponents.subordinate.Enable)2 Equal (com.github.bordertech.wcomponents.subordinate.Equal)2 Rule (com.github.bordertech.wcomponents.subordinate.Rule)2 WSubordinateControl (com.github.bordertech.wcomponents.subordinate.WSubordinateControl)2