Search in sources :

Example 36 with WHeading

use of com.github.bordertech.wcomponents.WHeading in project wcomponents by BorderTech.

the class WButtonExample method addDefaultSubmitButtonExample.

/**
 * Examples showing how to set a WButton as the default submit button for an input control.
 */
private void addDefaultSubmitButtonExample() {
    add(new WHeading(HeadingLevel.H3, "Default submit button"));
    add(new ExplanatoryText("This example shows how to use an image as the only content of a WButton. " + "In addition this text field submits the entire screen using the image button to the right of the field."));
    // We use WFieldLayout to lay out a label:input pair. In this case the input is a
    // compound control of a WTextField and a WButton.
    WFieldLayout imageButtonFieldLayout = new WFieldLayout();
    imageButtonFieldLayout.setLabelWidth(25);
    add(imageButtonFieldLayout);
    // the text field and the button both need to be defined explicitly to be able to add them into a wrapper
    WTextField textFld = new WTextField();
    // and finally we get to the actual button
    WButton button = new WButton("Flag this record for follow-up");
    button.setImage("/image/flag.png");
    button.getImageHolder().setCacheKey("eg-button-flag");
    button.setActionObject(button);
    button.setAction(new ExampleButtonAction());
    // we can set the image button to be the default submit button for the text field.
    textFld.setDefaultSubmitButton(button);
    // There are many way of putting multiple controls in to a WField's input.
    // We are using a WContainer is the one which is lowest impact in the UI.
    WContainer imageButtonFieldContainer = new WContainer();
    imageButtonFieldContainer.add(textFld);
    // Use a WText to push the button off of the text field by an appropriate (user-agent determined) amount.
    // an en space is half an em. a none-breaking space \u00a0 could also be used but will have no effect on inter-node wrapping
    imageButtonFieldContainer.add(new WText("\u2002"));
    imageButtonFieldContainer.add(button);
    // Finally add the input wrapper to the WFieldLayout
    imageButtonFieldLayout.addField("Enter record ID", imageButtonFieldContainer);
}
Also used : WContainer(com.github.bordertech.wcomponents.WContainer) WText(com.github.bordertech.wcomponents.WText) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) ExplanatoryText(com.github.bordertech.wcomponents.examples.common.ExplanatoryText) WTextField(com.github.bordertech.wcomponents.WTextField) WButton(com.github.bordertech.wcomponents.WButton) WHeading(com.github.bordertech.wcomponents.WHeading)

Example 37 with WHeading

use of com.github.bordertech.wcomponents.WHeading in project wcomponents by BorderTech.

the class ColumnLayoutExample method addHgapVGapExample.

/**
 * Build an example using hgap and vgap.
 *
 * @param hgap the hgap width
 * @param vgap the vgap width
 */
private void addHgapVGapExample(final Size hgap, final Size vgap) {
    add(new WHeading(HeadingLevel.H2, "Column Layout: hgap=" + hgap.toString() + " vgap=" + vgap.toString()));
    WPanel panel = new WPanel();
    panel.setLayout(new ColumnLayout(new int[] { 25, 25, 25, 25 }, hgap, vgap));
    add(panel);
    for (int i = 0; i < 8; i++) {
        panel.add(new BoxComponent("25%"));
    }
    add(new WHorizontalRule());
}
Also used : WPanel(com.github.bordertech.wcomponents.WPanel) ColumnLayout(com.github.bordertech.wcomponents.layout.ColumnLayout) WHeading(com.github.bordertech.wcomponents.WHeading) WHorizontalRule(com.github.bordertech.wcomponents.WHorizontalRule)

Example 38 with WHeading

use of com.github.bordertech.wcomponents.WHeading in project wcomponents by BorderTech.

the class ColumnLayoutExample method addResponsiveExample.

/**
 * Add a column layout which will change its rendering on small screens.
 */
private void addResponsiveExample() {
    add(new WHeading(HeadingLevel.H2, "Default responsive design"));
    add(new ExplanatoryText("This example applies the theme's default responsive design rules for ColumnLayout.\n " + "The columns have width and alignment and there is also a hgap and a vgap."));
    WPanel panel = new WPanel();
    panel.setLayout(new ColumnLayout(new int[] { 33, 33, 33 }, new Alignment[] { Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT }, 12, 18));
    panel.setHtmlClass(HtmlClassProperties.RESPOND);
    add(panel);
    panel.add(new BoxComponent("Left"));
    panel.add(new BoxComponent("Center"));
    panel.add(new BoxComponent("Right"));
    panel.add(new BoxComponent("Left"));
    panel.add(new BoxComponent("Center"));
    panel.add(new BoxComponent("Right"));
}
Also used : Alignment(com.github.bordertech.wcomponents.layout.ColumnLayout.Alignment) WPanel(com.github.bordertech.wcomponents.WPanel) ColumnLayout(com.github.bordertech.wcomponents.layout.ColumnLayout) ExplanatoryText(com.github.bordertech.wcomponents.examples.common.ExplanatoryText) WHeading(com.github.bordertech.wcomponents.WHeading)

Example 39 with WHeading

use of com.github.bordertech.wcomponents.WHeading 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());
}
Also used : Alignment(com.github.bordertech.wcomponents.layout.ColumnLayout.Alignment) WPanel(com.github.bordertech.wcomponents.WPanel) ColumnLayout(com.github.bordertech.wcomponents.layout.ColumnLayout) ExplanatoryText(com.github.bordertech.wcomponents.examples.common.ExplanatoryText) WHeading(com.github.bordertech.wcomponents.WHeading) WHorizontalRule(com.github.bordertech.wcomponents.WHorizontalRule)

Example 40 with WHeading

use of com.github.bordertech.wcomponents.WHeading 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)

Aggregations

WHeading (com.github.bordertech.wcomponents.WHeading)53 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)26 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)18 WPanel (com.github.bordertech.wcomponents.WPanel)17 WButton (com.github.bordertech.wcomponents.WButton)16 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)13 WLabel (com.github.bordertech.wcomponents.WLabel)13 Action (com.github.bordertech.wcomponents.Action)12 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)12 WCheckBoxSelect (com.github.bordertech.wcomponents.WCheckBoxSelect)12 WRadioButtonSelect (com.github.bordertech.wcomponents.WRadioButtonSelect)10 WTextField (com.github.bordertech.wcomponents.WTextField)10 WText (com.github.bordertech.wcomponents.WText)9 ColumnLayout (com.github.bordertech.wcomponents.layout.ColumnLayout)7 FlowLayout (com.github.bordertech.wcomponents.layout.FlowLayout)7 WHorizontalRule (com.github.bordertech.wcomponents.WHorizontalRule)6 Test (org.junit.Test)5 Margin (com.github.bordertech.wcomponents.Margin)4 Alignment (com.github.bordertech.wcomponents.layout.ColumnLayout.Alignment)4 ValidatingAction (com.github.bordertech.wcomponents.validation.ValidatingAction)4