Search in sources :

Example 46 with WPanel

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 }));
}
Also used : WAjaxControl(com.github.bordertech.wcomponents.WAjaxControl) WSkipLinks(com.github.bordertech.wcomponents.WSkipLinks) WPanel(com.github.bordertech.wcomponents.WPanel) WHeading(com.github.bordertech.wcomponents.WHeading) AjaxTarget(com.github.bordertech.wcomponents.AjaxTarget)

Example 47 with WPanel

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));
}
Also used : Action(com.github.bordertech.wcomponents.Action) WAjaxControl(com.github.bordertech.wcomponents.WAjaxControl) BorderLayout(com.github.bordertech.wcomponents.layout.BorderLayout) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) WPanel(com.github.bordertech.wcomponents.WPanel) WButton(com.github.bordertech.wcomponents.WButton) Margin(com.github.bordertech.wcomponents.Margin)

Example 48 with WPanel

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));
}
Also used : Action(com.github.bordertech.wcomponents.Action) WAjaxControl(com.github.bordertech.wcomponents.WAjaxControl) WText(com.github.bordertech.wcomponents.WText) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) WPanel(com.github.bordertech.wcomponents.WPanel) WButton(com.github.bordertech.wcomponents.WButton) WHeading(com.github.bordertech.wcomponents.WHeading)

Example 49 with WPanel

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);
}
Also used : WFieldSet(com.github.bordertech.wcomponents.WFieldSet) FlowLayout(com.github.bordertech.wcomponents.layout.FlowLayout) Equal(com.github.bordertech.wcomponents.subordinate.Equal) WPanel(com.github.bordertech.wcomponents.WPanel) WSubordinateControl(com.github.bordertech.wcomponents.subordinate.WSubordinateControl) WDateField(com.github.bordertech.wcomponents.WDateField) Enable(com.github.bordertech.wcomponents.subordinate.Enable) Rule(com.github.bordertech.wcomponents.subordinate.Rule) WHeading(com.github.bordertech.wcomponents.WHeading) Disable(com.github.bordertech.wcomponents.subordinate.Disable) WLabel(com.github.bordertech.wcomponents.WLabel)

Example 50 with WPanel

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);
}
Also used : FlowLayout(com.github.bordertech.wcomponents.layout.FlowLayout) WPanel(com.github.bordertech.wcomponents.WPanel) ExplanatoryText(com.github.bordertech.wcomponents.examples.common.ExplanatoryText) WTextField(com.github.bordertech.wcomponents.WTextField) WHeading(com.github.bordertech.wcomponents.WHeading) Margin(com.github.bordertech.wcomponents.Margin) WLabel(com.github.bordertech.wcomponents.WLabel)

Aggregations

WPanel (com.github.bordertech.wcomponents.WPanel)77 Test (org.junit.Test)39 WHeading (com.github.bordertech.wcomponents.WHeading)17 WText (com.github.bordertech.wcomponents.WText)17 FlowLayout (com.github.bordertech.wcomponents.layout.FlowLayout)16 WButton (com.github.bordertech.wcomponents.WButton)13 ColumnLayout (com.github.bordertech.wcomponents.layout.ColumnLayout)10 WContainer (com.github.bordertech.wcomponents.WContainer)9 WHorizontalRule (com.github.bordertech.wcomponents.WHorizontalRule)9 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)8 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)8 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)7 WLabel (com.github.bordertech.wcomponents.WLabel)7 Action (com.github.bordertech.wcomponents.Action)6 WTextField (com.github.bordertech.wcomponents.WTextField)6 ArrayList (java.util.ArrayList)6 Size (com.github.bordertech.wcomponents.Size)5 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)5 BorderLayout (com.github.bordertech.wcomponents.layout.BorderLayout)5 Alignment (com.github.bordertech.wcomponents.layout.ColumnLayout.Alignment)5