Search in sources :

Example 1 with WFieldSet

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

the class SubordinateControlOptionsExample method setupTrigger.

/**
 * Setup the trigger for the subordinate control.
 */
private void setupTrigger() {
    String label = drpTriggerType.getSelected() + " Trigger";
    WFieldLayout layout = new WFieldLayout();
    layout.setLabelWidth(LABEL_WIDTH);
    buildControlPanel.add(layout);
    switch((TriggerType) drpTriggerType.getSelected()) {
        case RadioButtonGroup:
            trigger = new RadioButtonGroup();
            WFieldSet rbSet = new WFieldSet("Select an option");
            RadioButtonGroup group = (RadioButtonGroup) trigger;
            WRadioButton rb1 = group.addRadioButton("A");
            WRadioButton rb2 = group.addRadioButton("B");
            WRadioButton rb3 = group.addRadioButton("C");
            rbSet.add(group);
            rbSet.add(rb1);
            rbSet.add(new WLabel("A", rb1));
            rbSet.add(new WText("\u00a0"));
            rbSet.add(rb2);
            rbSet.add(new WLabel("B", rb2));
            rbSet.add(new WText("\u00a0"));
            rbSet.add(rb3);
            rbSet.add(new WLabel("C", rb3));
            layout.addField(label, rbSet);
            return;
        case CheckBox:
            trigger = new WCheckBox();
            break;
        case CheckBoxSelect:
            trigger = new WCheckBoxSelect(LOOKUP_TABLE_NAME);
            break;
        case DateField:
            trigger = new WDateField();
            break;
        case Dropdown:
            trigger = new WDropdown(new TableWithNullOption(LOOKUP_TABLE_NAME));
            break;
        case EmailField:
            trigger = new WEmailField();
            break;
        case MultiSelect:
            trigger = new WMultiSelect(LOOKUP_TABLE_NAME);
            break;
        case MultiSelectPair:
            trigger = new WMultiSelectPair(LOOKUP_TABLE_NAME);
            break;
        case NumberField:
            trigger = new WNumberField();
            break;
        case PartialDateField:
            trigger = new WPartialDateField();
            break;
        case PasswordField:
            trigger = new WPasswordField();
            break;
        case PhoneNumberField:
            trigger = new WPhoneNumberField();
            break;
        case RadioButtonSelect:
            trigger = new WRadioButtonSelect(LOOKUP_TABLE_NAME);
            break;
        case SingleSelect:
            trigger = new WSingleSelect(LOOKUP_TABLE_NAME);
            break;
        case TextArea:
            trigger = new WTextArea();
            ((WTextArea) trigger).setMaxLength(1000);
            break;
        case TextField:
            trigger = new WTextField();
            break;
        default:
            throw new SystemException("Trigger type not valid");
    }
    layout.addField(label, trigger);
}
Also used : WFieldSet(com.github.bordertech.wcomponents.WFieldSet) WNumberField(com.github.bordertech.wcomponents.WNumberField) WEmailField(com.github.bordertech.wcomponents.WEmailField) WPasswordField(com.github.bordertech.wcomponents.WPasswordField) WMultiSelect(com.github.bordertech.wcomponents.WMultiSelect) WLabel(com.github.bordertech.wcomponents.WLabel) WTextArea(com.github.bordertech.wcomponents.WTextArea) WRadioButton(com.github.bordertech.wcomponents.WRadioButton) WDropdown(com.github.bordertech.wcomponents.WDropdown) SystemException(com.github.bordertech.wcomponents.util.SystemException) WText(com.github.bordertech.wcomponents.WText) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) TableWithNullOption(com.github.bordertech.wcomponents.examples.common.ExampleLookupTable.TableWithNullOption) WRadioButtonSelect(com.github.bordertech.wcomponents.WRadioButtonSelect) WTextField(com.github.bordertech.wcomponents.WTextField) WCheckBoxSelect(com.github.bordertech.wcomponents.WCheckBoxSelect) WMultiSelectPair(com.github.bordertech.wcomponents.WMultiSelectPair) WPhoneNumberField(com.github.bordertech.wcomponents.WPhoneNumberField) WSingleSelect(com.github.bordertech.wcomponents.WSingleSelect) RadioButtonGroup(com.github.bordertech.wcomponents.RadioButtonGroup) WCheckBox(com.github.bordertech.wcomponents.WCheckBox) WPartialDateField(com.github.bordertech.wcomponents.WPartialDateField) WDateField(com.github.bordertech.wcomponents.WDateField)

