use of com.github.bordertech.wcomponents.examples.common.ExplanatoryText in project wcomponents by BorderTech.
the class ColumnLayoutExample method addAutoWidthExample.
/**
* This example shows a column which does not have widths set in Java. This is a "good thing": widths should be set in CSS.
*/
private void addAutoWidthExample() {
add(new WHeading(HeadingLevel.H2, "Automatic (app defined) widths"));
add(new ExplanatoryText("This example shows what happens if you use undefined (0) column width and do not then define them in CSS."));
WPanel panel = new WPanel();
panel.setLayout(new ColumnLayout(new int[] { 0, 0, 0 }, new Alignment[] { Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT }));
add(panel);
panel.add(new BoxComponent("Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."));
panel.add(new BoxComponent("Praesent eu turpis convallis, fringilla elit nec, ullamcorper purus. Proin dictum ac nunc rhoncus fringilla. " + "Pellentesque habitant morbi tristique senectus et netus et malesuada fames."));
panel.add(new BoxComponent("Vestibulum vehicula a turpis et efficitur. Integer maximus enim a orci posuere, id fermentum magna dignissim. " + "Sed condimentum, dui et condimentum faucibus, quam erat pharetra."));
panel.add(new BoxComponent("Left"));
panel.add(new BoxComponent("Center"));
panel.add(new BoxComponent("Right"));
add(new WHorizontalRule());
}
use of com.github.bordertech.wcomponents.examples.common.ExplanatoryText in project wcomponents by BorderTech.
the class WCheckBoxSelectExample method addAntiPatternExamples.
/**
* Examples of what not to do when using WCheckBoxSelect.
*/
private void addAntiPatternExamples() {
add(new WHeading(HeadingLevel.H2, "WCheckBoxSelect anti-pattern examples"));
add(new WMessageBox(WMessageBox.WARN, "These examples are purposely bad and should not be used as samples of how to use WComponents but samples of how NOT to use them."));
add(new WHeading(HeadingLevel.H3, "WCheckBoxSelect with submitOnChange"));
WFieldLayout layout = new WFieldLayout(WFieldLayout.LAYOUT_STACKED);
add(layout);
WCheckBoxSelect select = new WCheckBoxSelect("australian_state");
select.setSubmitOnChange(true);
layout.addField("Select a state or territory with auto save", select);
select = new WCheckBoxSelect("australian_state");
select.setSubmitOnChange(true);
layout.addField("Select a state or territory with auto save and hint", select).getLabel().setHint("This is a hint");
// Even compound controls need a label
add(new WHeading(HeadingLevel.H3, "WCheckBoxSelect with no labelling component"));
add(new ExplanatoryText("All input controls, even those which are complex and do not output labellable HTML elements, must be associated with" + " a WLabel or have a toolTip."));
add(new WCheckBoxSelect("australian_state"));
// Too many options anti-pattern
add(new WHeading(HeadingLevel.H3, "WCheckBoxSelect with too many options"));
add(new ExplanatoryText("Don't use a WCheckBoxSelect if you have more than a handful of options. A good rule of thumb is fewer than 10."));
select = new WCheckBoxSelect(new String[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" });
select.setButtonLayout(WCheckBoxSelect.LAYOUT_COLUMNS);
select.setButtonColumns(6);
select.setFrameless(true);
add(new WLabel("Select your country of birth", select));
add(select);
add(new WHeading(HeadingLevel.H3, "WCheckBoxSelect with no options."));
add(new ExplanatoryText("An interactive WCheckBoxSelect with no options is rather pointless."));
select = new WCheckBoxSelect();
add(new WLabel("WCheckBoxSelect with no options", select));
add(select);
}
use of com.github.bordertech.wcomponents.examples.common.ExplanatoryText in project wcomponents by BorderTech.
the class WCheckBoxSelectExample method addSingleColumnSelectExample.
/**
* adds a WCheckBoxSelect with LAYOUT_COLUMN in 1 column simply by not setting the number of columns. This is
* superfluous as you should use LAYOUT_STACKED (the default) instead.
*/
private void addSingleColumnSelectExample() {
add(new WHeading(HeadingLevel.H3, "WCheckBoxSelect laid out in a single column"));
add(new ExplanatoryText("When layout is COLUMN, setting the layoutColumnCount property to one, or forgetting to set it at all (default is " + "one) is a little bit pointless."));
final WCheckBoxSelect select = new WCheckBoxSelect("australian_state");
select.setToolTip("Make a selection");
select.setButtonLayout(WCheckBoxSelect.LAYOUT_COLUMNS);
add(select);
}
use of com.github.bordertech.wcomponents.examples.common.ExplanatoryText in project wcomponents by BorderTech.
the class WLabelExample method addNestedFieldExamples.
/**
* Examples showing WLabel with a nested input control WComponent.
* This is VERY dangerous as only a very few WComponents are valid for this scenario. If you go down this route: stop!!
* These are really here for framework testing, not as examples as to how to do things.
*/
private void addNestedFieldExamples() {
add(new WHeading(HeadingLevel.H2, "Label nesting which is technically OK"));
/* Just because it is OK to do this does not mean you should! So these "examples" have far fewer comments. */
WPanel errorLayoutPanel = new WPanel();
errorLayoutPanel.setLayout(new FlowLayout(FlowLayout.VERTICAL, Size.LARGE));
errorLayoutPanel.setMargin(new Margin(null, null, Size.XL, null));
add(errorLayoutPanel);
errorLayoutPanel.add(new ExplanatoryText("This example shows WLabels with a single nested simple form control WTextField." + " This is not a contravention of the HTML specification but you should not do it."));
WLabel outerLabel = new WLabel("Label with nested WTextField and not 'for' anything");
errorLayoutPanel.add(outerLabel);
outerLabel.add(new WTextField());
WTextField innerField = new WTextField();
outerLabel = new WLabel("Label 'for' nested WTextField", innerField);
errorLayoutPanel.add(outerLabel);
outerLabel.add(innerField);
}
use of com.github.bordertech.wcomponents.examples.common.ExplanatoryText in project wcomponents by BorderTech.
the class WRadioButtonSelectExample method addMandatorySelectExample.
/**
* adds a WRadioButtonSelect with setMandatory(true).
*/
private void addMandatorySelectExample() {
add(new WHeading(HeadingLevel.H3, "Mandatory WRadioButtonSelect"));
add(new ExplanatoryText("When a WRadioButtonSelect is mandatory it needs a visible labelling element, otherwise many users may not know that " + "the component requires an answer."));
final WRadioButtonSelect select = new WRadioButtonSelect("australian_state");
select.setButtonLayout(WRadioButtonSelect.LAYOUT_FLAT);
select.setMandatory(true);
add(new WLabel("Mandatory selection", select));
add(select);
add(new WHeading(HeadingLevel.H3, "Mandatory WRadioButtonSelect in a WFieldLayout"));
WRadioButtonSelect select2 = new WRadioButtonSelect("australian_state");
select2.setButtonLayout(WRadioButtonSelect.LAYOUT_FLAT);
select2.setMandatory(true);
final WFieldLayout layout = new WFieldLayout();
layout.setLabelWidth(25);
add(layout);
layout.addField("Required selection", select2).getLabel().setHint("Required");
select2 = new WRadioButtonSelect("australian_state");
select2.setButtonLayout(WRadioButtonSelect.LAYOUT_FLAT);
select2.setMandatory(true);
select2.setToolTip("Select a state");
layout.addField((WLabel) null, select2);
}
Aggregations