use of com.github.bordertech.wcomponents.WPanel in project wcomponents by BorderTech.
the class TreePicker method buildUI.
/**
* Add all the bits in the right order.
*/
private void buildUI() {
add(new WSkipLinks());
// the application header
add(headerPanel);
headerPanel.add(new UtilityBar());
headerPanel.add(new WHeading(HeadingLevel.H1, "WComponents"));
// mainPanel holds the menu and the actual example.
add(mainPanel);
mainPanel.add(menuPanel);
mainPanel.add(exampleSection);
// An application footer?
WPanel footer = new WPanel(WPanel.Type.FOOTER);
footer.add(lastLoaded);
add(footer);
add(new WAjaxControl(menuPanel.getTree(), new AjaxTarget[] { menuPanel.getMenu(), exampleSection }));
}
use of com.github.bordertech.wcomponents.WPanel in project wcomponents by BorderTech.
the class RepeaterExampleWithStaticIDs method createButtonBar.
/**
* Create the UI artefacts for the update and reset buttons.
*/
private void createButtonBar() {
// Update and reset controls for the repeater.
WPanel buttonPanel = new WPanel(WPanel.Type.FEATURE);
buttonPanel.setMargin(new Margin(Size.MEDIUM, null, Size.LARGE, null));
buttonPanel.setLayout(new BorderLayout());
WButton updateButton = new WButton("Update");
updateButton.setImage("/image/document-save-5.png");
updateButton.setImagePosition(WButton.ImagePosition.EAST);
buttonPanel.add(updateButton, BorderLayout.EAST);
WButton resetButton = new WButton("Reset");
resetButton.setImage("/image/edit-undo-8.png");
resetButton.setImagePosition(WButton.ImagePosition.WEST);
resetButton.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
repeater.setData(fetchDataList());
}
});
buttonPanel.add(resetButton, BorderLayout.WEST);
add(buttonPanel);
add(new WAjaxControl(updateButton, repeater));
add(new WAjaxControl(resetButton, repeater));
}
use of com.github.bordertech.wcomponents.WPanel in project wcomponents by BorderTech.
the class WConfirmationButtonExample method addAjaxExample.
/**
* This is used to reproduce a WComponents bug condition to make sure we do not re-create it once it is fixed.
* See https://github.com/BorderTech/wcomponents/issues/1266.
*/
private void addAjaxExample() {
add(new WHeading(HeadingLevel.H2, "Confirm as ajax trigger"));
final String before = "Before";
final String after = "After";
final WText ajaxContent = new WText("Before");
final WPanel target = new WPanel(WPanel.Type.BOX);
add(target);
target.add(ajaxContent);
WButton confirmWithAjax = new WButton("Replace");
confirmWithAjax.setMessage("Are you sure?");
confirmWithAjax.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
ajaxContent.setText(before.equals(ajaxContent.getText()) ? after : before);
}
});
add(confirmWithAjax);
add(new WAjaxControl(confirmWithAjax, target));
}
use of com.github.bordertech.wcomponents.WPanel 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.WPanel 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);
}
Aggregations