Search in sources :

Example 6 with WButton

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

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

the class ButtonOptionsExample method applySettings.

/**
 * this is were the majority of the work is done for building the button. Note that it is in a container that is
 * reset, effectively creating a new button. this is only done to enable to dynamically change the button to a link
 * and back.
 */
private void applySettings() {
    buttonContainer.reset();
    WButton exampleButton = new WButton(tfButtonLabel.getText());
    exampleButton.setRenderAsLink(cbRenderAsLink.isSelected());
    exampleButton.setText(tfButtonLabel.getText());
    if (cbSetImage.isSelected()) {
        exampleButton.setImage("/image/pencil.png");
        exampleButton.setImagePosition((ImagePosition) ddImagePosition.getSelected());
    }
    exampleButton.setDisabled(cbDisabled.isSelected());
    if (tfAccesskey.getText() != null && tfAccesskey.getText().length() > 0) {
        exampleButton.setAccessKey(tfAccesskey.getText().toCharArray()[0]);
    }
    buttonContainer.add(exampleButton);
}
Also used : WButton(com.github.bordertech.wcomponents.WButton)

Example 8 with WButton

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

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

the class InputBeanBindingExample method addButtons.

/**
 * Setup the action buttons.
 */
private void addButtons() {
    // Validation Button
    WButton buttonValidate = new WButton("Validate and Update Bean");
    add(buttonValidate);
    buttonValidate.setAction(new ValidatingAction(messages.getValidationErrors(), layout) {

        @Override
        public void executeOnValid(final ActionEvent event) {
            WebUtilities.updateBeanValue(layout);
            messages.success("OK");
        }
    });
    // Update Bean
    WButton buttonUpdate = new WButton("Update Bean");
    add(buttonUpdate);
    buttonUpdate.setAction(new Action() {

        @Override
        public void execute(final ActionEvent event) {
            WebUtilities.updateBeanValue(layout);
        }
    });
    // Reset Inputs
    WButton buttonReset = new WButton("Reset Inputs");
    add(buttonReset);
    buttonReset.setAction(new Action() {

        @Override
        public void execute(final ActionEvent event) {
            layout.reset();
        }
    });
    // Reset Bean
    WButton buttonBean = new WButton("Reset Bean");
    add(buttonBean);
    buttonBean.setAction(new Action() {

        @Override
        public void execute(final ActionEvent event) {
            InputBeanBindingExample.this.setBean(new MyDemoBean());
        }
    });
    add(new WButton("submit"));
}
Also used : Action(com.github.bordertech.wcomponents.Action) ValidatingAction(com.github.bordertech.wcomponents.validation.ValidatingAction) ValidatingAction(com.github.bordertech.wcomponents.validation.ValidatingAction) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) WButton(com.github.bordertech.wcomponents.WButton)

Example 10 with WButton

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

the class WButtonExample method addDisabledExamples.

/**
 * Examples of disabled buttons in various guises.
 */
private void addDisabledExamples() {
    add(new WHeading(HeadingLevel.H2, "Examples of disabled buttons"));
    WPanel disabledButtonLayoutPanel = new WPanel(WPanel.Type.BOX);
    disabledButtonLayoutPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0, FlowLayout.ContentAlignment.BASELINE));
    add(disabledButtonLayoutPanel);
    WButton button = new WButton("Disabled button");
    button.setDisabled(true);
    disabledButtonLayoutPanel.add(button);
    button = new WButton("Disabled button as link");
    button.setDisabled(true);
    button.setRenderAsLink(true);
    disabledButtonLayoutPanel.add(button);
    add(new WHeading(HeadingLevel.H3, "Examples of disabled buttons displaying only an image"));
    disabledButtonLayoutPanel = new WPanel(WPanel.Type.BOX);
    disabledButtonLayoutPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0, FlowLayout.ContentAlignment.BASELINE));
    add(disabledButtonLayoutPanel);
    button = new WButton("Disabled button");
    button.setDisabled(true);
    button.setImage("/image/tick.png");
    button.setToolTip("Checking currently disabled");
    disabledButtonLayoutPanel.add(button);
    button = new WButton("Disabled button as link");
    button.setDisabled(true);
    button.setRenderAsLink(true);
    button.setImage("/image/tick.png");
    button.setToolTip("Checking currently disabled");
    disabledButtonLayoutPanel.add(button);
    add(new WHeading(HeadingLevel.H3, "Examples of disabled buttons displaying an image with imagePosition EAST"));
    disabledButtonLayoutPanel = new WPanel(WPanel.Type.BOX);
    disabledButtonLayoutPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0, FlowLayout.ContentAlignment.BASELINE));
    add(disabledButtonLayoutPanel);
    button = new WButton("Disabled button");
    button.setDisabled(true);
    button.setImage("/image/tick.png");
    button.setToolTip("Checking currently disabled");
    button.setImagePosition(ImagePosition.EAST);
    disabledButtonLayoutPanel.add(button);
    button = new WButton("Disabled button as link");
    button.setDisabled(true);
    button.setRenderAsLink(true);
    button.setImage("/image/tick.png");
    button.setToolTip("Checking currently disabled");
    button.setImagePosition(ImagePosition.EAST);
    disabledButtonLayoutPanel.add(button);
}
Also used : FlowLayout(com.github.bordertech.wcomponents.layout.FlowLayout) WPanel(com.github.bordertech.wcomponents.WPanel) WButton(com.github.bordertech.wcomponents.WButton) WHeading(com.github.bordertech.wcomponents.WHeading)

Aggregations

WButton (com.github.bordertech.wcomponents.WButton)76 Test (org.junit.Test)39 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)25 Action (com.github.bordertech.wcomponents.Action)20 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)18 WTextField (com.github.bordertech.wcomponents.WTextField)17 WHeading (com.github.bordertech.wcomponents.WHeading)16 WContainer (com.github.bordertech.wcomponents.WContainer)14 WPanel (com.github.bordertech.wcomponents.WPanel)13 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)11 ValidatingAction (com.github.bordertech.wcomponents.validation.ValidatingAction)10 WLabel (com.github.bordertech.wcomponents.WLabel)9 WTableColumn (com.github.bordertech.wcomponents.WTableColumn)8 UIContext (com.github.bordertech.wcomponents.UIContext)7 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)7 WText (com.github.bordertech.wcomponents.WText)6 WDataTable (com.github.bordertech.wcomponents.WDataTable)5 WFieldSet (com.github.bordertech.wcomponents.WFieldSet)5 WTable (com.github.bordertech.wcomponents.WTable)5 AdapterBasicTableModel (com.github.bordertech.wcomponents.AdapterBasicTableModel)4