use of com.github.bordertech.wcomponents.ActionEvent in project wcomponents by BorderTech.
the class WRadioButtonTriggerActionExample method setup.
/**
* Add controls to the UI.
*/
private void setup() {
setLayout(new FlowLayout(FlowLayout.VERTICAL));
WFieldSet fset = new WFieldSet("Select a meal");
add(fset);
fset.setMargin(new Margin(null, null, Size.LARGE, null));
WFieldLayout flay = new WFieldLayout(WFieldLayout.LAYOUT_STACKED);
fset.add(flay);
flay.setLabelWidth(0);
flay.addField("Breakfast", rb1);
flay.addField("Lunch", rb2);
flay.addField("Dinner", rb3);
/*
* NOTE: you should never use submitOnChange with a WRadioButton
*/
fset.add(new WAjaxControl(mealSelections, textBox));
mealSelections.setActionOnChange(new Action() {
@Override
public void execute(final ActionEvent event) {
String selection = null;
if (rb1.isSelected()) {
selection = "Breakfast selected";
}
if (rb2.isSelected()) {
selection = "Lunch selected";
}
if (rb3.isSelected()) {
selection = "Dinner selected";
}
text1.setText(selection + " : " + (new Date()).toString());
}
});
textBox.add(text1);
add(textBox);
add(mealSelections);
}
use of com.github.bordertech.wcomponents.ActionEvent in project wcomponents by BorderTech.
the class GridLayoutOptionsExample method getLayoutControls.
/**
* build the list controls field set.
*
* @param errors the error box to be linked to the apply button.
* @return a field set for the controls.
*/
private WFieldSet getLayoutControls(final WValidationErrors errors) {
// Options Layout
WFieldSet fieldSet = new WFieldSet("List configuration");
WFieldLayout layout = new ControlFieldLayout();
fieldSet.add(layout);
// options.
columnCount.setDecimalPlaces(0);
columnCount.setMinValue(0);
columnCount.setNumber(DEFAULT_COLUMN_COUNT);
columnCount.setMandatory(true);
layout.addField("Number of Columns", columnCount);
rowCount.setDecimalPlaces(0);
rowCount.setMinValue(0);
rowCount.setNumber(DEFAULT_ROW_COUNT);
rowCount.setMandatory(true);
layout.addField("Number of Rows", rowCount);
hGap.setDecimalPlaces(0);
hGap.setMinValue(0);
hGap.setNumber(0);
hGap.setMandatory(true);
layout.addField("Horizontal Gap", hGap);
vGap.setDecimalPlaces(0);
vGap.setMinValue(0);
vGap.setNumber(0);
vGap.setMandatory(true);
layout.addField("Vertical Gap", vGap);
boxCount.setDecimalPlaces(0);
boxCount.setMinValue(0);
boxCount.setNumber(DEFAULT_BOX_COUNT);
boxCount.setMandatory(true);
layout.addField("Number of Boxes", boxCount);
layout.addField("Visible", cbVisible);
layout.addField("Allow responsive design", cbResponsive);
// Apply Button
WButton apply = new WButton("Apply");
apply.setAction(new ValidatingAction(errors, this) {
@Override
public void executeOnValid(final ActionEvent event) {
applySettings();
}
});
layout.addField(apply);
fieldSet.add(new WAjaxControl(apply, container));
fieldSet.setMargin(new Margin(null, null, Size.LARGE, null));
return fieldSet;
}
use of com.github.bordertech.wcomponents.ActionEvent 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;
}
use of com.github.bordertech.wcomponents.ActionEvent 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;
}
use of com.github.bordertech.wcomponents.ActionEvent in project wcomponents by BorderTech.
the class ExampleSection method buildUI.
/**
* Add the controls to the section in the right order.
*/
private void buildUI() {
add(messages);
add(tabset);
// add(new AccessibilityWarningContainer());
container.add(new WText("Select an example from the menu"));
// Set a static ID on container and it becomes a de-facto naming context.
container.setIdName("eg");
tabset.addTab(container, "(no selection)", WTabSet.TAB_MODE_CLIENT);
WImage srcImage = new WImage(new ImageResource("/image/text-x-source.png", "View Source"));
srcImage.setCacheKey("srcTabImage");
tabset.addTab(source, new WDecoratedLabel(srcImage), WTabSet.TAB_MODE_LAZY).setToolTip("View Source");
// The refresh current view button.
WButton refreshButton = new WButton("\u200b");
refreshButton.setToolTip("Refresh");
refreshButton.setHtmlClass(HtmlIconUtil.getIconClasses("fa-refresh"));
// refreshButton.setImage("/image/refresh-w.png");
refreshButton.setRenderAsLink(true);
refreshButton.setAction(new ValidatingAction(messages.getValidationErrors(), refreshButton) {
@Override
public void executeOnValid(final ActionEvent event) {
// Do Nothing
}
});
// The reset example button.
final WButton resetButton = new WButton("\u200b");
resetButton.setToolTip("Reset");
resetButton.setHtmlClass(HtmlIconUtil.getIconClasses("fa-times-circle"));
// resetButton.setImage("/image/cancel-w.png");
resetButton.setRenderAsLink(true);
resetButton.setAction(new ValidatingAction(messages.getValidationErrors(), resetButton) {
@Override
public void executeOnValid(final ActionEvent event) {
resetExample();
}
});
addToTail(refreshButton);
addToTail(new WText("\u2002"));
addToTail(resetButton);
}
Aggregations