Example 2 with WFieldSet

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

the class WFieldSetExample method addFieldSet.

/**
 * Creates a WFieldSet with content and a given FrameType.
 *
 * @param title The title to give to the WFieldSet.
 * @param type The decorative model of the WFieldSet
 * @return a WFieldSet with form control content.
 */
private WFieldSet addFieldSet(final String title, final WFieldSet.FrameType type) {
    final WFieldSet fieldset = new WFieldSet(title);
    fieldset.setFrameType(type);
    fieldset.setMargin(new com.github.bordertech.wcomponents.Margin(0, 0, 12, 0));
    final WFieldLayout layout = new WFieldLayout();
    fieldset.add(layout);
    layout.setLabelWidth(25);
    layout.addField("Street address", new WTextField());
    final WField add2Field = layout.addField("Street address line 2", new WTextField());
    add2Field.getLabel().setHidden(true);
    layout.addField("Suburb", new WTextField());
    layout.addField("State/Territory", new WDropdown(new String[] { "", "ACT", "NSW", "NT", "QLD", "SA", "TAS", "VIC", "WA" }));
    // NOTE: this is an Australia-specific post code field. An Australian post code is not a number as they may contain a leading zero.
    final WTextField postcode = new WTextField();
    postcode.setMaxLength(4);
    postcode.setColumns(4);
    postcode.setMinLength(3);
    layout.addField("Postcode", postcode);
    add(fieldset);
    return fieldset;
}
Also used : WField(com.github.bordertech.wcomponents.WField) WFieldSet(com.github.bordertech.wcomponents.WFieldSet) WDropdown(com.github.bordertech.wcomponents.WDropdown) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) WTextField(com.github.bordertech.wcomponents.WTextField)

Example 3 with WFieldSet

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

the class WLabelExample method addNullLabelExample.

/**
 * Example of when and how to use a null WLabel.
 */
private void addNullLabelExample() {
    add(new WHeading(HeadingLevel.H2, "How to use accessible null WLabels"));
    add(new ExplanatoryText("These examples shows how sometime a null WLabel is the right thing to do." + "\n This example uses a WFieldSet as the labelled component and it has its own \"label\"."));
    // We want to add a WFieldSet to a WFieldLayout but without an extra label.
    WFieldLayout fieldsFlat = new WFieldLayout();
    fieldsFlat.setMargin(new Margin(null, null, Size.XL, null));
    add(fieldsFlat);
    WFieldSet fs = new WFieldSet("Do you like Bananas?");
    fieldsFlat.addField((WLabel) null, fs);
    // now add the WRadioButtons to the WFieldSet using an inner WFieldLayout
    WFieldLayout innerLayout = new WFieldLayout(WFieldLayout.LAYOUT_STACKED);
    // The content will be a group of WRadioButtons
    RadioButtonGroup group1 = new RadioButtonGroup();
    WRadioButton rb1 = group1.addRadioButton(1);
    WRadioButton rb2 = group1.addRadioButton(2);
    // make the labels for the radio buttons
    WLabel rb1Label = new WLabel("", rb1);
    WImage labelImage = new WImage("/image/success.png", "I still like bananas");
    labelImage.setHtmlClass("wc-valign-bottom");
    rb1Label.add(labelImage);
    WLabel rb2Label = new WLabel("", rb2);
    labelImage = new WImage("/image/error.png", "I still dislike bananas");
    labelImage.setHtmlClass("wc-valign-bottom");
    rb2Label.add(labelImage);
    innerLayout.addField(rb1Label, rb1);
    innerLayout.addField(rb2Label, rb2);
    // add the content to the WFieldLayout - the order really doesn't matter.
    fs.add(group1);
    fs.add(innerLayout);
}
Also used : WFieldSet(com.github.bordertech.wcomponents.WFieldSet) WRadioButton(com.github.bordertech.wcomponents.WRadioButton) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) RadioButtonGroup(com.github.bordertech.wcomponents.RadioButtonGroup) WImage(com.github.bordertech.wcomponents.WImage) ExplanatoryText(com.github.bordertech.wcomponents.examples.common.ExplanatoryText) WHeading(com.github.bordertech.wcomponents.WHeading) Margin(com.github.bordertech.wcomponents.Margin) WLabel(com.github.bordertech.wcomponents.WLabel)

