Search in sources :

Example 66 with WLabel

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());
}
Also used : WLabel(com.github.bordertech.wcomponents.WLabel) Test(org.junit.Test)

Example 67 with WLabel

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());
}
Also used : SubordinateTarget(com.github.bordertech.wcomponents.SubordinateTarget) WComponentGroup(com.github.bordertech.wcomponents.WComponentGroup) WLabel(com.github.bordertech.wcomponents.WLabel) Test(org.junit.Test)

Example 68 with WLabel

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());
}
Also used : WLabel(com.github.bordertech.wcomponents.WLabel) Test(org.junit.Test)

Example 69 with WLabel

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());
}
Also used : SubordinateTarget(com.github.bordertech.wcomponents.SubordinateTarget) WComponentGroup(com.github.bordertech.wcomponents.WComponentGroup) WLabel(com.github.bordertech.wcomponents.WLabel) Test(org.junit.Test)

Example 70 with WLabel

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");
}
Also used : WField(com.github.bordertech.wcomponents.WField) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder) WLabel(com.github.bordertech.wcomponents.WLabel)

Aggregations

WLabel (com.github.bordertech.wcomponents.WLabel)99 Test (org.junit.Test)57 WHeading (com.github.bordertech.wcomponents.WHeading)13 WTextField (com.github.bordertech.wcomponents.WTextField)10 WButton (com.github.bordertech.wcomponents.WButton)9 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)9 WComponent (com.github.bordertech.wcomponents.WComponent)8 WRadioButtonSelect (com.github.bordertech.wcomponents.WRadioButtonSelect)8 WPanel (com.github.bordertech.wcomponents.WPanel)7 UIContext (com.github.bordertech.wcomponents.UIContext)6 WCheckBoxSelect (com.github.bordertech.wcomponents.WCheckBoxSelect)6 SubordinateTarget (com.github.bordertech.wcomponents.SubordinateTarget)5 UIContextImpl (com.github.bordertech.wcomponents.UIContextImpl)5 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)5 WComponentGroup (com.github.bordertech.wcomponents.WComponentGroup)5 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)5 Action (com.github.bordertech.wcomponents.Action)4 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)4 WApplication (com.github.bordertech.wcomponents.WApplication)4 WContainer (com.github.bordertech.wcomponents.WContainer)4