use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.
the class WDropdownOptionsExample method getDropDownControls.
/**
* build the drop down controls.
*
* @return a field set containing the dropdown controls.
*/
private WFieldSet getDropDownControls() {
WFieldSet fieldSet = new WFieldSet("Drop down configuration");
WFieldLayout layout = new WFieldLayout();
layout.setLabelWidth(25);
fieldSet.add(layout);
rbsDDType.setButtonLayout(WRadioButtonSelect.LAYOUT_FLAT);
rbsDDType.setSelected(WDropdown.DropdownType.NATIVE);
rbsDDType.setFrameless(true);
layout.addField("Dropdown Type", rbsDDType);
nfWidth.setMinValue(0);
nfWidth.setDecimalPlaces(0);
layout.addField("Width", nfWidth);
layout.addField("ToolTip", tfToolTip);
layout.addField("Include null option", cbNullOption);
rgDefaultOption.setButtonLayout(WRadioButtonSelect.LAYOUT_COLUMNS);
rgDefaultOption.setButtonColumns(2);
rgDefaultOption.setSelected(NONE);
rgDefaultOption.setFrameless(true);
layout.addField("Default Option", rgDefaultOption);
layout.addField("Action on change", cbActionOnChange);
layout.addField("Ajax", cbAjax);
WField subField = layout.addField("Subordinate", cbSubordinate);
// .getLabel().setHint("Does not work with Dropdown Type COMBO");
layout.addField("Submit on change", cbSubmitOnChange);
layout.addField("Visible", cbVisible);
layout.addField("Disabled", cbDisabled);
// Apply Button
WButton apply = new WButton("Apply");
fieldSet.add(apply);
WSubordinateControl subSubControl = new WSubordinateControl();
Rule rule = new Rule();
subSubControl.addRule(rule);
rule.setCondition(new Equal(rbsDDType, WDropdown.DropdownType.COMBO));
rule.addActionOnTrue(new Disable(subField));
rule.addActionOnFalse(new Enable(subField));
fieldSet.add(subSubControl);
apply.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
applySettings();
}
});
return fieldSet;
}
use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.
the class WListOptionsExample method getListControls.
/**
* build the list controls field set.
*
* @return a field set for the controls.
*/
private WFieldSet getListControls() {
// Options Layout
WFieldSet fieldSet = new WFieldSet("List configuration");
WFieldLayout layout = new WFieldLayout();
// options.
layout.addField("Type", ddType);
layout.addField("Separator", ddSeparator);
layout.addField("Render fields", cgBeanFields);
layout.addField("Render Border", cbRenderBorder);
layout.addField("Render using field layout", cbRenderUsingFieldLayout);
layout.addField("Visible", cbVisible);
// Apply Button
WButton apply = new WButton("Apply");
apply.setAction(new com.github.bordertech.wcomponents.Action() {
@Override
public void execute(final ActionEvent event) {
applySettings();
}
});
fieldSet.add(layout);
fieldSet.add(apply);
return fieldSet;
}
use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.
the class WPanelTypeExample method setUpUtilBar.
/**
* Add some UI to a "utility bar" type structure.
*/
private void setUpUtilBar() {
utilBar.setLayout(new ListLayout(ListLayout.Type.FLAT, ListLayout.Alignment.RIGHT, ListLayout.Separator.NONE, false));
WTextField selectOther = new WTextField();
selectOther.setToolTip("Enter text.");
utilBar.add(selectOther);
utilBar.add(new WButton("Go"));
utilBar.add(new WButton("A"));
utilBar.add(new WButton("B"));
utilBar.add(new WButton("C"));
utilBar.setVisible(false);
}
use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.
the class WRadioButtonSelectExample method addColumnSelectExample.
/**
* adds a WRadioButtonSelect with LAYOUT_COLUMN in 3 columns.
*/
private void addColumnSelectExample() {
add(new WHeading(HeadingLevel.H3, "WRadioButtonSelect laid out in three columns"));
add(new ExplanatoryText("Setting the layout to COLUMN will make the radio buttons be rendered in 'n' columns. The number of columns is" + " determined by the layoutColumnCount property."));
final WRadioButtonSelect select = new WRadioButtonSelect("australian_state");
select.setButtonLayout(WRadioButtonSelect.LAYOUT_COLUMNS);
select.setButtonColumns(3);
add(new WLabel("Three column selection", select));
add(select);
add(new WHeading(HeadingLevel.H3, "Options equal to columns"));
String[] options = new String[] { "Dog", "Cat", "Bird" };
final WRadioButtonSelect select2 = new WRadioButtonSelect(options);
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() == null ? NO_SELECTION : "The selected animal is: " + select2.getSelected();
text.setText(output);
}
});
select2.setDefaultSubmitButton(update);
add(new WLabel("Three columns and three options", select2));
add(select2);
add(update);
add(text);
add(new WAjaxControl(update, text));
}
use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.
the class WRadioButtonSelectExample method addInsideAFieldLayoutExample.
/**
* When a WRadioButtonSelect is added to a WFieldLayout the legend is moved. The first CheckBoxSelect has a frame,
* the second doesn't
*/
private void addInsideAFieldLayoutExample() {
add(new WHeading(HeadingLevel.H3, "WRadioButtonSelect inside a WFieldLayout"));
add(new ExplanatoryText("When a WRadioButtonSelect is inside a WField its label is exposed in a way which appears and behaves like a regular HTML label." + " This allows WRadioButtonSelects to be used in a layout with simple form controls (such as WTextField) and produce a consistent" + " and predicatable interface.\n" + "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."));
// Note: the wrapper WPanel here is to work around a bug in validation. See https://github.com/BorderTech/wcomponents/issues/1370
final WPanel wrapper = new WPanel();
add(wrapper);
final WMessages messages = new WMessages();
wrapper.add(messages);
WFieldLayout layout = new WFieldLayout();
layout.setLabelWidth(25);
wrapper.add(layout);
WButton resetThisBit = new WButton("Reset this bit");
resetThisBit.setCancel(true);
resetThisBit.setAjaxTarget(wrapper);
resetThisBit.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
wrapper.reset();
}
});
layout.addField(resetThisBit);
String[] options = new String[] { "Dog", "Cat", "Bird", "Turtle" };
WRadioButtonSelect select = new WRadioButtonSelect(options);
layout.addField("Select an animal", select);
String[] options2 = new String[] { "Parrot", "Galah", "Cockatoo", "Lyre" };
select = new WRadioButtonSelect(options2);
select.setMandatory(true);
layout.addField("You must select a bird", 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 WRadioButtonSelect(options3);
// if you absolutely do not want a WLabel in a WField then it has to be added using null cast to a WLabel.
layout.addField((WLabel) null, select);
select.setToolTip("Veggies");
WButton btnValidate = new WButton("validate");
btnValidate.setAction(new ValidatingAction(messages.getValidationErrors(), layout) {
@Override
public void executeOnValid(final ActionEvent event) {
// do nothing
}
});
layout.addField(btnValidate);
wrapper.add(new WAjaxControl(btnValidate, wrapper));
}
Aggregations