Search in sources :

Example 6 with WFieldSet

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

the class WListOptionsExample method getListControls.

/**
 * build the list controls field set.
 *
 * @return a field set for the controls.
 */
private WFieldSet getListControls() {
    // Options Layout
    WFieldSet fieldSet = new WFieldSet("List configuration");
    WFieldLayout layout = new WFieldLayout();
    // options.
    layout.addField("Type", ddType);
    layout.addField("Separator", ddSeparator);
    layout.addField("Render fields", cgBeanFields);
    layout.addField("Render Border", cbRenderBorder);
    layout.addField("Render using field layout", cbRenderUsingFieldLayout);
    layout.addField("Visible", cbVisible);
    // Apply Button
    WButton apply = new WButton("Apply");
    apply.setAction(new com.github.bordertech.wcomponents.Action() {

        @Override
        public void execute(final ActionEvent event) {
            applySettings();
        }
    });
    fieldSet.add(layout);
    fieldSet.add(apply);
    return fieldSet;
}
Also used : WFieldSet(com.github.bordertech.wcomponents.WFieldSet) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) WButton(com.github.bordertech.wcomponents.WButton)

Example 7 with WFieldSet

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

the class AbstractSetMandatory_Test method testExecute.

@Test
public void testExecute() {
    // ---------------------
    // Valid Target (WInput) and TRUE Boolean Value
    SubordinateTarget target1 = new MyTarget();
    AbstractSetMandatory mandatory = new MyMandatory(target1, Boolean.TRUE);
    // Should be mandatory
    mandatory.execute();
    Assert.assertTrue("Target (Mandatable) should be mandatory", ((Mandatable) target1).isMandatory());
    // FALSE Boolean Value
    mandatory = new MyMandatory(target1, Boolean.FALSE);
    // Should not be mandatory
    mandatory.execute();
    Assert.assertFalse("Target (Mandatable) should not be mandatory", ((Mandatable) target1).isMandatory());
    // ---------------------
    // Valid Target (WField) and TRUE Boolean Value
    Input textArea = new WTextArea();
    WField target2 = new WFieldLayout().addField("test", textArea);
    mandatory = new MyMandatory(target2, Boolean.TRUE);
    // Should be mandatory
    mandatory.execute();
    Assert.assertTrue("Target (WField) should be mandatory", textArea.isMandatory());
    // FALSE Boolean Value
    mandatory = new MyMandatory(target2, Boolean.FALSE);
    // Should not be mandatory
    mandatory.execute();
    Assert.assertFalse("Target (WField) should not be mandatory", textArea.isMandatory());
    // ---------------------
    // Valid Target (WFieldSet) and TRUE Boolean Value
    WFieldSet target3 = new WFieldSet("Test");
    mandatory = new MyMandatory(target3, Boolean.TRUE);
    // Should be mandatory
    mandatory.execute();
    Assert.assertTrue("Target (WFieldSet) should be mandatory", target3.isMandatory());
    // FALSE Boolean Value
    mandatory = new MyMandatory(target3, Boolean.FALSE);
    // Should not be mandatory
    mandatory.execute();
    Assert.assertFalse("Target (WFieldSet) should not be mandatory", target3.isMandatory());
    // ---------------------
    // Invalid Target (Cannot be set Mandatory) and Boolean Value
    MyInvalidTarget target4 = new MyInvalidTarget();
    mandatory = new MyMandatory(target4, Boolean.TRUE);
    // Should do nothing
    mandatory.execute();
}
Also used : WTextArea(com.github.bordertech.wcomponents.WTextArea) SubordinateTarget(com.github.bordertech.wcomponents.SubordinateTarget) Input(com.github.bordertech.wcomponents.Input) WField(com.github.bordertech.wcomponents.WField) WFieldSet(com.github.bordertech.wcomponents.WFieldSet) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) Test(org.junit.Test)

Example 8 with WFieldSet

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

the class WFieldSetRenderer_Test method testRenderedWithMargins.

