Search in sources :

Example 21 with Action

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

the class ColumnMenuExample method buildColumnMenu.

/**
 * Builds up a column menu for inclusion in the example.
 *
 * @param selectedMenuText the WText to display the selected menu.
 * @return a column menu for the example.
 */
private WMenu buildColumnMenu(final WText selectedMenuText) {
    WMenu menu = new WMenu(WMenu.MenuType.COLUMN);
    menu.setSelectMode(SelectMode.SINGLE);
    menu.setRows(8);
    StringTreeNode root = getOrgHierarchyTree();
    mapColumnHierarchy(menu, root, selectedMenuText);
    // Demonstrate different menu modes
    getSubMenuByText("Australia", menu).setAccessKey('A');
    getSubMenuByText("NSW", menu).setMode(MenuMode.CLIENT);
    getSubMenuByText("Branch 1", menu).setMode(MenuMode.DYNAMIC);
    getSubMenuByText("VIC", menu).setMode(MenuMode.LAZY);
    WMenuItem itemWithIcon = new WMenuItem("Help");
    itemWithIcon.setAction(new Action() {

        @Override
        public void execute(final ActionEvent event) {
        // do something
        }
    });
    itemWithIcon.setHtmlClass(HtmlClassProperties.ICON_HELP_BEFORE);
    menu.add(itemWithIcon);
    return menu;
}
Also used : Action(com.github.bordertech.wcomponents.Action) WMenuItem(com.github.bordertech.wcomponents.WMenuItem) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) WMenu(com.github.bordertech.wcomponents.WMenu)

Example 22 with Action

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

the class TreeMenuExample method buildTreeMenuWithDecoratedLabel.

/**
 * Tree menu containing image in the items. This example demonstrates creating {@link WSubMenu} and
 * {@link WMenuItem} components with {@link WDecoratedLabel}.
 *
 * @return menu with a decorated label
 */
private WMenu buildTreeMenuWithDecoratedLabel() {
    WMenu menu = new WMenu(WMenu.MenuType.TREE);
    WDecoratedLabel dLabel = new WDecoratedLabel(null, new WText("Settings Menu"), new WImage("/image/settings.png", "settings"));
    WSubMenu settings = new WSubMenu(dLabel);
    settings.setMode(WSubMenu.MenuMode.LAZY);
    settings.setAccessKey('S');
    menu.add(settings);
    settings.add(new WMenuItem(new WDecoratedLabel(null, new WText("Account Settings"), new WImage("/image/user-properties.png", "user properties"))));
    settings.add(new WMenuItem(new WDecoratedLabel(null, new WText("Personal Details"), new WImage("/image/user.png", "user"))));
    WSubMenu addressSub = new WSubMenu(new WDecoratedLabel(null, new WText("Address Details"), new WImage("/image/address-book-open.png", "address book")));
    addressSub.setMode(WSubMenu.MenuMode.LAZY);
    settings.add(addressSub);
    addressSub.add(new WMenuItem(new WDecoratedLabel(null, new WText("Home Address"), new WImage("/image/home.png", "home"))));
    addressSub.add(new WMenuItem(new WDecoratedLabel(null, new WText("Work Address"), new WImage("/image/wrench.png", "work"))));
    addressSub.add(new WMenuItem(new WDecoratedLabel(null, new WText("Postal Address"), new WImage("/image/mail-post.png", "postal"))));
    WMenuItem itemWithIcon = new WMenuItem("Help");
    itemWithIcon.setAction(new Action() {

        @Override
        public void execute(final ActionEvent event) {
        // do something
        }
    });
    itemWithIcon.setHtmlClass(HtmlClassProperties.ICON_HELP_BEFORE);
    menu.add(itemWithIcon);
    return menu;
}
Also used : Action(com.github.bordertech.wcomponents.Action) WSubMenu(com.github.bordertech.wcomponents.WSubMenu) WMenuItem(com.github.bordertech.wcomponents.WMenuItem) WText(com.github.bordertech.wcomponents.WText) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) WMenu(com.github.bordertech.wcomponents.WMenu) WImage(com.github.bordertech.wcomponents.WImage) WDecoratedLabel(com.github.bordertech.wcomponents.WDecoratedLabel)

Example 23 with Action

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

the class RepeaterExampleWithEditableRows method createExampleUi.

/**
 * Add all the required UI artefacts for this example.
 */