Example 4 with WFieldSet

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

the class ButtonOptionsExample 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("Button configuration");
    WFieldLayout layout = new WFieldLayout();
    layout.setLabelWidth(30);
    layout.addField("Text", tfButtonLabel);
    layout.addField("AccessKey", tfAccesskey);
    layout.addField("Render as link", cbRenderAsLink);
    layout.addField("Disabled", cbDisabled);
    layout.addField("setImage ('/image/pencil.png')", cbSetImage);
    layout.addField("Image Position", ddImagePosition);
    // 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 5 with WFieldSet

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

the class WDropdownOptionsExample method getDropDownControls.

/**
 * build the drop down controls.
 *
 * @return a field set containing the dropdown controls.
 */
private WFieldSet getDropDownControls() {
    WFieldSet fieldSet = new WFieldSet("Drop down configuration");
    WFieldLayout layout = new WFieldLayout();
    layout.setLabelWidth(25);
    fieldSet.add(layout);
    rbsDDType.setButtonLayout(WRadioButtonSelect.LAYOUT_FLAT);
    rbsDDType.setSelected(WDropdown.DropdownType.NATIVE);
    rbsDDType.setFrameless(true);
    layout.addField("Dropdown Type", rbsDDType);
    nfWidth.setMinValue(0);
    nfWidth.setDecimalPlaces(0);
    layout.addField("Width", nfWidth);
    layout.addField("ToolTip", tfToolTip);
    layout.addField("Include null option", cbNullOption);
    rgDefaultOption.setButtonLayout(WRadioButtonSelect.LAYOUT_COLUMNS);
    rgDefaultOption.setButtonColumns(2);
    rgDefaultOption.setSelected(NONE);
    rgDefaultOption.setFrameless(true);
    layout.addField("Default Option", rgDefaultOption);
    layout.addField("Action on change", cbActionOnChange);
    layout.addField("Ajax", cbAjax);
    WField subField = layout.addField("Subordinate", cbSubordinate);
    // .getLabel().setHint("Does not work with Dropdown Type COMBO");
    layout.addField("Submit on change", cbSubmitOnChange);
    layout.addField("Visible", cbVisible);
    layout.addField("Disabled", cbDisabled);
    // Apply Button
    WButton apply = new WButton("Apply");
    fieldSet.add(apply);
    WSubordinateControl subSubControl = new WSubordinateControl();
    Rule rule = new Rule();
    subSubControl.addRule(rule);
    rule.setCondition(new Equal(rbsDDType, WDropdown.DropdownType.COMBO));
    rule.addActionOnTrue(new Disable(subField));
    rule.addActionOnFalse(new Enable(subField));
    fieldSet.add(subSubControl);
    apply.setAction(new Action() {

        @Override
        public void execute(final ActionEvent event) {
            applySettings();
        }
    });
    return fieldSet;
}
Also used : WField(com.github.bordertech.wcomponents.WField) Action(com.github.bordertech.wcomponents.Action) WFieldSet(com.github.bordertech.wcomponents.WFieldSet) Equal(com.github.bordertech.wcomponents.subordinate.Equal) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) 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) WHorizontalRule(com.github.bordertech.wcomponents.WHorizontalRule) WButton(com.github.bordertech.wcomponents.WButton) Disable(com.github.bordertech.wcomponents.subordinate.Disable)

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