@Test
public void testRenderedWithMargins() throws IOException, SAXException, XpathException {
    WFieldSet fieldSet = new WFieldSet("");
    assertXpathNotExists("//ui:fieldset/ui:margin", fieldSet);
    Margin margin = new Margin(0);
    fieldSet.setMargin(margin);
    assertXpathNotExists("//ui:fieldset/ui:margin", fieldSet);
    margin = new Margin(Size.SMALL);
    fieldSet.setMargin(margin);
    assertSchemaMatch(fieldSet);
    assertXpathEvaluatesTo("sm", "//ui:fieldset/ui:margin/@all", fieldSet);
    assertXpathEvaluatesTo("", "//ui:fieldset/ui:margin/@north", fieldSet);
    assertXpathEvaluatesTo("", "//ui:fieldset/ui:margin/@east", fieldSet);
    assertXpathEvaluatesTo("", "//ui:fieldset/ui:margin/@south", fieldSet);
    assertXpathEvaluatesTo("", "//ui:fieldset/ui:margin/@west", fieldSet);
    margin = new Margin(Size.SMALL, Size.MEDIUM, Size.LARGE, Size.XL);
    fieldSet.setMargin(margin);
    assertSchemaMatch(fieldSet);
    assertXpathEvaluatesTo("", "//ui:fieldset/ui:margin/@all", fieldSet);
    assertXpathEvaluatesTo("sm", "//ui:fieldset/ui:margin/@north", fieldSet);
    assertXpathEvaluatesTo("med", "//ui:fieldset/ui:margin/@east", fieldSet);
    assertXpathEvaluatesTo("lg", "//ui:fieldset/ui:margin/@south", fieldSet);
    assertXpathEvaluatesTo("xl", "//ui:fieldset/ui:margin/@west", fieldSet);
}
Also used : WFieldSet(com.github.bordertech.wcomponents.WFieldSet) Margin(com.github.bordertech.wcomponents.Margin) Test(org.junit.Test)

Example 9 with WFieldSet

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

the class WFieldSetRenderer_Test method testDoPaint.

@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
    final String title = "WFieldSetRenderer_Test.testDoPaint.title";
    WTextField text = new WTextField();
    WFieldSet fieldSet = new WFieldSet(title);
    fieldSet.add(text);
    text.setText("text1");
    assertSchemaMatch(fieldSet);
    // Check Attributes
    assertXpathEvaluatesTo(fieldSet.getId(), "//ui:fieldset/@id", fieldSet);
    assertXpathNotExists("//ui:fieldset/@frame", fieldSet);
    // Check Input
    assertXpathEvaluatesTo(text.getText(), "//ui:fieldset/ui:content/ui:textfield", fieldSet);
    fieldSet.setFrameType(FrameType.NO_BORDER);
    assertXpathEvaluatesTo("noborder", "//ui:fieldset/@frame", fieldSet);
    fieldSet.setFrameType(FrameType.NO_TEXT);
    assertXpathEvaluatesTo("notext", "//ui:fieldset/@frame", fieldSet);
    fieldSet.setFrameType(FrameType.NONE);
    assertXpathEvaluatesTo("none", "//ui:fieldset/@frame", fieldSet);
}
Also used : WFieldSet(com.github.bordertech.wcomponents.WFieldSet) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 10 with WFieldSet

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

the class WFieldSetRenderer_Test method testRendererCorrectlyConfigured.

/**
 * Test the Layout is correctly configured.
 */
@Test
public void testRendererCorrectlyConfigured() {
    WFieldSet fieldSet = new WFieldSet("dummy");
    Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(fieldSet) instanceof WFieldSetRenderer);
}
Also used : WFieldSet(com.github.bordertech.wcomponents.WFieldSet) Test(org.junit.Test)

Aggregations

WFieldSet (com.github.bordertech.wcomponents.WFieldSet)17 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)10 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)6 Test (org.junit.Test)6 WButton (com.github.bordertech.wcomponents.WButton)5 Margin (com.github.bordertech.wcomponents.Margin)4 WLabel (com.github.bordertech.wcomponents.WLabel)4 WField (com.github.bordertech.wcomponents.WField)3 WTextField (com.github.bordertech.wcomponents.WTextField)3 Action (com.github.bordertech.wcomponents.Action)2 RadioButtonGroup (com.github.bordertech.wcomponents.RadioButtonGroup)2 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)2 WDateField (com.github.bordertech.wcomponents.WDateField)2 WDropdown (com.github.bordertech.wcomponents.WDropdown)2 WHeading (com.github.bordertech.wcomponents.WHeading)2 WRadioButton (com.github.bordertech.wcomponents.WRadioButton)2 WTextArea (com.github.bordertech.wcomponents.WTextArea)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