use of com.github.bordertech.wcomponents.WFieldSet in project wcomponents by BorderTech.
the class LinkOptionsExample 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("Link configuration");
WFieldLayout layout = new WFieldLayout();
layout.setLabelWidth(30);
layout.addField("Link text", tfLinkLabel);
layout.addField("Link address", tfUrlField);
layout.addField("Link AccessKey", tfAccesskey).getLabel().setHint("A single upper case letter or digit.");
layout.addField("Render as button", cbRenderAsButton);
layout.addField("Disabled", cbDisabled);
layout.addField("Open in a new window", cbOpenNew);
layout.addField("setImage ('/image/attachment.png')", cbSetImage);
layout.addField("Image Position", ddImagePosition);
layout.setMargin(new com.github.bordertech.wcomponents.Margin(0, 0, 6, 0));
// 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;
}
use of com.github.bordertech.wcomponents.WFieldSet 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.WFieldSet 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.WFieldSet in project wcomponents by BorderTech.
the class WDateFieldExample method addDateRangeExample.
/**
* Add date range example.
*/
private void addDateRangeExample() {
add(new WHeading(WHeading.MAJOR, "Example of a date range component"));
WFieldSet dateRange = new WFieldSet("Enter the expected arrival and departure dates.");
add(dateRange);
WPanel dateRangePanel = new WPanel();
dateRangePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0));
dateRange.add(dateRangePanel);
final WDateField arrivalDate = new WDateField();
final WDateField departureDate = new WDateField();
// One could add some validation rules around this so that "arrival" was always earlier than or equal to "departure"
WLabel arrivalLabel = new WLabel("Arrival", arrivalDate);
arrivalLabel.setHint("dd MMM yyyy");
WLabel departureLabel = new WLabel("Departure", departureDate);
departureLabel.setHint("dd MMM yyyy");
dateRangePanel.add(arrivalLabel);
dateRangePanel.add(arrivalDate);
dateRangePanel.add(departureLabel);
dateRangePanel.add(departureDate);
// subordinate control to ensure that the departure date is only enabled if the arrival date is populated
WSubordinateControl control = new WSubordinateControl();
add(control);
Rule rule = new Rule(new Equal(arrivalDate, null));
control.addRule(rule);
rule.addActionOnTrue(new Disable(departureDate));
rule.addActionOnFalse(new Enable(departureDate));
control.addRule(rule);
}
use of com.github.bordertech.wcomponents.WFieldSet in project wcomponents by BorderTech.
the class AbstractSetEnable_Test method testExecuteWithWFieldSet.
@Test
public void testExecuteWithWFieldSet() {
// Setup targets in a FieldSet
WFieldSet fieldSet = new WFieldSet("test");
MyTarget target1 = new MyTarget();
MyTarget target2 = new MyTarget();
MyTarget target3 = new MyTarget();
fieldSet.add(target1);
fieldSet.add(target2);
fieldSet.add(target3);
AbstractSetEnable enable = new MyEnable(fieldSet, Boolean.FALSE);
// Targets should be enabled by default
Assert.assertFalse("WFieldSet - Target1 should be enabled", target1.isDisabled());
Assert.assertFalse("WFieldSet - Target2 should be enabled", target2.isDisabled());
Assert.assertFalse("WFieldSet - Target3 should be enabled", target3.isDisabled());
enable.execute();
// Targets should be disabled
Assert.assertTrue("WFieldSet - Target1 should be disabled", target1.isDisabled());
Assert.assertTrue("WFieldSet - Target2 should be disabled", target2.isDisabled());
Assert.assertTrue("WFieldSet - Target3 should be disabled", target3.isDisabled());
}
Aggregations