use of com.github.bordertech.wcomponents.WFieldLayout in project wcomponents by BorderTech.
the class WFieldLayoutRenderer_Test method testDoPaintAllOptions.
@Test
public void testDoPaintAllOptions() throws IOException, SAXException, XpathException {
WFieldLayout layout = new WFieldLayout(WFieldLayout.LAYOUT_STACKED);
setFlag(layout, ComponentModel.HIDE_FLAG, true);
layout.setLabelWidth(10);
layout.setTitle("title1");
// Validate Schema
assertSchemaMatch(layout);
// Check Attributes
assertXpathEvaluatesTo(layout.getId(), "//ui:fieldlayout/@id", layout);
assertXpathEvaluatesTo("stacked", "//ui:fieldlayout/@layout", layout);
assertXpathEvaluatesTo("true", "//ui:fieldlayout/@hidden", layout);
assertXpathEvaluatesTo("10", "//ui:fieldlayout/@labelWidth", layout);
assertXpathEvaluatesTo("title1", "//ui:fieldlayout/@title", layout);
// Check No Fields
assertXpathNotExists("//ui:fieldlayout/ui:field", layout);
// Set Label Width - 0
layout.setLabelWidth(0);
assertXpathEvaluatesTo("", "//ui:fieldlayout/@labelWidth", layout);
// Set Label Width - 1
layout.setLabelWidth(1);
assertXpathEvaluatesTo("1", "//ui:fieldlayout/@labelWidth", layout);
// Set Label Width - 100
layout.setLabelWidth(100);
assertXpathEvaluatesTo("100", "//ui:fieldlayout/@labelWidth", layout);
// Set ordered
layout.setOrdered(true);
assertSchemaMatch(layout);
assertXpathEvaluatesTo("1", "//ui:fieldlayout/@ordered", layout);
// Set offset
layout.setOrderedOffset(20);
assertXpathEvaluatesTo("20", "//ui:fieldlayout/@ordered", layout);
}
use of com.github.bordertech.wcomponents.WFieldLayout in project wcomponents by BorderTech.
the class WFieldLayoutRenderer_Test method testXssEscaping.
@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
WFieldLayout layout = new WFieldLayout();
layout.setTitle(getMaliciousAttribute("ui:fieldlayout"));
assertSafeContent(layout);
}
use of com.github.bordertech.wcomponents.WFieldLayout in project wcomponents by BorderTech.
the class WFieldLayoutRenderer_Test method testRendererCorrectlyConfigured.
/**
* Test the Layout is correctly configured.
*/
@Test
public void testRendererCorrectlyConfigured() {
WFieldLayout layout = new WFieldLayout();
Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(layout) instanceof WFieldLayoutRenderer);
}
use of com.github.bordertech.wcomponents.WFieldLayout in project wcomponents by BorderTech.
the class WFieldLayoutRenderer_Test method testRenderedWithMargins.
@Test
public void testRenderedWithMargins() throws IOException, SAXException, XpathException {
WFieldLayout layout = new WFieldLayout();
assertXpathNotExists("//ui:fieldlayout/ui:margin", layout);
Margin margin = new Margin(0);
layout.setMargin(margin);
assertXpathNotExists("//ui:fieldlayout/ui:margin", layout);
margin = new Margin(Size.SMALL);
layout.setMargin(margin);
assertSchemaMatch(layout);
assertXpathEvaluatesTo("sm", "//ui:fieldlayout/ui:margin/@all", layout);
assertXpathEvaluatesTo("", "//ui:fieldlayout/ui:margin/@north", layout);
assertXpathEvaluatesTo("", "//ui:fieldlayout/ui:margin/@east", layout);
assertXpathEvaluatesTo("", "//ui:fieldlayout/ui:margin/@south", layout);
assertXpathEvaluatesTo("", "//ui:fieldlayout/ui:margin/@west", layout);
margin = new Margin(Size.SMALL, Size.MEDIUM, Size.LARGE, Size.XL);
layout.setMargin(margin);
assertSchemaMatch(layout);
assertXpathEvaluatesTo("", "//ui:fieldlayout/ui:margin/@all", layout);
assertXpathEvaluatesTo("sm", "//ui:fieldlayout/ui:margin/@north", layout);
assertXpathEvaluatesTo("med", "//ui:fieldlayout/ui:margin/@east", layout);
assertXpathEvaluatesTo("lg", "//ui:fieldlayout/ui:margin/@south", layout);
assertXpathEvaluatesTo("xl", "//ui:fieldlayout/ui:margin/@west", layout);
}
use of com.github.bordertech.wcomponents.WFieldLayout in project wcomponents by BorderTech.
the class AccordionExample method constructExample.
/**
* Helper to do the work of the constructor since we do not really want to call over-rideable methods in a
* constructor.
*/
private void constructExample() {
add(new WHeading(HeadingLevel.H3, "ACCORDION tabs"));
WTabSet tabset1c = new SampleWTabset(TabSetType.ACCORDION);
add(tabset1c);
/* Content height */
add(new WHeading(HeadingLevel.H2, "Examples showing content height property."));
add(new WHeading(HeadingLevel.H3, "Tall content."));
WTabSet htabset1c = new SampleWTabset(TabSetType.ACCORDION);
htabset1c.setContentHeight(TALL_CONTENT);
add(htabset1c);
add(new WHeading(HeadingLevel.H3, "Short content."));
WTabSet htabset1g = new SampleWTabset(TabSetType.ACCORDION);
htabset1g.setContentHeight(SHORT_CONTENT);
add(htabset1g);
add(new WHeading(HeadingLevel.H2, "Examples showing accordion's single property."));
WTabSet singleOpenAccordionabset = new SampleWTabset(WTabSet.TYPE_ACCORDION);
singleOpenAccordionabset.setSingle(true);
add(singleOpenAccordionabset);
add(new WHeading(HeadingLevel.H2, "Using WSubordinateControl"));
WTabSet targetTabset = new SampleWTabset(TabSetType.ACCORDION);
add(targetTabset);
WFieldLayout layout = new WFieldLayout(WFieldLayout.LAYOUT_STACKED);
add(layout);
final WCheckBox disabledControllerCb = new WCheckBox();
final WCheckBox hiddenControllerCb = new WCheckBox();
layout.addField("disable tabset", disabledControllerCb);
layout.addField("hide tabset", hiddenControllerCb);
// Build & add the subordinate
SubordinateBuilder builder = new SubordinateBuilder();
builder.condition().equals(hiddenControllerCb, String.valueOf(true));
builder.whenTrue().hide(targetTabset);
builder.whenFalse().show(targetTabset);
add(builder.build());
builder = new SubordinateBuilder();
builder.condition().equals(disabledControllerCb, String.valueOf(true));
builder.whenTrue().disable(targetTabset);
builder.whenFalse().enable(targetTabset);
add(builder.build());
}
Aggregations