Search in sources :

Example 1 with WTabSet

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

the class WTabSetRenderer method doRender.

/**
 * Paints the given WTabSet.
 *
 * @param component the WTabSet to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WTabSet tabSet = (WTabSet) component;
    XmlStringBuilder xml = renderContext.getWriter();
    xml.appendTagOpen("ui:tabset");
    xml.appendAttribute("id", component.getId());
    xml.appendOptionalAttribute("class", component.getHtmlClass());
    xml.appendOptionalAttribute("track", component.isTracking(), "true");
    xml.appendAttribute("type", getTypeAsString(tabSet.getType()));
    xml.appendOptionalAttribute("disabled", tabSet.isDisabled(), "true");
    xml.appendOptionalAttribute("hidden", tabSet.isHidden(), "true");
    xml.appendOptionalAttribute("contentHeight", tabSet.getContentHeight());
    xml.appendOptionalAttribute("showHeadOnly", tabSet.isShowHeadOnly(), "true");
    xml.appendOptionalAttribute("single", TabSetType.ACCORDION.equals(tabSet.getType()) && tabSet.isSingle(), "true");
    if (WTabSet.TabSetType.ACCORDION.equals(tabSet.getType())) {
        xml.appendOptionalAttribute("groupName", tabSet.getGroupName());
    }
    xml.appendClose();
    // Render margin
    MarginRendererUtil.renderMargin(tabSet, renderContext);
    paintChildren(tabSet, renderContext);
    xml.appendEndTag("ui:tabset");
}
Also used : XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder) WTabSet(com.github.bordertech.wcomponents.WTabSet)

Example 2 with WTabSet

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

the class WTabGroupRenderer_Test method wrapTabGroup.

/**
 * Tabs can not be used stand-alone, so we must test them through a WTabSet.
 *
 * @param tabGroup the tab group to wrap
 *
 * @return wrapped tab group
 */
private WComponent wrapTabGroup(final WTabGroup tabGroup) {
    WTabSet tabSet = new WTabSet();
    tabSet.add(tabGroup);
    return tabSet;
}
Also used : WTabSet(com.github.bordertech.wcomponents.WTabSet)

Example 3 with WTabSet

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

the class WTabRenderer_Test method testXssEscaping.

@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
    WTabSet tabSet = new WTabSet();
    WTab tab = tabSet.addTab(new WText("dummy"), getMaliciousContent(), TabMode.CLIENT);
    assertSafeContent(tabSet);
    tab.setToolTip(getMaliciousAttribute("ui:tab"));
    assertSafeContent(tabSet);
    tab.setAccessibleText(getMaliciousAttribute("ui:tab"));
    assertSafeContent(tabSet);
}
Also used : WText(com.github.bordertech.wcomponents.WText) WTab(com.github.bordertech.wcomponents.WTab) WTabSet(com.github.bordertech.wcomponents.WTabSet) Test(org.junit.Test)

Example 4 with WTabSet

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

the class WTabSetRenderer_Test method testSingleAccordian.

@Test
public void testSingleAccordian() throws IOException, SAXException, XpathException {
    WTabSet tabSet = new WTabSet(WTabSet.TabSetType.ACCORDION);
    tabSet.addTab(new WText("1"), "1", TabMode.CLIENT);
    // Default should be single is false (ie not rendered)
    assertSchemaMatch(tabSet);
    assertXpathEvaluatesTo("", "//ui:tabset/@single", tabSet);
    // Default should be single is false (ie not rendered)
    tabSet.setSingle(true);
    assertSchemaMatch(tabSet);
    assertXpathEvaluatesTo("true", "//ui:tabset/@single", tabSet);
}
Also used : WText(com.github.bordertech.wcomponents.WText) WTabSet(com.github.bordertech.wcomponents.WTabSet) Test(org.junit.Test)

Example 5 with WTabSet

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

the class WTabSetRenderer_Test method testRenderedWithMargins.

@Test
public void testRenderedWithMargins() throws IOException, SAXException, XpathException {
    WTabSet tabSet = new WTabSet();
    tabSet.addTab(new WText("1"), "1", TabMode.CLIENT);
    assertXpathNotExists("//ui:tabset/ui:margin", tabSet);
    Margin margin = new Margin(0);
    tabSet.setMargin(margin);
    assertXpathNotExists("//ui:tabset/ui:margin", tabSet);
    margin = new Margin(Size.SMALL);
    tabSet.setMargin(margin);
    assertSchemaMatch(tabSet);
    assertXpathEvaluatesTo("sm", "//ui:tabset/ui:margin/@all", tabSet);
    assertXpathEvaluatesTo("", "//ui:tabset/ui:margin/@north", tabSet);
    assertXpathEvaluatesTo("", "//ui:tabset/ui:margin/@east", tabSet);
    assertXpathEvaluatesTo("", "//ui:tabset/ui:margin/@south", tabSet);
    assertXpathEvaluatesTo("", "//ui:tabset/ui:margin/@west", tabSet);
}
Also used : WText(com.github.bordertech.wcomponents.WText) WTabSet(com.github.bordertech.wcomponents.WTabSet) Margin(com.github.bordertech.wcomponents.Margin) Test(org.junit.Test)

Aggregations

WTabSet (com.github.bordertech.wcomponents.WTabSet)11 WText (com.github.bordertech.wcomponents.WText)7 Test (org.junit.Test)7 WTab (com.github.bordertech.wcomponents.WTab)3 WCheckBox (com.github.bordertech.wcomponents.WCheckBox)2 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)2 WHeading (com.github.bordertech.wcomponents.WHeading)2 SubordinateBuilder (com.github.bordertech.wcomponents.subordinate.builder.SubordinateBuilder)2 Margin (com.github.bordertech.wcomponents.Margin)1 WDecoratedLabel (com.github.bordertech.wcomponents.WDecoratedLabel)1 WHorizontalRule (com.github.bordertech.wcomponents.WHorizontalRule)1 WImage (com.github.bordertech.wcomponents.WImage)1 WPanel (com.github.bordertech.wcomponents.WPanel)1 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)1 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)1 FlowLayout (com.github.bordertech.wcomponents.layout.FlowLayout)1