Search in sources :

Example 16 with WPanel

use of com.github.bordertech.wcomponents.WPanel 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;
}
Also used : WText(com.github.bordertech.wcomponents.WText) WPanel(com.github.bordertech.wcomponents.WPanel) WRow(com.github.bordertech.wcomponents.WRow) WColumn(com.github.bordertech.wcomponents.WColumn)

Example 17 with WPanel

use of com.github.bordertech.wcomponents.WPanel in project wcomponents by BorderTech.

the class AbstractSetMandatory_Test method testExecuteWithWPanel.

@Test
public void testExecuteWithWPanel() {
    // Setup targets in a Panel
    WPanel panel = new WPanel();
    MyTarget target1 = new MyTarget();
    MyTarget target2 = new MyTarget();
    MyTarget target3 = new MyTarget();
    panel.add(target1);
    panel.add(target2);
    panel.add(target3);
    AbstractSetMandatory enable = new MyMandatory(panel, Boolean.TRUE);
    // Targets should be optional by default
    Assert.assertFalse("WPanel - Target1 should be optional", target1.isMandatory());
    Assert.assertFalse("WPanel - Target2 should be optional", target2.isMandatory());
    Assert.assertFalse("WPanel - Target3 should be optional", target3.isMandatory());
    enable.execute();
    // Targets should be mandatory
    Assert.assertTrue("WPanel - Target1 should be mandatory", target1.isMandatory());
    Assert.assertTrue("WPanel - Target2 should be mandatory", target2.isMandatory());
    Assert.assertTrue("WPanel - Target3 should be mandatory", target3.isMandatory());
}
Also used : WPanel(com.github.bordertech.wcomponents.WPanel) Test(org.junit.Test)

Example 18 with WPanel

use of com.github.bordertech.wcomponents.WPanel in project wcomponents by BorderTech.

the class TargetableInterceptor_Test method setUp.

@Before
public void setUp() {
    UIContext uic = new UIContextImpl();
    WPanel root = new WPanel();
    originalUI = new WLabel();
    targetUI = new TargetableWLabel();
    root.add(originalUI);
    root.add(targetUI);
    uic.setUI(root);
    setActiveContext(uic);
    interceptor = new TargetableInterceptor();
    interceptor.setBackingComponent(originalUI);
}
Also used : UIContext(com.github.bordertech.wcomponents.UIContext) UIContextImpl(com.github.bordertech.wcomponents.UIContextImpl) WPanel(com.github.bordertech.wcomponents.WPanel) WLabel(com.github.bordertech.wcomponents.WLabel) Before(org.junit.Before)

Example 19 with WPanel

use of com.github.bordertech.wcomponents.WPanel in project wcomponents by BorderTech.

the class ColumnLayoutRenderer_Test method testDoRenderWhenEmpty.

@Test
public void testDoRenderWhenEmpty() throws IOException, SAXException, XpathException {
    WPanel container = new WPanel();
    container.setLayout(new ColumnLayout(new int[] { 50, 50 }));
    assertSchemaMatch(container);
    assertXpathNotExists("//ui:panel/ui:columnlayout/ui:cell", container);
}
Also used : WPanel(com.github.bordertech.wcomponents.WPanel) ColumnLayout(com.github.bordertech.wcomponents.layout.ColumnLayout) Test(org.junit.Test)

Example 20 with WPanel

use of com.github.bordertech.wcomponents.WPanel in project wcomponents by BorderTech.

the class FlowLayoutRenderer_Test method testDoRenderWithContent.

@Test
public void testDoRenderWithContent() throws IOException, SAXException, XpathException {
    final String text1 = "FlowRenderer_Test.testPaint.text1";
    final String text2 = "FlowRenderer_Test.testPaint.text2";
    WPanel panel = new WPanel();
    panel.setLayout(new FlowLayout());
    assertSchemaMatch(panel);
    panel.add(new WText(text1));
    panel.add(new WText(text2));
    assertSchemaMatch(panel);
    assertXpathEvaluatesTo("2", "count(//ui:panel/ui:flowlayout/ui:cell)", panel);
    assertXpathEvaluatesTo(text1, "normalize-space(//ui:panel/ui:flowlayout/ui:cell[1])", panel);
    assertXpathEvaluatesTo(text2, "normalize-space(//ui:panel/ui:flowlayout/ui:cell[2])", panel);
}
Also used : FlowLayout(com.github.bordertech.wcomponents.layout.FlowLayout) WText(com.github.bordertech.wcomponents.WText) WPanel(com.github.bordertech.wcomponents.WPanel) Test(org.junit.Test)

Aggregations

WPanel (com.github.bordertech.wcomponents.WPanel)77 Test (org.junit.Test)39 WHeading (com.github.bordertech.wcomponents.WHeading)17 WText (com.github.bordertech.wcomponents.WText)17 FlowLayout (com.github.bordertech.wcomponents.layout.FlowLayout)16 WButton (com.github.bordertech.wcomponents.WButton)13 ColumnLayout (com.github.bordertech.wcomponents.layout.ColumnLayout)10 WContainer (com.github.bordertech.wcomponents.WContainer)9 WHorizontalRule (com.github.bordertech.wcomponents.WHorizontalRule)9 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)8 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)8 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)7 WLabel (com.github.bordertech.wcomponents.WLabel)7 Action (com.github.bordertech.wcomponents.Action)6 WTextField (com.github.bordertech.wcomponents.WTextField)6 ArrayList (java.util.ArrayList)6 Size (com.github.bordertech.wcomponents.Size)5 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)5 BorderLayout (com.github.bordertech.wcomponents.layout.BorderLayout)5 Alignment (com.github.bordertech.wcomponents.layout.ColumnLayout.Alignment)5