use of com.github.bordertech.wcomponents.WLabel in project wcomponents by BorderTech.
the class Optional_Test method testToString.
@Test
public void testToString() {
MyTarget target = new MyTarget();
Optional action = new Optional(target);
Assert.assertEquals("Incorrect toString for action", "set MyTarget optional", action.toString());
WLabel label = new WLabel("test label", target);
Assert.assertEquals("Incorrect toString for action with a label", "set " + label.getText() + " optional", action.toString());
}
use of com.github.bordertech.wcomponents.WLabel in project wcomponents by BorderTech.
the class ShowInGroup_Test method testToString.
@Test
public void testToString() {
SubordinateTarget target1 = new MyTarget();
SubordinateTarget target2 = new MyTarget();
SubordinateTarget target3 = new MyTarget();
WComponentGroup<SubordinateTarget> group = new WComponentGroup<>();
group.addToGroup(target1);
group.addToGroup(target2);
group.addToGroup(target3);
ShowInGroup action = new ShowInGroup(target2, group);
Assert.assertEquals("Incorrect toString for action", "show MyTarget in WComponentGroup([MyTarget, MyTarget, MyTarget])", action.toString());
new WLabel("test label", target2);
Assert.assertEquals("Incorrect toString for action with a label", "show test label in WComponentGroup([MyTarget, MyTarget, MyTarget])", action.toString());
}
use of com.github.bordertech.wcomponents.WLabel in project wcomponents by BorderTech.
the class Show_Test method testToString.
@Test
public void testToString() {
MyTarget target = new MyTarget();
Show action = new Show(target);
Assert.assertEquals("Incorrect toString for action", "show MyTarget", action.toString());
WLabel label = new WLabel("test label", target);
Assert.assertEquals("Incorrect toString for action with a label", "show " + label.getText(), action.toString());
}
use of com.github.bordertech.wcomponents.WLabel in project wcomponents by BorderTech.
the class Action_Test method testToString.
/**
* Since the string representation is relied upon by other tests, it's worth testing specifically.
*/
@Test
public void testToString() {
SubordinateTarget target = new MyTarget();
Action action = new Action(com.github.bordertech.wcomponents.subordinate.Action.ActionType.DISABLE, target);
Assert.assertEquals("Incorrect toString for disable action", "disable MyTarget", action.toString());
action = new Action(com.github.bordertech.wcomponents.subordinate.Action.ActionType.ENABLE, target);
Assert.assertEquals("Incorrect toString for enable action", "enable MyTarget", action.toString());
action = new Action(com.github.bordertech.wcomponents.subordinate.Action.ActionType.HIDE, target);
Assert.assertEquals("Incorrect toString for hide action", "hide MyTarget", action.toString());
action = new Action(com.github.bordertech.wcomponents.subordinate.Action.ActionType.MANDATORY, target);
Assert.assertEquals("Incorrect toString for set mandatory action", "set MyTarget mandatory", action.toString());
action = new Action(com.github.bordertech.wcomponents.subordinate.Action.ActionType.OPTIONAL, target);
Assert.assertEquals("Incorrect toString for set optional action", "set MyTarget optional", action.toString());
action = new Action(com.github.bordertech.wcomponents.subordinate.Action.ActionType.SHOW, target);
Assert.assertEquals("Incorrect toString for show action", "show MyTarget", action.toString());
action = new Action(com.github.bordertech.wcomponents.subordinate.Action.ActionType.SHOWIN, target, new WComponentGroup<SubordinateTarget>());
Assert.assertEquals("Incorrect toString for showIn action", "show MyTarget in WComponentGroup([])", action.toString());
action = new Action(com.github.bordertech.wcomponents.subordinate.Action.ActionType.HIDEIN, target, new WComponentGroup<SubordinateTarget>());
Assert.assertEquals("Incorrect toString for hideIn action", "hide MyTarget in WComponentGroup([])", action.toString());
action = new Action(com.github.bordertech.wcomponents.subordinate.Action.ActionType.ENABLEIN, target, new WComponentGroup<SubordinateTarget>());
Assert.assertEquals("Incorrect toString for enableIn action", "enable MyTarget in WComponentGroup([])", action.toString());
action = new Action(com.github.bordertech.wcomponents.subordinate.Action.ActionType.DISABLEIN, target, new WComponentGroup<SubordinateTarget>());
Assert.assertEquals("Incorrect toString for disableIn action", "disable MyTarget in WComponentGroup([])", action.toString());
// Test when a label is associated with the field
action = new Action(com.github.bordertech.wcomponents.subordinate.Action.ActionType.SHOW, target);
new WLabel("My test field", target);
Assert.assertEquals("Incorrect toString for show action with label", "show My test field", action.toString());
}
use of com.github.bordertech.wcomponents.WLabel in project wcomponents by BorderTech.
the class WFieldRenderer method doRender.
/**
* Paints the given WField.
*
* @param component the WField to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WField field = (WField) component;
XmlStringBuilder xml = renderContext.getWriter();
int inputWidth = field.getInputWidth();
xml.appendTagOpen("ui:field");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", field.isHidden(), "true");
xml.appendOptionalAttribute("inputWidth", inputWidth > 0, inputWidth);
xml.appendClose();
// Label
WLabel label = field.getLabel();
if (label != null) {
label.paint(renderContext);
}
// Field
if (field.getField() != null) {
xml.appendTag("ui:input");
field.getField().paint(renderContext);
if (field.getErrorIndicator() != null) {
field.getErrorIndicator().paint(renderContext);
}
if (field.getWarningIndicator() != null) {
field.getWarningIndicator().paint(renderContext);
}
xml.appendEndTag("ui:input");
}
xml.appendEndTag("ui:field");
}
Aggregations