Search in sources :

Example 1 with WCheckBoxSelect

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

the class WCheckBoxSelectExample method addFlatSelectExample.

/**
 * WCheckBoxSelect layout options These examples show the various ways to lay out the options in a WCheckBoxSelect
 * NOTE: the default (if no buttonLayout is set) is LAYOUT_STACKED. adds a WCheckBoxSelect with LAYOUT_FLAT
 */
private void addFlatSelectExample() {
    add(new WHeading(HeadingLevel.H3, "WCheckBoxSelect with flat layout"));
    add(new ExplanatoryText("Setting the layout to FLAT will make thecheck boxes be rendered in a horizontal line. They will wrap when they reach" + " the edge of the parent container."));
    final WCheckBoxSelect select = new WCheckBoxSelect("australian_state");
    select.setToolTip("Make a selection");
    select.setButtonLayout(WCheckBoxSelect.LAYOUT_FLAT);
    add(select);
}
Also used : ExplanatoryText(com.github.bordertech.wcomponents.examples.common.ExplanatoryText) WHeading(com.github.bordertech.wcomponents.WHeading) WCheckBoxSelect(com.github.bordertech.wcomponents.WCheckBoxSelect)

Example 2 with WCheckBoxSelect

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

the class WCheckBoxSelectExample method addInteractiveExamples.

/**
 * Simple interactive-state WCheckBoxSelect examples.
 */
private void addInteractiveExamples() {
    add(new WHeading(HeadingLevel.H2, "Simple WCheckBoxSelect examples"));
    addExampleUsingLookupTable();
    addExampleUsingArrayList();
    addExampleUsingStringArray();
    addInsideAFieldLayoutExamples();
    add(new WHeading(HeadingLevel.H2, "Examples showing LAYOUT properties"));
    addFlatSelectExample();
    addColumnSelectExample();
    addSingleColumnSelectExample();
    add(new WHeading(HeadingLevel.H2, "WCheckBoxSelect showing the frameless state"));
    add(new WHeading(HeadingLevel.H3, "Normal (with frame)"));
    WCheckBoxSelect select = new WCheckBoxSelect("australian_state");
    add(select);
    select.setToolTip("Make a selection");
    add(new WHeading(HeadingLevel.H3, "Without frame"));
    select = new WCheckBoxSelect("australian_state");
    add(select);
    select.setFrameless(true);
    select.setToolTip("Make a selection (no frame)");
}
Also used : WHeading(com.github.bordertech.wcomponents.WHeading) WCheckBoxSelect(com.github.bordertech.wcomponents.WCheckBoxSelect)

Example 3 with WCheckBoxSelect

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

the class WCheckBoxSelectExample method addExampleUsingArrayList.

/**
 * This example creates the WCheckBoxSelect from a List of CarOptions.
 */
private void addExampleUsingArrayList() {
    add(new WHeading(HeadingLevel.H3, "WCheckBoxSelect created using an array list of options"));
    List<CarOption> options = new ArrayList<>();
    options.add(new CarOption("1", "Ferrari", "F-360"));
    options.add(new CarOption("2", "Mercedez Benz", "amg"));
    options.add(new CarOption("3", "Nissan", "Skyline"));
    options.add(new CarOption("5", "Toyota", "Prius"));
    final WCheckBoxSelect select = new WCheckBoxSelect(options);
    select.setToolTip("Cars");
    final WTextField text = new WTextField();
    text.setReadOnly(true);
    text.setText(NO_SELECTION);
    WButton update = new WButton("Select Cars");
    update.setAction(new Action() {

        @Override
        public void execute(final ActionEvent event) {
            String output = select.getSelected().isEmpty() ? NO_SELECTION : "The selected cars are: " + select.getSelected();
            text.setText(output);
        }
    });
    select.setDefaultSubmitButton(update);
    add(select);
    add(update);
    add(text);
    add(new WAjaxControl(update, text));
}
Also used : Action(com.github.bordertech.wcomponents.Action) WAjaxControl(com.github.bordertech.wcomponents.WAjaxControl) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) ArrayList(java.util.ArrayList) WTextField(com.github.bordertech.wcomponents.WTextField) WButton(com.github.bordertech.wcomponents.WButton) WHeading(com.github.bordertech.wcomponents.WHeading) WCheckBoxSelect(com.github.bordertech.wcomponents.WCheckBoxSelect)

