use of com.github.bordertech.wcomponents.WFieldSet in project wcomponents by BorderTech.
the class WListOptionsExample method getListControls.
/**
* build the list controls field set.
*
* @return a field set for the controls.
*/
private WFieldSet getListControls() {
// Options Layout
WFieldSet fieldSet = new WFieldSet("List configuration");
WFieldLayout layout = new WFieldLayout();
// options.
layout.addField("Type", ddType);
layout.addField("Separator", ddSeparator);
layout.addField("Render fields", cgBeanFields);
layout.addField("Render Border", cbRenderBorder);
layout.addField("Render using field layout", cbRenderUsingFieldLayout);
layout.addField("Visible", cbVisible);
// Apply Button
WButton apply = new WButton("Apply");
apply.setAction(new com.github.bordertech.wcomponents.Action() {
@Override
public void execute(final ActionEvent event) {
applySettings();
}
});
fieldSet.add(layout);
fieldSet.add(apply);
return fieldSet;
}
use of com.github.bordertech.wcomponents.WFieldSet in project wcomponents by BorderTech.
the class AbstractSetMandatory_Test method testExecute.
@Test
public void testExecute() {
// ---------------------
// Valid Target (WInput) and TRUE Boolean Value
SubordinateTarget target1 = new MyTarget();
AbstractSetMandatory mandatory = new MyMandatory(target1, Boolean.TRUE);
// Should be mandatory
mandatory.execute();
Assert.assertTrue("Target (Mandatable) should be mandatory", ((Mandatable) target1).isMandatory());
// FALSE Boolean Value
mandatory = new MyMandatory(target1, Boolean.FALSE);
// Should not be mandatory
mandatory.execute();
Assert.assertFalse("Target (Mandatable) should not be mandatory", ((Mandatable) target1).isMandatory());
// ---------------------
// Valid Target (WField) and TRUE Boolean Value
Input textArea = new WTextArea();
WField target2 = new WFieldLayout().addField("test", textArea);
mandatory = new MyMandatory(target2, Boolean.TRUE);
// Should be mandatory
mandatory.execute();
Assert.assertTrue("Target (WField) should be mandatory", textArea.isMandatory());
// FALSE Boolean Value
mandatory = new MyMandatory(target2, Boolean.FALSE);
// Should not be mandatory
mandatory.execute();
Assert.assertFalse("Target (WField) should not be mandatory", textArea.isMandatory());
// ---------------------
// Valid Target (WFieldSet) and TRUE Boolean Value
WFieldSet target3 = new WFieldSet("Test");
mandatory = new MyMandatory(target3, Boolean.TRUE);
// Should be mandatory
mandatory.execute();
Assert.assertTrue("Target (WFieldSet) should be mandatory", target3.isMandatory());
// FALSE Boolean Value
mandatory = new MyMandatory(target3, Boolean.FALSE);
// Should not be mandatory
mandatory.execute();
Assert.assertFalse("Target (WFieldSet) should not be mandatory", target3.isMandatory());
// ---------------------
// Invalid Target (Cannot be set Mandatory) and Boolean Value
MyInvalidTarget target4 = new MyInvalidTarget();
mandatory = new MyMandatory(target4, Boolean.TRUE);
// Should do nothing
mandatory.execute();
}
use of com.github.bordertech.wcomponents.WFieldSet in project wcomponents by BorderTech.
the class WFieldSetRenderer_Test method testRenderedWithMargins.
@Test
public void testRenderedWithMargins() throws IOException, SAXException, XpathException {
WFieldSet fieldSet = new WFieldSet("");
assertXpathNotExists("//ui:fieldset/ui:margin", fieldSet);
Margin margin = new Margin(0);
fieldSet.setMargin(margin);
assertXpathNotExists("//ui:fieldset/ui:margin", fieldSet);
margin = new Margin(Size.SMALL);
fieldSet.setMargin(margin);
assertSchemaMatch(fieldSet);
assertXpathEvaluatesTo("sm", "//ui:fieldset/ui:margin/@all", fieldSet);
assertXpathEvaluatesTo("", "//ui:fieldset/ui:margin/@north", fieldSet);
assertXpathEvaluatesTo("", "//ui:fieldset/ui:margin/@east", fieldSet);
assertXpathEvaluatesTo("", "//ui:fieldset/ui:margin/@south", fieldSet);
assertXpathEvaluatesTo("", "//ui:fieldset/ui:margin/@west", fieldSet);
margin = new Margin(Size.SMALL, Size.MEDIUM, Size.LARGE, Size.XL);
fieldSet.setMargin(margin);
assertSchemaMatch(fieldSet);
assertXpathEvaluatesTo("", "//ui:fieldset/ui:margin/@all", fieldSet);
assertXpathEvaluatesTo("sm", "//ui:fieldset/ui:margin/@north", fieldSet);
assertXpathEvaluatesTo("med", "//ui:fieldset/ui:margin/@east", fieldSet);
assertXpathEvaluatesTo("lg", "//ui:fieldset/ui:margin/@south", fieldSet);
assertXpathEvaluatesTo("xl", "//ui:fieldset/ui:margin/@west", fieldSet);
}
use of com.github.bordertech.wcomponents.WFieldSet in project wcomponents by BorderTech.
the class WFieldSetRenderer_Test method testDoPaint.
@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
final String title = "WFieldSetRenderer_Test.testDoPaint.title";
WTextField text = new WTextField();
WFieldSet fieldSet = new WFieldSet(title);
fieldSet.add(text);
text.setText("text1");
assertSchemaMatch(fieldSet);
// Check Attributes
assertXpathEvaluatesTo(fieldSet.getId(), "//ui:fieldset/@id", fieldSet);
assertXpathNotExists("//ui:fieldset/@frame", fieldSet);
// Check Input
assertXpathEvaluatesTo(text.getText(), "//ui:fieldset/ui:content/ui:textfield", fieldSet);
fieldSet.setFrameType(FrameType.NO_BORDER);
assertXpathEvaluatesTo("noborder", "//ui:fieldset/@frame", fieldSet);
fieldSet.setFrameType(FrameType.NO_TEXT);
assertXpathEvaluatesTo("notext", "//ui:fieldset/@frame", fieldSet);
fieldSet.setFrameType(FrameType.NONE);
assertXpathEvaluatesTo("none", "//ui:fieldset/@frame", fieldSet);
}
use of com.github.bordertech.wcomponents.WFieldSet in project wcomponents by BorderTech.
the class WFieldSetRenderer_Test method testRendererCorrectlyConfigured.
/**
* Test the Layout is correctly configured.
*/
@Test
public void testRendererCorrectlyConfigured() {
WFieldSet fieldSet = new WFieldSet("dummy");
Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(fieldSet) instanceof WFieldSetRenderer);
}
Aggregations