private void createExampleUi() {
    add(new WHeading(HeadingLevel.H2, "Contacts"));
    add(repeater);
    WButton addBtn = new WButton("Add");
    addBtn.setAction(new Action() {

        @Override
        public void execute(final ActionEvent event) {
            addNewContact();
        }
    });
    newNameField.setDefaultSubmitButton(addBtn);
    WButton printBtn = new WButton("Print");
    printBtn.setAction(new Action() {

        @Override
        public void execute(final ActionEvent event) {
            printEditedDetails();
        }
    });
    WFieldLayout layout = new WFieldLayout();
    add(layout);
    layout.addField("New contact name", newNameField);
    layout.addField((WLabel) null, addBtn);
    layout.addField("Print output", console);
    layout.addField((WLabel) null, printBtn);
    // Ajax controls to make things zippier
    add(new WAjaxControl(addBtn, new AjaxTarget[] { repeater, newNameField }));
    add(new WAjaxControl(printBtn, console));
}
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) AjaxTarget(com.github.bordertech.wcomponents.AjaxTarget)

Example 24 with Action

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

the class RepeaterExampleWithStaticIDs method createButtonBar.

/**
 * Create the UI artefacts for the update and reset buttons.
 */
private void createButtonBar() {
    // Update and reset controls for the repeater.
    WPanel buttonPanel = new WPanel(WPanel.Type.FEATURE);
    buttonPanel.setMargin(new Margin(Size.MEDIUM, null, Size.LARGE, null));
    buttonPanel.setLayout(new BorderLayout());
    WButton updateButton = new WButton("Update");
    updateButton.setImage("/image/document-save-5.png");
    updateButton.setImagePosition(WButton.ImagePosition.EAST);
    buttonPanel.add(updateButton, BorderLayout.EAST);
    WButton resetButton = new WButton("Reset");
    resetButton.setImage("/image/edit-undo-8.png");
    resetButton.setImagePosition(WButton.ImagePosition.WEST);
    resetButton.setAction(new Action() {

        @Override
        public void execute(final ActionEvent event) {
            repeater.setData(fetchDataList());
        }
    });
    buttonPanel.add(resetButton, BorderLayout.WEST);
    add(buttonPanel);
    add(new WAjaxControl(updateButton, repeater));
    add(new WAjaxControl(resetButton, repeater));
}
Also used : Action(com.github.bordertech.wcomponents.Action) WAjaxControl(com.github.bordertech.wcomponents.WAjaxControl) BorderLayout(com.github.bordertech.wcomponents.layout.BorderLayout) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) WPanel(com.github.bordertech.wcomponents.WPanel) WButton(com.github.bordertech.wcomponents.WButton) Margin(com.github.bordertech.wcomponents.Margin)

Example 25 with Action

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

the class WCheckBoxSelectExample method addExampleUsingLookupTable.

/**
 * This example creates the WCheckBoxSelect using an a look up table. All other optional properties are in their default state.
 * <p>Note for Framework devs: the unit tests for this Example are used to test the Selenium WebElement extension and this example is expected
 * to be: the first WCheckBoxSelect in the example; and to be interactive; and to have the 9 options of the "australian_state" lookup table.
 */
private void addExampleUsingLookupTable() {
    add(new WHeading(HeadingLevel.H3, "WCheckBoxSelect created using a lookup table"));
    final WCheckBoxSelect select = new WCheckBoxSelect("australian_state");
    final WTextField text = new WTextField();
    text.setReadOnly(true);
    text.setText(NO_SELECTION);
    WButton update = new WButton("Select");
    update.setAction(new Action() {

        @Override
        public void execute(final ActionEvent event) {
            String output = select.getSelected().isEmpty() ? NO_SELECTION : "The selected states are: " + select.getSelected();
            text.setText(output);
        }
    });
    select.setDefaultSubmitButton(update);
    add(new WLabel("Select a state or territory", select));
    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)

Aggregations

Action (com.github.bordertech.wcomponents.Action)28 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)27 WButton (com.github.bordertech.wcomponents.WButton)20 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)15 WHeading (com.github.bordertech.wcomponents.WHeading)12 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)8 WTextField (com.github.bordertech.wcomponents.WTextField)7 WPanel (com.github.bordertech.wcomponents.WPanel)6 ValidatingAction (com.github.bordertech.wcomponents.validation.ValidatingAction)6 WCheckBoxSelect (com.github.bordertech.wcomponents.WCheckBoxSelect)4 WContainer (com.github.bordertech.wcomponents.WContainer)4 WLabel (com.github.bordertech.wcomponents.WLabel)4 WMenu (com.github.bordertech.wcomponents.WMenu)4 WMenuItem (com.github.bordertech.wcomponents.WMenuItem)4 WRadioButtonSelect (com.github.bordertech.wcomponents.WRadioButtonSelect)4 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)4 Margin (com.github.bordertech.wcomponents.Margin)3 WText (com.github.bordertech.wcomponents.WText)3 Equal (com.github.bordertech.wcomponents.subordinate.Equal)3 Rule (com.github.bordertech.wcomponents.subordinate.Rule)3