Search in sources :

Example 36 with WPanel

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

the class WRadioButtonRenderer_Test method testIsNullOption.

@Test
public void testIsNullOption() throws IOException, SAXException, XpathException {
    WPanel root = new WPanel();
    RadioButtonGroup group = new RadioButtonGroup();
    root.add(group);
    WRadioButton button1 = group.addRadioButton(null);
    WRadioButton button2 = group.addRadioButton("");
    WRadioButton button3 = group.addRadioButton("A");
    root.add(button1);
    root.add(button2);
    root.add(button3);
    assertSchemaMatch(root);
    assertXpathEvaluatesTo("true", "//ui:radiobutton/@isNull", button1);
    assertXpathEvaluatesTo("true", "//ui:radiobutton/@isNull", button2);
    assertXpathEvaluatesTo("", "//ui:radiobutton/@isNull", button3);
}
Also used : WRadioButton(com.github.bordertech.wcomponents.WRadioButton) WPanel(com.github.bordertech.wcomponents.WPanel) RadioButtonGroup(com.github.bordertech.wcomponents.RadioButtonGroup) Test(org.junit.Test)

Example 37 with WPanel

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

the class WRadioButtonSelectRenderer_Test method testDoPaintAllOptions.

@Test
public void testDoPaintAllOptions() throws IOException, SAXException, XpathException {
    WRadioButtonSelect group = new WRadioButtonSelect();
    // Set ALL Options
    group.setDisabled(true);
    setFlag(group, ComponentModel.HIDE_FLAG, true);
    group.setMandatory(true);
    group.setSubmitOnChange(true);
    group.setToolTip("tip");
    group.setFrameless(true);
    group.setAjaxTarget(new WPanel());
    group.setButtonLayout(WRadioButtonSelect.LAYOUT_COLUMNS);
    group.setButtonColumns(2);
    // Validate ALL Options
    assertSchemaMatch(group);
    assertXpathEvaluatesTo(group.getId(), "//ui:radiobuttonselect/@id", group);
    assertXpathEvaluatesTo("true", "//ui:radiobuttonselect/@disabled", group);
    assertXpathEvaluatesTo("true", "//ui:radiobuttonselect/@hidden", group);
    assertXpathEvaluatesTo("true", "//ui:radiobuttonselect/@required", group);
    assertXpathEvaluatesTo("true", "//ui:radiobuttonselect/@submitOnChange", group);
    assertXpathEvaluatesTo("tip", "//ui:radiobuttonselect/@toolTip", group);
    assertXpathEvaluatesTo("true", "//ui:radiobuttonselect/@frameless", group);
    assertXpathEvaluatesTo("column", "//ui:radiobuttonselect/@layout", group);
    assertXpathEvaluatesTo("2", "//ui:radiobuttonselect/@layoutColumnCount", group);
    assertXpathEvaluatesTo(group.getId(), "//ui:ajaxtrigger/@triggerId", group);
}
Also used : WPanel(com.github.bordertech.wcomponents.WPanel) WRadioButtonSelect(com.github.bordertech.wcomponents.WRadioButtonSelect) Test(org.junit.Test)

Example 38 with WPanel

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

the class ObjectGraphDump_Test method testDump.

@Test
public void testDump() {
    WPanel component = new WPanel();
    component.setLayout(new BorderLayout());
    component.add(new WLabel(TEST_LABEL), BorderLayout.NORTH);
    ObjectGraphNode graphNode = ObjectGraphDump.dump(component);
    String result = graphNode.toXml();
    // ObjectGraphNode tested independently
    // for the input 'component' above - the dump result must at least contain the following
    // and have run without exceptions
    Assert.assertTrue("", result.indexOf("type=\"com.github.bordertech.wcomponents.WPanel\"") != -1);
    Assert.assertTrue("", result.indexOf("field=\"label\" type=\"com.github.bordertech.wcomponents.WLabel\"") != -1);
    Assert.assertTrue("", result.indexOf("field=\"text\" value=\""" + TEST_LABEL + ""\" type=\"java.io.Serializable\"") != -1);
    Assert.assertTrue("", result.indexOf("field=\"value\" type=\"com.github.bordertech.wcomponents.layout.BorderLayout$BorderLayoutConstraint\"") != -1);
}
Also used : BorderLayout(com.github.bordertech.wcomponents.layout.BorderLayout) WPanel(com.github.bordertech.wcomponents.WPanel) WLabel(com.github.bordertech.wcomponents.WLabel) Test(org.junit.Test)

Example 39 with WPanel

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

the class WButtonExample method addImageExamples.

/**
 * An example to cover the gamut of image buttons both with and without visible text and with both renderAsLink and
 * render as button.
 */
