Search in sources :

Example 1 with WButton

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

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

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

the class TableRowEditingAjaxExample method setUpActionButtons.

/**
 * Setup the action buttons and ajax controls in the action column.
 */
private void setUpActionButtons() {
    // Buttons Panel
    WPanel buttonPanel = new WPanel();
    actionContainer.add(buttonPanel);
    // Edit Button
    final WButton editButton = new WButton("Edit") {

        @Override
        public boolean isVisible() {
            Object key = TableUtil.getCurrentRowKey();
            return !isEditRow(key);
        }
    };
    editButton.setImage("/image/pencil.png");
    editButton.setRenderAsLink(true);
    editButton.setToolTip("Edit");
    editButton.setAction(new Action() {

        @Override
        public void execute(final ActionEvent event) {
            Object key = TableUtil.getCurrentRowKey();
            addEditRow(key);
        }
    });
    // Cancel Button
    final WButton cancelButton = new WButton("Cancel") {

        @Override
        public boolean isVisible() {
            Object key = TableUtil.getCurrentRowKey();
            return isEditRow(key);
        }
    };
    cancelButton.setImage("/image/cancel.png");
    cancelButton.setRenderAsLink(true);
    cancelButton.setToolTip("Cancel");
    cancelButton.setAction(new Action() {

        @Override
        public void execute(final ActionEvent event) {
            Object key = TableUtil.getCurrentRowKey();
            removeEditRow(key);
            firstNameField.reset();
            lastNameField.reset();
            dobField.reset();
        }
    });
    // Delete Button
    WConfirmationButton deleteButton = new WConfirmationButton("Delete") {

        @Override
        public boolean isVisible() {
            Object key = TableUtil.getCurrentRowKey();
            return !isEditRow(key);
        }
    };
    deleteButton.setMessage("Do you want to delete row?");
    deleteButton.setImage("/image/remove.png");
    deleteButton.setRenderAsLink(true);
    deleteButton.setToolTip("Delete");
    deleteButton.setAction(new Action() {

        @Override
        public void execute(final ActionEvent event) {
            Object key = TableUtil.getCurrentRowKey();
            removeEditRow(key);
            PersonBean bean = (PersonBean) actionContainer.getBean();
            List<PersonBean> beans = (List<PersonBean>) table.getBean();
            beans.remove(bean);
            table.handleDataChanged();
            messages.success(bean.getFirstName() + " " + bean.getLastName() + " removed.");
        }
    });
    buttonPanel.add(editButton);
    buttonPanel.add(cancelButton);
    buttonPanel.add(deleteButton);
    // Ajax - edit button
    WAjaxControl editAjax = new WAjaxControl(editButton, new AjaxTarget[] { firstNameField, lastNameField, dobField, buttonPanel }) {

        @Override
        public boolean isVisible() {
            return editButton.isVisible();
        }
    };
    buttonPanel.add(editAjax);
    // Ajax - cancel button
    WAjaxControl cancelAjax = new WAjaxControl(cancelButton, new AjaxTarget[] { firstNameField, lastNameField, dobField, buttonPanel }) {

        @Override
        public boolean isVisible() {
            return cancelButton.isVisible();
        }
    };
    buttonPanel.add(cancelAjax);
    buttonPanel.setIdName("buttons");
    editAjax.setIdName("ajax_edit");
    cancelAjax.setIdName("ajax_can");
    editButton.setIdName("edit_btn");
    cancelButton.setIdName("cancel_btn");
    deleteButton.setIdName("delete_btn");
}
Also used : Action(com.github.bordertech.wcomponents.Action) WAjaxControl(com.github.bordertech.wcomponents.WAjaxControl) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) WPanel(com.github.bordertech.wcomponents.WPanel) List(java.util.List) WButton(com.github.bordertech.wcomponents.WButton) WConfirmationButton(com.github.bordertech.wcomponents.WConfirmationButton)

Example 4 with WButton

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

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

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