Example 4 with WCheckBoxSelect

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

the class WCheckBoxSelectExample method addExampleUsingStringArray.

/**
 * This example creates the WCheckBoxSelect from an array of Strings.
 */
private void addExampleUsingStringArray() {
    add(new WHeading(HeadingLevel.H3, "WCheckBoxSelect created using a String array"));
    String[] options = new String[] { "Dog", "Cat", "Bird", "Turtle" };
    final WCheckBoxSelect select = new WCheckBoxSelect(options);
    select.setToolTip("Animals");
    select.setMandatory(true);
    final WTextField text = new WTextField();
    text.setReadOnly(true);
    text.setText(NO_SELECTION);
    WButton update = new WButton("Select Animals");
    update.setAction(new Action() {

        @Override
        public void execute(final ActionEvent event) {
            String output = select.getSelected().isEmpty() ? NO_SELECTION : "The selected animals are: " + select.getSelected();
            text.setText(output);
        }
    });
    select.setDefaultSubmitButton(update);
    WLabel animalLabel = new WLabel("A selection is required", select);
    animalLabel.setHint("mandatory");
    add(animalLabel);
    add(select);
    add(update);
    add(text);
    add(new WAjaxControl(update, text));
}
Also used : Action(com.github.bordertech.wcomponents.Action) WAjaxControl(com.github.bordertech.wcomponents.WAjaxControl) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) WTextField(com.github.bordertech.wcomponents.WTextField) WButton(com.github.bordertech.wcomponents.WButton) WHeading(com.github.bordertech.wcomponents.WHeading) WCheckBoxSelect(com.github.bordertech.wcomponents.WCheckBoxSelect) WLabel(com.github.bordertech.wcomponents.WLabel)

Example 5 with WCheckBoxSelect

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

the class WCheckBoxSelectExample method addReadOnlyExamples.

/**
 * Examples of readonly states.
 */