private void addImageExamples() {
    // Button rendered with an image only
    add(new WHeading(HeadingLevel.H2, "Image buttons"));
    add(new ExplanatoryText("This example shows how to use an image inside a WButton."));
    add(new WHeading(HeadingLevel.H3, "Just an image"));
    add(new ExplanatoryText("This example shows how to use an image as the only content of a WButton. " + "The button must still have text content to adequately explain the button's purpose."));
    add(new WHeading(HeadingLevel.H4, "Image in a button"));
    add(makeImageButton("Save", false));
    add(new WHeading(HeadingLevel.H4, "Image button without button style"));
    add(new ExplanatoryText("This example shows how to use an image as the only content of a WButton when styled to be without its button appearance. " + "If you are creating a button containing only an image you should be careful as it may not be obvious to the application user that the 'image' is actually a 'button'." + "The button must still have text content to adequately explain the button's purpose."));
    add(makeImageButton("Save", true));
    add(new ExplanatoryText("Button using a WImage description as the text equivalent."));
    WButton button = new WButton();
    WImage buttonImage = new WImage("/image/tick.png", "Mark as OK");
    button.setImage(buttonImage.getImage());
    add(button);
    add(new WHeading(HeadingLevel.H3, "Image and text"));
    add(new ExplanatoryText("This example shows how to use an image and text as the content of a button."));
    add(new WHeading(HeadingLevel.H4, "Rendered as a button"));
    WPanel buttonLayoutPanel = new WPanel(WPanel.Type.BOX);
    buttonLayoutPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0, FlowLayout.ContentAlignment.BOTTOM));
    add(buttonLayoutPanel);
    buttonLayoutPanel.add(makeImageButtonWithPosition("Image on the North", ImagePosition.NORTH));
    buttonLayoutPanel.add(makeImageButtonWithPosition("Image on the East", ImagePosition.EAST));
    buttonLayoutPanel.add(makeImageButtonWithPosition("Image on the South", ImagePosition.SOUTH));
    buttonLayoutPanel.add(makeImageButtonWithPosition("Image on the West", ImagePosition.WEST));
    add(new WHeading(HeadingLevel.H4, "Rendered as a link"));
    add(new ExplanatoryText("This example shows how to use an image and text as the content of a button without the button styling."));
    buttonLayoutPanel = new WPanel(WPanel.Type.BOX);
    buttonLayoutPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0, FlowLayout.ContentAlignment.BOTTOM));
    add(buttonLayoutPanel);
    buttonLayoutPanel.add(makeImageButtonWithPosition("Image on the North", ImagePosition.NORTH, true));
    buttonLayoutPanel.add(makeImageButtonWithPosition("Image on the East", ImagePosition.EAST, true));
    buttonLayoutPanel.add(makeImageButtonWithPosition("Image on the South", ImagePosition.SOUTH, true));
    buttonLayoutPanel.add(makeImageButtonWithPosition("Image on the West", ImagePosition.WEST, true));
    add(new WHeading(HeadingLevel.H4, "Using theme icons"));
    add(new ExplanatoryText("These examples show ways to add an icon to a button using 'HtmlClassUtil'."));
    // \u200b is a zero-width space.
    WButton iconButton = new WButton("\u200b");
    iconButton.setToolTip("Edit");
    iconButton.setHtmlClass(HtmlClassProperties.ICON_EDIT);
    add(iconButton);
    iconButton = new WButton("Save");
    iconButton.setHtmlClass(HtmlClassProperties.ICON_SAVE_BEFORE);
    add(iconButton);
    iconButton = new WButton("Search");
    iconButton.setHtmlClass(HtmlClassProperties.ICON_SEARCH_AFTER);
    add(iconButton);
    add(new ExplanatoryText("These examples show ways to add a Font-Awesome icon to a button using 'setHtmlClass'."));
    // \u200b is a zero-width space.
    iconButton = new WButton("\u200b");
    iconButton.setToolTip("Open Menu");
    iconButton.setHtmlClass(HtmlIconUtil.getIconClasses("fa-bars"));
    add(iconButton);
    iconButton = new WButton("With text content");
    iconButton.setHtmlClass(HtmlIconUtil.getIconClasses("fa-hand-o-left", HtmlIconUtil.IconPosition.BEFORE));
    add(iconButton);
    iconButton = new WButton("Right icon with text content");
    iconButton.setHtmlClass(HtmlIconUtil.getIconClasses("fa-hand-o-right", HtmlIconUtil.IconPosition.AFTER));
    add(iconButton);
}
Also used : FlowLayout(com.github.bordertech.wcomponents.layout.FlowLayout) WPanel(com.github.bordertech.wcomponents.WPanel) WImage(com.github.bordertech.wcomponents.WImage) ExplanatoryText(com.github.bordertech.wcomponents.examples.common.ExplanatoryText) WButton(com.github.bordertech.wcomponents.WButton) WHeading(com.github.bordertech.wcomponents.WHeading)

Example 40 with WPanel

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

the class WDropdownOptionsExample method buildSubordinatePanel.

/**
 * Builds a panel for the subordinate control, including the rule for that particular option.
 *
 * @param dropdown the subordinate trigger.
 * @param value the dropdown option to be added
 * @param group the group
 * @param control the subordinate control
 */
private void buildSubordinatePanel(final WDropdown dropdown, final String value, final WComponentGroup<SubordinateTarget> group, final WSubordinateControl control) {
    // create the panel.
    WPanel panel = new WPanel();
    WStyledText subordinateInfo = new WStyledText();
    subordinateInfo.setWhitespaceMode(WhitespaceMode.PRESERVE);
    subordinateInfo.setText(value + " - Subordinate");
    panel.add(subordinateInfo);
    // add the panel to the screen and group.
    infoPanel.add(panel);
    group.addToGroup(panel);
    // create the rule
    Rule rule = new Rule();
    control.addRule(rule);
    rule.setCondition(new Equal(dropdown, value));
    rule.addActionOnTrue(new ShowInGroup(panel, group));
}
Also used : ShowInGroup(com.github.bordertech.wcomponents.subordinate.ShowInGroup) Equal(com.github.bordertech.wcomponents.subordinate.Equal) WPanel(com.github.bordertech.wcomponents.WPanel) WStyledText(com.github.bordertech.wcomponents.WStyledText) Rule(com.github.bordertech.wcomponents.subordinate.Rule) WHorizontalRule(com.github.bordertech.wcomponents.WHorizontalRule)

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