Search in sources :

Example 11 with WFieldSet

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

the class LinkOptionsExample method getButtonControls.

/**
 * build the button controls field set.
 *
 * @param errors the error pane from the page.
 * @return a field set for the controls.
 */
private WFieldSet getButtonControls(final WValidationErrors errors) {
    // Options Layout
    WFieldSet fieldSet = new WFieldSet("Link configuration");
    WFieldLayout layout = new WFieldLayout();
    layout.setLabelWidth(30);
    layout.addField("Link text", tfLinkLabel);
    layout.addField("Link address", tfUrlField);
    layout.addField("Link AccessKey", tfAccesskey).getLabel().setHint("A single upper case letter or digit.");
    layout.addField("Render as button", cbRenderAsButton);
    layout.addField("Disabled", cbDisabled);
    layout.addField("Open in a new window", cbOpenNew);
    layout.addField("setImage ('/image/attachment.png')", cbSetImage);
    layout.addField("Image Position", ddImagePosition);
    layout.setMargin(new com.github.bordertech.wcomponents.Margin(0, 0, 6, 0));
    // Apply Button
    WButton apply = new WButton("Apply");
    apply.setAction(new ValidatingAction(errors, fieldSet) {

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

Example 12 with WFieldSet

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

the class WRadioButtonTriggerActionExample method setup.

/**
 * Add controls to the UI.
 */
private void setup() {
    setLayout(new FlowLayout(FlowLayout.VERTICAL));
    WFieldSet fset = new WFieldSet("Select a meal");
    add(fset);
    fset.setMargin(new Margin(null, null, Size.LARGE, null));
    WFieldLayout flay = new WFieldLayout(WFieldLayout.LAYOUT_STACKED);
    fset.add(flay);
    flay.setLabelWidth(0);
    flay.addField("Breakfast", rb1);
    flay.addField("Lunch", rb2);
    flay.addField("Dinner", rb3);
    /*
		 * NOTE: you should never use submitOnChange with a WRadioButton
		 */
    fset.add(new WAjaxControl(mealSelections, textBox));
    mealSelections.setActionOnChange(new Action() {

        @Override
        public void execute(final ActionEvent event) {
            String selection = null;
            if (rb1.isSelected()) {
                selection = "Breakfast selected";
            }
            if (rb2.isSelected()) {
                selection = "Lunch selected";
            }
            if (rb3.isSelected()) {
                selection = "Dinner selected";
            }
            text1.setText(selection + " : " + (new Date()).toString());
        }
    });
    textBox.add(text1);
    add(textBox);
    add(mealSelections);
}
Also used : WAjaxControl(com.github.bordertech.wcomponents.WAjaxControl) Action(com.github.bordertech.wcomponents.Action) FlowLayout(com.github.bordertech.wcomponents.layout.FlowLayout) WFieldSet(com.github.bordertech.wcomponents.WFieldSet) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) Date(java.util.Date) Margin(com.github.bordertech.wcomponents.Margin)

Example 13 with WFieldSet

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

the class GridLayoutOptionsExample method getLayoutControls.

/**
 * build the list controls field set.
 *
 * @param errors the error box to be linked to the apply button.
 * @return a field set for the controls.
 */
private WFieldSet getLayoutControls(final WValidationErrors errors) {
    // Options Layout
    WFieldSet fieldSet = new WFieldSet("List configuration");
    WFieldLayout layout = new ControlFieldLayout();
    fieldSet.add(layout);
    // options.
    columnCount.setDecimalPlaces(0);
    columnCount.setMinValue(0);
    columnCount.setNumber(DEFAULT_COLUMN_COUNT);
    columnCount.setMandatory(true);
    layout.addField("Number of Columns", columnCount);
    rowCount.setDecimalPlaces(0);
    rowCount.setMinValue(0);
    rowCount.setNumber(DEFAULT_ROW_COUNT);
    rowCount.setMandatory(true);
    layout.addField("Number of Rows", rowCount);
    hGap.setDecimalPlaces(0);
    hGap.setMinValue(0);
    hGap.setNumber(0);
    hGap.setMandatory(true);
    layout.addField("Horizontal Gap", hGap);
    vGap.setDecimalPlaces(0);
    vGap.setMinValue(0);
    vGap.setNumber(0);
    vGap.setMandatory(true);
    layout.addField("Vertical Gap", vGap);
    boxCount.setDecimalPlaces(0);
    boxCount.setMinValue(0);
    boxCount.setNumber(DEFAULT_BOX_COUNT);
    boxCount.setMandatory(true);
    layout.addField("Number of Boxes", boxCount);
    layout.addField("Visible", cbVisible);
    layout.addField("Allow responsive design", cbResponsive);
    // Apply Button
    WButton apply = new WButton("Apply");
    apply.setAction(new ValidatingAction(errors, this) {

        @Override
        public void executeOnValid(final ActionEvent event) {
            applySettings();
        }
    });
    layout.addField(apply);
    fieldSet.add(new WAjaxControl(apply, container));
    fieldSet.setMargin(new Margin(null, null, Size.LARGE, null));
    return fieldSet;
}
Also used : WAjaxControl(com.github.bordertech.wcomponents.WAjaxControl) WFieldSet(com.github.bordertech.wcomponents.WFieldSet) ValidatingAction(com.github.bordertech.wcomponents.validation.ValidatingAction) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) WButton(com.github.bordertech.wcomponents.WButton) Margin(com.github.bordertech.wcomponents.Margin)

Example 14 with WFieldSet

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

the class WDateFieldExample method addDateRangeExample.

/**
 * Add date range example.
 */
private void addDateRangeExample() {
    add(new WHeading(WHeading.MAJOR, "Example of a date range component"));
    WFieldSet dateRange = new WFieldSet("Enter the expected arrival and departure dates.");
    add(dateRange);
    WPanel dateRangePanel = new WPanel();
    dateRangePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0));
    dateRange.add(dateRangePanel);
    final WDateField arrivalDate = new WDateField();
    final WDateField departureDate = new WDateField();
    // One could add some validation rules around this so that "arrival" was always earlier than or equal to "departure"
    WLabel arrivalLabel = new WLabel("Arrival", arrivalDate);
    arrivalLabel.setHint("dd MMM yyyy");
    WLabel departureLabel = new WLabel("Departure", departureDate);
    departureLabel.setHint("dd MMM yyyy");
    dateRangePanel.add(arrivalLabel);
    dateRangePanel.add(arrivalDate);
    dateRangePanel.add(departureLabel);
    dateRangePanel.add(departureDate);
    // subordinate control to ensure that the departure date is only enabled if the arrival date is populated
    WSubordinateControl control = new WSubordinateControl();
    add(control);
    Rule rule = new Rule(new Equal(arrivalDate, null));
    control.addRule(rule);
    rule.addActionOnTrue(new Disable(departureDate));
    rule.addActionOnFalse(new Enable(departureDate));
    control.addRule(rule);
}
Also used : WFieldSet(com.github.bordertech.wcomponents.WFieldSet) FlowLayout(com.github.bordertech.wcomponents.layout.FlowLayout) Equal(com.github.bordertech.wcomponents.subordinate.Equal) WPanel(com.github.bordertech.wcomponents.WPanel) WSubordinateControl(com.github.bordertech.wcomponents.subordinate.WSubordinateControl) WDateField(com.github.bordertech.wcomponents.WDateField) Enable(com.github.bordertech.wcomponents.subordinate.Enable) Rule(com.github.bordertech.wcomponents.subordinate.Rule) WHeading(com.github.bordertech.wcomponents.WHeading) Disable(com.github.bordertech.wcomponents.subordinate.Disable) WLabel(com.github.bordertech.wcomponents.WLabel)

Example 15 with WFieldSet

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

the class AbstractSetEnable_Test method testExecuteWithWFieldSet.

@Test
public void testExecuteWithWFieldSet() {
    // Setup targets in a FieldSet
    WFieldSet fieldSet = new WFieldSet("test");
    MyTarget target1 = new MyTarget();
    MyTarget target2 = new MyTarget();
    MyTarget target3 = new MyTarget();
    fieldSet.add(target1);
    fieldSet.add(target2);
    fieldSet.add(target3);
    AbstractSetEnable enable = new MyEnable(fieldSet, Boolean.FALSE);
    // Targets should be enabled by default
    Assert.assertFalse("WFieldSet - Target1 should be enabled", target1.isDisabled());
    Assert.assertFalse("WFieldSet - Target2 should be enabled", target2.isDisabled());
    Assert.assertFalse("WFieldSet - Target3 should be enabled", target3.isDisabled());
    enable.execute();
    // Targets should be disabled
    Assert.assertTrue("WFieldSet - Target1 should be disabled", target1.isDisabled());
    Assert.assertTrue("WFieldSet - Target2 should be disabled", target2.isDisabled());
    Assert.assertTrue("WFieldSet - Target3 should be disabled", target3.isDisabled());
}
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