Search in sources :

Example 6 with WStyledText

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

Example 7 with WStyledText

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

the class WStyledTextRenderer_Test method testParagraphText.

@Test
public void testParagraphText() throws IOException, SAXException, XpathException {
    WStyledText styledText = new WStyledText("abc def");
    styledText.setWhitespaceMode(WStyledText.WhitespaceMode.PARAGRAPHS);
    assertSchemaMatch(styledText);
    assertXpathEvaluatesTo("abc def", "//ui:text[@type='plain']", styledText);
    assertXpathEvaluatesTo("paragraphs", "//ui:text/@space", styledText);
    styledText.setText("abc\ndef");
    assertSchemaMatch(styledText);
    assertInnerTextEquals("abc<ui:nl/>def", styledText);
    styledText.setText("abc\rdef");
    assertSchemaMatch(styledText);
    assertInnerTextEquals("abc<ui:nl/>def", styledText);
    styledText.setText("abc\r\ndef");
    assertSchemaMatch(styledText);
    assertInnerTextEquals("abc<ui:nl/>def", styledText);
    styledText.setText("abc\n\rdef");
    assertSchemaMatch(styledText);
    assertInnerTextEquals("abc<ui:nl/>def", styledText);
    styledText.setText("abc\n\ndef");
    assertSchemaMatch(styledText);
    assertInnerTextEquals("abc<ui:nl/>def", styledText);
    styledText.setText("abc\r\rdef");
    assertSchemaMatch(styledText);
    assertInnerTextEquals("abc<ui:nl/>def", styledText);
    styledText.setText("abc\r\n\r\ndef");
    assertSchemaMatch(styledText);
    assertInnerTextEquals("abc<ui:nl/>def", styledText);
    styledText.setText("abc\n\r\r\ndef");
    assertSchemaMatch(styledText);
    assertInnerTextEquals("abc<ui:nl/>def", styledText);
    styledText.setText("\nabc\ndef\rghi\n");
    assertSchemaMatch(styledText);
    assertInnerTextEquals("abc<ui:nl/>def<ui:nl/>ghi", styledText);
}
Also used : WStyledText(com.github.bordertech.wcomponents.WStyledText) Test(org.junit.Test)

Aggregations

WStyledText (com.github.bordertech.wcomponents.WStyledText)7 Test (org.junit.Test)4 WHorizontalRule (com.github.bordertech.wcomponents.WHorizontalRule)2 Equal (com.github.bordertech.wcomponents.subordinate.Equal)2 Rule (com.github.bordertech.wcomponents.subordinate.Rule)2 Action (com.github.bordertech.wcomponents.Action)1 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)1 SubordinateTarget (com.github.bordertech.wcomponents.SubordinateTarget)1 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)1 WButton (com.github.bordertech.wcomponents.WButton)1 WComponentGroup (com.github.bordertech.wcomponents.WComponentGroup)1 WDropdown (com.github.bordertech.wcomponents.WDropdown)1 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)1 WPanel (com.github.bordertech.wcomponents.WPanel)1 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)1 Hide (com.github.bordertech.wcomponents.subordinate.Hide)1 ShowInGroup (com.github.bordertech.wcomponents.subordinate.ShowInGroup)1 WSubordinateControl (com.github.bordertech.wcomponents.subordinate.WSubordinateControl)1 ArrayList (java.util.ArrayList)1