use of com.github.bordertech.wcomponents.WFieldSet in project wcomponents by BorderTech.
the class SubordinateControlOptionsExample method setupTrigger.
/**
* Setup the trigger for the subordinate control.
*/
private void setupTrigger() {
String label = drpTriggerType.getSelected() + " Trigger";
WFieldLayout layout = new WFieldLayout();
layout.setLabelWidth(LABEL_WIDTH);
buildControlPanel.add(layout);
switch((TriggerType) drpTriggerType.getSelected()) {
case RadioButtonGroup:
trigger = new RadioButtonGroup();
WFieldSet rbSet = new WFieldSet("Select an option");
RadioButtonGroup group = (RadioButtonGroup) trigger;
WRadioButton rb1 = group.addRadioButton("A");
WRadioButton rb2 = group.addRadioButton("B");
WRadioButton rb3 = group.addRadioButton("C");
rbSet.add(group);
rbSet.add(rb1);
rbSet.add(new WLabel("A", rb1));
rbSet.add(new WText("\u00a0"));
rbSet.add(rb2);
rbSet.add(new WLabel("B", rb2));
rbSet.add(new WText("\u00a0"));
rbSet.add(rb3);
rbSet.add(new WLabel("C", rb3));
layout.addField(label, rbSet);
return;
case CheckBox:
trigger = new WCheckBox();
break;
case CheckBoxSelect:
trigger = new WCheckBoxSelect(LOOKUP_TABLE_NAME);
break;
case DateField:
trigger = new WDateField();
break;
case Dropdown:
trigger = new WDropdown(new TableWithNullOption(LOOKUP_TABLE_NAME));
break;
case EmailField:
trigger = new WEmailField();
break;
case MultiSelect:
trigger = new WMultiSelect(LOOKUP_TABLE_NAME);
break;
case MultiSelectPair:
trigger = new WMultiSelectPair(LOOKUP_TABLE_NAME);
break;
case NumberField:
trigger = new WNumberField();
break;
case PartialDateField:
trigger = new WPartialDateField();
break;
case PasswordField:
trigger = new WPasswordField();
break;
case PhoneNumberField:
trigger = new WPhoneNumberField();
break;
case RadioButtonSelect:
trigger = new WRadioButtonSelect(LOOKUP_TABLE_NAME);
break;
case SingleSelect:
trigger = new WSingleSelect(LOOKUP_TABLE_NAME);
break;
case TextArea:
trigger = new WTextArea();
((WTextArea) trigger).setMaxLength(1000);
break;
case TextField:
trigger = new WTextField();
break;
default:
throw new SystemException("Trigger type not valid");
}
layout.addField(label, trigger);
}
use of com.github.bordertech.wcomponents.WFieldSet in project wcomponents by BorderTech.
the class WFieldSetExample method addFieldSet.
/**
* Creates a WFieldSet with content and a given FrameType.
*
* @param title The title to give to the WFieldSet.
* @param type The decorative model of the WFieldSet
* @return a WFieldSet with form control content.
*/
private WFieldSet addFieldSet(final String title, final WFieldSet.FrameType type) {
final WFieldSet fieldset = new WFieldSet(title);
fieldset.setFrameType(type);
fieldset.setMargin(new com.github.bordertech.wcomponents.Margin(0, 0, 12, 0));
final WFieldLayout layout = new WFieldLayout();
fieldset.add(layout);
layout.setLabelWidth(25);
layout.addField("Street address", new WTextField());
final WField add2Field = layout.addField("Street address line 2", new WTextField());
add2Field.getLabel().setHidden(true);
layout.addField("Suburb", new WTextField());
layout.addField("State/Territory", new WDropdown(new String[] { "", "ACT", "NSW", "NT", "QLD", "SA", "TAS", "VIC", "WA" }));
// NOTE: this is an Australia-specific post code field. An Australian post code is not a number as they may contain a leading zero.
final WTextField postcode = new WTextField();
postcode.setMaxLength(4);
postcode.setColumns(4);
postcode.setMinLength(3);
layout.addField("Postcode", postcode);
add(fieldset);
return fieldset;
}
use of com.github.bordertech.wcomponents.WFieldSet in project wcomponents by BorderTech.
the class WLabelExample method addNullLabelExample.
/**
* Example of when and how to use a null WLabel.
*/
private void addNullLabelExample() {
add(new WHeading(HeadingLevel.H2, "How to use accessible null WLabels"));
add(new ExplanatoryText("These examples shows how sometime a null WLabel is the right thing to do." + "\n This example uses a WFieldSet as the labelled component and it has its own \"label\"."));
// We want to add a WFieldSet to a WFieldLayout but without an extra label.
WFieldLayout fieldsFlat = new WFieldLayout();
fieldsFlat.setMargin(new Margin(null, null, Size.XL, null));
add(fieldsFlat);
WFieldSet fs = new WFieldSet("Do you like Bananas?");
fieldsFlat.addField((WLabel) null, fs);
// now add the WRadioButtons to the WFieldSet using an inner WFieldLayout
WFieldLayout innerLayout = new WFieldLayout(WFieldLayout.LAYOUT_STACKED);
// The content will be a group of WRadioButtons
RadioButtonGroup group1 = new RadioButtonGroup();
WRadioButton rb1 = group1.addRadioButton(1);
WRadioButton rb2 = group1.addRadioButton(2);
// make the labels for the radio buttons
WLabel rb1Label = new WLabel("", rb1);
WImage labelImage = new WImage("/image/success.png", "I still like bananas");
labelImage.setHtmlClass("wc-valign-bottom");
rb1Label.add(labelImage);
WLabel rb2Label = new WLabel("", rb2);
labelImage = new WImage("/image/error.png", "I still dislike bananas");
labelImage.setHtmlClass("wc-valign-bottom");
rb2Label.add(labelImage);
innerLayout.addField(rb1Label, rb1);
innerLayout.addField(rb2Label, rb2);
// add the content to the WFieldLayout - the order really doesn't matter.
fs.add(group1);
fs.add(innerLayout);
}
use of com.github.bordertech.wcomponents.WFieldSet in project wcomponents by BorderTech.
the class ButtonOptionsExample 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("Button configuration");
WFieldLayout layout = new WFieldLayout();
layout.setLabelWidth(30);
layout.addField("Text", tfButtonLabel);
layout.addField("AccessKey", tfAccesskey);
layout.addField("Render as link", cbRenderAsLink);
layout.addField("Disabled", cbDisabled);
layout.addField("setImage ('/image/pencil.png')", cbSetImage);
layout.addField("Image Position", ddImagePosition);
// 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 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;
}
Aggregations