Search in sources :

Example 1 with WHeading

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

the class WHeadingRenderer_Test method testPaintWithDecoratedLabel.

@Test
public void testPaintWithDecoratedLabel() throws IOException, SAXException, XpathException {
    final String text1 = "WHeading_Test.testPaintWithDecoratedLabel.text1";
    final String text2 = "WHeading_Test.testPaintWithDecoratedLabel.text2";
    WHeading heading = new WHeading(HeadingLevel.H1, new WDecoratedLabel(new WText(text1)));
    assertSchemaMatch(heading);
    assertXpathEvaluatesTo(text1, "//ui:heading[@level=1]/ui:decoratedlabel/ui:labelbody/text()", heading);
    // Test WHeading's WText implementation
    heading.setText(text2);
    assertXpathEvaluatesTo(text2 + text1, "//ui:heading[@level=1]/ui:decoratedlabel/ui:labelbody/text()", heading);
}
Also used : WText(com.github.bordertech.wcomponents.WText) WHeading(com.github.bordertech.wcomponents.WHeading) WDecoratedLabel(com.github.bordertech.wcomponents.WDecoratedLabel) Test(org.junit.Test)

Example 2 with WHeading

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

the class WHeadingRenderer_Test method testRenderedWithMargins.

@Test
public void testRenderedWithMargins() throws IOException, SAXException, XpathException {
    WHeading heading = new WHeading(HeadingLevel.H1, "test");
    assertXpathNotExists("//ui:heading/ui:margin", heading);
    Margin margin = new Margin(null);
    heading.setMargin(margin);
    assertXpathNotExists("//ui:heading/ui:margin", heading);
    margin = new Margin(Size.SMALL);
    heading.setMargin(margin);
    assertSchemaMatch(heading);
    assertXpathEvaluatesTo("sm", "//ui:heading/ui:margin/@all", heading);
    assertXpathEvaluatesTo("", "//ui:heading/ui:margin/@north", heading);
    assertXpathEvaluatesTo("", "//ui:heading/ui:margin/@east", heading);
    assertXpathEvaluatesTo("", "//ui:heading/ui:margin/@south", heading);
    assertXpathEvaluatesTo("", "//ui:heading/ui:margin/@west", heading);
    margin = new Margin(Size.SMALL, Size.MEDIUM, Size.LARGE, Size.XL);
    heading.setMargin(margin);
    assertSchemaMatch(heading);
    assertXpathEvaluatesTo("", "//ui:heading/ui:margin/@all", heading);
    assertXpathEvaluatesTo("sm", "//ui:heading/ui:margin/@north", heading);
    assertXpathEvaluatesTo("med", "//ui:heading/ui:margin/@east", heading);
    assertXpathEvaluatesTo("lg", "//ui:heading/ui:margin/@south", heading);
    assertXpathEvaluatesTo("xl", "//ui:heading/ui:margin/@west", heading);
}
Also used : WHeading(com.github.bordertech.wcomponents.WHeading) Margin(com.github.bordertech.wcomponents.Margin) Test(org.junit.Test)

Example 3 with WHeading

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

the class WHeadingRenderer_Test method testRendererCorrectlyConfigured.

@Test
public void testRendererCorrectlyConfigured() {
    WHeading component = new WHeading(HeadingLevel.H1, "");
    Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(component) instanceof WHeadingRenderer);
}
Also used : WHeading(com.github.bordertech.wcomponents.WHeading) Test(org.junit.Test)

Example 4 with WHeading

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

the class WHeadingRenderer_Test method testPaint.

@Test
public void testPaint() throws IOException, SAXException, XpathException {
    final String text = "WHeading_Test.testPaint.heading";
    WHeading heading = new WHeading(HeadingLevel.H1, text);
    assertSchemaMatch(heading);
    assertXpathEvaluatesTo(text, "//ui:heading[@level=1]", heading);
    heading = new WHeading(HeadingLevel.H2, text);
    assertSchemaMatch(heading);
    assertXpathEvaluatesTo(text, "//ui:heading[@level=2]", heading);
    heading = new WHeading(HeadingLevel.H3, text);
    assertSchemaMatch(heading);
    assertXpathEvaluatesTo(text, "//ui:heading[@level=3]", heading);
    heading = new WHeading(HeadingLevel.H4, text);
    assertSchemaMatch(heading);
    assertXpathEvaluatesTo(text, "//ui:heading[@level=4]", heading);
    heading = new WHeading(HeadingLevel.H5, text);
    assertSchemaMatch(heading);
    assertXpathEvaluatesTo(text, "//ui:heading[@level=5]", heading);
    heading = new WHeading(HeadingLevel.H6, text);
    assertSchemaMatch(heading);
    assertXpathEvaluatesTo(text, "//ui:heading[@level=6]", heading);
    try {
        heading = new WHeading(123456, text);
        Assert.fail("Should have thrown a SystemException");
    } catch (IllegalArgumentException expected) {
        Assert.assertNotNull("Thrown exception should contain a message", expected.getMessage());
    }
}
Also used : WHeading(com.github.bordertech.wcomponents.WHeading) Test(org.junit.Test)

Example 5 with WHeading

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

the class RepeaterExampleWithStaticIDs method createUI.

/**
 * Creates the example UI.
 */
private void createUI() {
    add(new WHeading(HeadingLevel.H2, "Contacts"));
    add(repeater);
    createButtonBar();
    createAddContactSubForm();
    createPrintContactsSubForm();
}
Also used : WHeading(com.github.bordertech.wcomponents.WHeading)

Aggregations

WHeading (com.github.bordertech.wcomponents.WHeading)57 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)27 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)21 WPanel (com.github.bordertech.wcomponents.WPanel)18 WButton (com.github.bordertech.wcomponents.WButton)16 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)15 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 WText (com.github.bordertech.wcomponents.WText)10 WTextField (com.github.bordertech.wcomponents.WTextField)10 ColumnLayout (com.github.bordertech.wcomponents.layout.ColumnLayout)7 FlowLayout (com.github.bordertech.wcomponents.layout.FlowLayout)7 Margin (com.github.bordertech.wcomponents.Margin)6 WHorizontalRule (com.github.bordertech.wcomponents.WHorizontalRule)6 WMessageBox (com.github.bordertech.wcomponents.WMessageBox)4 Alignment (com.github.bordertech.wcomponents.layout.ColumnLayout.Alignment)4 ValidatingAction (com.github.bordertech.wcomponents.validation.ValidatingAction)4