Search in sources :

Example 11 with WHeading

use of com.github.bordertech.wcomponents.WHeading 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 12 with WHeading

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

the class WCheckBoxSelectExample method addColumnSelectExample.

/**
 * adds a WCheckBoxSelect with LAYOUT_COLUMN in 2 columns.
 */
private void addColumnSelectExample() {
    add(new WHeading(HeadingLevel.H3, "WCheckBoxSelect laid out in columns"));
    add(new ExplanatoryText("Setting the layout to COLUMN will make the check boxes be rendered in 'n' columns. The number of columns is" + " determined by the layoutColumnCount property."));
    final WCheckBoxSelect select = new WCheckBoxSelect("australian_state");
    select.setToolTip("Make a selection");
    select.setButtonLayout(WCheckBoxSelect.LAYOUT_COLUMNS);
    select.setButtonColumns(2);
    add(select);
    add(new WHeading(HeadingLevel.H3, "Options equal to columns"));
    String[] options = new String[] { "Dog", "Cat", "Bird" };
    final WCheckBoxSelect select2 = new WCheckBoxSelect(options);
    select2.setToolTip("Animals");
    select2.setButtonColumns(3);
    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 = select2.getSelected().isEmpty() ? NO_SELECTION : "The selected animals are: " + select2.getSelected();
            text.setText(output);
        }
    });
    select2.setDefaultSubmitButton(update);
    add(select2);
    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) ExplanatoryText(com.github.bordertech.wcomponents.examples.common.ExplanatoryText) 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 13 with WHeading

use of com.github.bordertech.wcomponents.WHeading 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 14 with WHeading

use of com.github.bordertech.wcomponents.WHeading 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 15 with WHeading

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

the class WDateFieldExample method addContraintExamples.

/**
 * Add constraint example.
 */
private void addContraintExamples() {
    add(new WHeading(WHeading.MAJOR, "Date fields with input constraints"));
    WFieldLayout layout = new WFieldLayout();
    layout.setLabelWidth(33);
    add(layout);
    /* mandatory */
    WDateField constrainedDateField = new WDateField();
    constrainedDateField.setMandatory(true);
    layout.addField("Mandatory date field", constrainedDateField);
    /* min date */
    constrainedDateField = new WDateField();
    constrainedDateField.setMinDate(new Date());
    layout.addField("Minimum date today", constrainedDateField);
    /* max date */
    constrainedDateField = new WDateField();
    constrainedDateField.setMaxDate(new Date());
    layout.addField("Maximum date today", constrainedDateField);
}
Also used : WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) WDateField(com.github.bordertech.wcomponents.WDateField) WHeading(com.github.bordertech.wcomponents.WHeading) Date(java.util.Date)

Aggregations

WHeading (com.github.bordertech.wcomponents.WHeading)53 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)26 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)18 WPanel (com.github.bordertech.wcomponents.WPanel)17 WButton (com.github.bordertech.wcomponents.WButton)16 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)13 WLabel (com.github.bordertech.wcomponents.WLabel)13 Action (com.github.bordertech.wcomponents.Action)12 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)12 WCheckBoxSelect (com.github.bordertech.wcomponents.WCheckBoxSelect)12 WRadioButtonSelect (com.github.bordertech.wcomponents.WRadioButtonSelect)10 WTextField (com.github.bordertech.wcomponents.WTextField)10 WText (com.github.bordertech.wcomponents.WText)9 ColumnLayout (com.github.bordertech.wcomponents.layout.ColumnLayout)7 FlowLayout (com.github.bordertech.wcomponents.layout.FlowLayout)7 WHorizontalRule (com.github.bordertech.wcomponents.WHorizontalRule)6 Test (org.junit.Test)5 Margin (com.github.bordertech.wcomponents.Margin)4 Alignment (com.github.bordertech.wcomponents.layout.ColumnLayout.Alignment)4 ValidatingAction (com.github.bordertech.wcomponents.validation.ValidatingAction)4