Search in sources :

Example 1 with WFieldLayout

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

the class RepeaterExampleWithStaticIDs method createPrintContactsSubForm.

/**
 * Create the UI artefacts for the "Print contacts" sub form.
 */
private void createPrintContactsSubForm() {
    add(new WHeading(HeadingLevel.H3, "Print to CSV"));
    WButton printBtn = new WButton("Print");
    printBtn.setAction(new Action() {

        @Override
        public void execute(final ActionEvent event) {
            printDetails();
        }
    });
    printBtn.setImage("/image/document-print.png");
    printBtn.setImagePosition(WButton.ImagePosition.EAST);
    WFieldLayout layout = new WFieldLayout();
    add(layout);
    layout.setMargin(new Margin(Size.LARGE, null, null, null));
    layout.addField("Print output", printOutput);
    layout.addField((WLabel) null, printBtn);
    add(new WAjaxControl(printBtn, printOutput));
}
Also used : Action(com.github.bordertech.wcomponents.Action) WAjaxControl(com.github.bordertech.wcomponents.WAjaxControl) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) WButton(com.github.bordertech.wcomponents.WButton) WHeading(com.github.bordertech.wcomponents.WHeading) Margin(com.github.bordertech.wcomponents.Margin)

Example 2 with WFieldLayout

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

the class RepeaterExampleWithStaticIDs method createAddContactSubForm.

/**
 * Create the UI artefacts for the "Add contact" sub form.
 */
private void createAddContactSubForm() {
    add(new WHeading(HeadingLevel.H3, "Add a new contact"));
    WButton addBtn = new WButton("Add");
    addBtn.setAction(new Action() {

        @Override
        public void execute(final ActionEvent event) {
            addNewContact();
        }
    });
    addBtn.setImage("/image/address-book-new.png");
    newNameField.setDefaultSubmitButton(addBtn);
    WContainer container = new WContainer();
    container.add(newNameField);
    container.add(addBtn);
    WFieldLayout layout = new WFieldLayout();
    add(layout);
    layout.addField("New contact name", container);
    add(new WAjaxControl(addBtn, new AjaxTarget[] { repeater, newNameField }));
}
Also used : Action(com.github.bordertech.wcomponents.Action) WContainer(com.github.bordertech.wcomponents.WContainer) WAjaxControl(com.github.bordertech.wcomponents.WAjaxControl) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) WButton(com.github.bordertech.wcomponents.WButton) WHeading(com.github.bordertech.wcomponents.WHeading) AjaxTarget(com.github.bordertech.wcomponents.AjaxTarget)

Example 3 with WFieldLayout

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

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

the class WCheckBoxSelectExample method addInsideAFieldLayoutExamples.

/**
 * When a WCheckBoxSelect is added to a WFieldLayout the legend is moved. The first CheckBoxSelect has a frame, the
 * second doesn't
 */
private void addInsideAFieldLayoutExamples() {
    add(new WHeading(HeadingLevel.H3, "WCheckBoxSelect inside a WFieldLayout"));
    add(new ExplanatoryText("When a WCheckBoxSelect is inside a WField its label is exposed in a way which appears and behaves like a regular " + "HTML label. This allows WCheckBoxSelects to be used in a layout with simple form controls (such as WTextField) and produce a " + "consistent and predicatable interface. The third example in this set uses a null label and a toolTip to hide the labelling " + "element. This can lead to user confusion and is not recommended."));
    WFieldLayout layout = new WFieldLayout();
    layout.setLabelWidth(25);
    add(layout);
    String[] options = new String[] { "Dog", "Cat", "Bird", "Turtle" };
    WCheckBoxSelect select = new WCheckBoxSelect(options);
    layout.addField("Select some animals", select);
    String[] options2 = new String[] { "Parrot", "Galah", "Cockatoo", "Lyre" };
    select = new WCheckBoxSelect(options2);
    layout.addField("Select some birds", select);
    select.setFrameless(true);
    // a tooltip can be used as a label stand-in even in a WField
    String[] options3 = new String[] { "Carrot", "Beet", "Brocolli", "Bacon - the perfect vegetable" };
    select = new WCheckBoxSelect(options3);
    layout.addField((WLabel) null, select);
    select.setToolTip("Veggies");
    select = new WCheckBoxSelect("australian_state");
    layout.addField("Select a state", select).getLabel().setHint("This is an ajax trigger");
    add(new WAjaxControl(select, layout));
}
Also used : WAjaxControl(com.github.bordertech.wcomponents.WAjaxControl) 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)

Example 5 with WFieldLayout

use of com.github.bordertech.wcomponents.WFieldLayout 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

WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)47 WHeading (com.github.bordertech.wcomponents.WHeading)18 Test (org.junit.Test)13 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)12 WButton (com.github.bordertech.wcomponents.WButton)11 WTextField (com.github.bordertech.wcomponents.WTextField)11 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)11 Margin (com.github.bordertech.wcomponents.Margin)10 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)10 WField (com.github.bordertech.wcomponents.WField)10 WFieldSet (com.github.bordertech.wcomponents.WFieldSet)10 Action (com.github.bordertech.wcomponents.Action)8 WRadioButtonSelect (com.github.bordertech.wcomponents.WRadioButtonSelect)7 WCheckBoxSelect (com.github.bordertech.wcomponents.WCheckBoxSelect)6 WCheckBox (com.github.bordertech.wcomponents.WCheckBox)5 WContainer (com.github.bordertech.wcomponents.WContainer)5 WLabel (com.github.bordertech.wcomponents.WLabel)5 WText (com.github.bordertech.wcomponents.WText)5 Equal (com.github.bordertech.wcomponents.subordinate.Equal)5 Rule (com.github.bordertech.wcomponents.subordinate.Rule)5