private void addReadOnlyExamples() {
    add(new WHeading(HeadingLevel.H3, "Read-only WCheckBoxSelect examples"));
    add(new ExplanatoryText("These examples all use the same list of options: the states and territories list from the editable examples above." + " When the readOnly state is specified only those options which are selected are output."));
    // NOTE: when there are 0 or 1 selections the frame is not rendered.
    add(new WHeading(HeadingLevel.H4, "Read only with no selection"));
    WCheckBoxSelect select = new WCheckBoxSelect("australian_state");
    add(select);
    select.setReadOnly(true);
    select.setToolTip("Read only with no selection");
    add(new WText("end of unselected read only example"));
    add(new WHeading(HeadingLevel.H4, "Read only with one selection"));
    select = new SelectWithSingleSelected("australian_state");
    add(select);
    select.setReadOnly(true);
    select.setToolTip("Read only with one selection");
    add(new WHeading(HeadingLevel.H4, "Read only with many selections and no frame"));
    select = new SelectWithSingleSelected("australian_state");
    add(select);
    select.setReadOnly(true);
    select.setToolTip("Read only with many selections");
    select.setFrameless(true);
    add(new WHeading(HeadingLevel.H4, "Read only with many selections and COLUMN layout"));
    select = new SelectWithSingleSelected("australian_state");
    add(select);
    select.setReadOnly(true);
    select.setToolTip("Read only with many selections");
    select.setButtonLayout(WCheckBoxSelect.LAYOUT_COLUMNS);
    select.setButtonColumns(3);
    // read only in a WFieldLayout
    add(new WHeading(HeadingLevel.H4, "Read only in a WFieldLayout"));
    add(new ExplanatoryText("Each read only example is preceded by an editable example with the same options and selection. This is to ensure the" + " CSS works properly."));
    WFieldLayout layout = new WFieldLayout();
    layout.setLabelWidth(25);
    add(layout);
    // no selections
    select = new WCheckBoxSelect("australian_state");
    select.setFrameless(true);
    layout.addField("No selections were made", select);
    select = new WCheckBoxSelect("australian_state");
    select.setFrameless(true);
    select.setReadOnly(true);
    layout.addField("No selections were made (read only)", select);
    // one selection
    select = new SelectWithSingleSelected("australian_state");
    select.setFrameless(true);
    layout.addField("One selection was made", select);
    select = new SelectWithSingleSelected("australian_state");
    select.setFrameless(true);
    select.setReadOnly(true);
    layout.addField("One selection was made (read only)", select);
    // many selections
    select = new SelectWithManySelected("australian_state");
    layout.addField("Many selections with frame", select);
    select = new SelectWithManySelected("australian_state");
    select.setReadOnly(true);
    layout.addField("Many selections with frame (read only)", select);
    // columns with selections
    select = new SelectWithSingleSelected("australian_state");
    select.setButtonLayout(WCheckBoxSelect.LAYOUT_COLUMNS);
    select.setButtonColumns(3);
    select.setFrameless(true);
    layout.addField("many selections, frameless, COLUMN layout (3 columns)", select);
    select = new SelectWithManySelected("australian_state");
    select.setReadOnly(true);
    select.setButtonLayout(WCheckBoxSelect.LAYOUT_COLUMNS);
    select.setButtonColumns(3);
    select.setFrameless(true);
    layout.addField("many selections, frameless, COLUMN layout (3 columns) (read only)", select);
    // flat with selections
    select = new SelectWithManySelected("australian_state");
    select.setButtonLayout(WCheckBoxSelect.LAYOUT_FLAT);
    select.setFrameless(true);
    layout.addField("Many selections, frameless, FLAT layout", select);
    select = new SelectWithManySelected("australian_state");
    select.setReadOnly(true);
    select.setButtonLayout(WCheckBoxSelect.LAYOUT_FLAT);
    select.setFrameless(true);
    layout.addField("Many selections, frameless, FLAT layout (read only)", select);
}
Also used : WText(com.github.bordertech.wcomponents.WText) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) ExplanatoryText(com.github.bordertech.wcomponents.examples.common.ExplanatoryText) WHeading(com.github.bordertech.wcomponents.WHeading) WCheckBoxSelect(com.github.bordertech.wcomponents.WCheckBoxSelect)

Aggregations

WCheckBoxSelect (com.github.bordertech.wcomponents.WCheckBoxSelect)23 WHeading (com.github.bordertech.wcomponents.WHeading)12 Test (org.junit.Test)8 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)7 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)6 WLabel (com.github.bordertech.wcomponents.WLabel)6 WTextField (com.github.bordertech.wcomponents.WTextField)6 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)5 Action (com.github.bordertech.wcomponents.Action)4 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)4 WButton (com.github.bordertech.wcomponents.WButton)4 OptionGroup (com.github.bordertech.wcomponents.OptionGroup)2 WCheckBox (com.github.bordertech.wcomponents.WCheckBox)2 WDateField (com.github.bordertech.wcomponents.WDateField)2 WText (com.github.bordertech.wcomponents.WText)2 WTextArea (com.github.bordertech.wcomponents.WTextArea)2 SystemException (com.github.bordertech.wcomponents.util.SystemException)2 ArrayList (java.util.ArrayList)2 RadioButtonGroup (com.github.bordertech.wcomponents.RadioButtonGroup)1 UIContext (com.github.bordertech.wcomponents.UIContext)1