Search in sources :

Example 11 with WTextField

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

the class TreeUtil_Test method initTree.

@Before
public void initTree() {
    root = new WApplication();
    containerChild = new WContainer();
    simpleChild = new WTextField();
    repeatedComponent = new WText();
    repeaterChild = new WRepeater(repeatedComponent);
    grandChild = new WTextArea();
    cardManager = new WCardManager();
    card1 = new WText();
    card2 = new WText();
    root.add(containerChild);
    root.add(simpleChild);
    root.add(repeaterChild);
    root.add(cardManager);
    containerChild.add(grandChild);
    cardManager.add(card1);
    cardManager.add(card2);
    root.setLocked(true);
    setActiveContext(new UIContextImpl());
    repeaterChild.setData(Arrays.asList(new String[] { "1", "2", "3" }));
}
Also used : WTextArea(com.github.bordertech.wcomponents.WTextArea) WContainer(com.github.bordertech.wcomponents.WContainer) WApplication(com.github.bordertech.wcomponents.WApplication) WText(com.github.bordertech.wcomponents.WText) UIContextImpl(com.github.bordertech.wcomponents.UIContextImpl) WCardManager(com.github.bordertech.wcomponents.WCardManager) WTextField(com.github.bordertech.wcomponents.WTextField) WRepeater(com.github.bordertech.wcomponents.WRepeater) Before(org.junit.Before)

Example 12 with WTextField

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

the class DiagnosticImpl_Test method testGetContext.

@Test
public void testGetContext() {
    final UIContext uic = new UIContextImpl();
    DiagnosticImpl diag = new DiagnosticImpl(Diagnostic.INFO, uic, new WTextField(), "dummy");
    Assert.assertSame("Incorrect UI context", uic, diag.getContext());
}
Also used : UIContext(com.github.bordertech.wcomponents.UIContext) UIContextImpl(com.github.bordertech.wcomponents.UIContextImpl) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 13 with WTextField

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

the class WFieldErrorIndicator_Test method testIsDefaultState.

@Test
public void testIsDefaultState() {
    WPanel root = new WPanel();
    WTextField component = new WTextField();
    WFieldErrorIndicator indicator = new WFieldErrorIndicator(component);
    root.add(indicator);
    root.add(component);
    root.setLocked(true);
    setActiveContext(createUIContext());
    Assert.assertTrue("Should be in default state by default", indicator.isDefaultState());
    List<Diagnostic> diags = new ArrayList<>();
    root.validate(diags);
    root.showErrorIndicators(diags);
    Assert.assertTrue("Should be in default if there are no errors", indicator.isDefaultState());
    // Add an error by making the field mandatory
    root.reset();
    component.setMandatory(true);
    root.validate(diags);
    root.showErrorIndicators(diags);
    Assert.assertFalse("Should not be in default if there are errors", indicator.isDefaultState());
    root.reset();
    Assert.assertTrue("Should be in default after reset", indicator.isDefaultState());
}
Also used : WPanel(com.github.bordertech.wcomponents.WPanel) ArrayList(java.util.ArrayList) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 14 with WTextField

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

the class WFieldErrorIndicator_Test method testConstructor.

@Test
public void testConstructor() {
    WTextField component = new WTextField();
    WFieldErrorIndicator indicator = new WFieldErrorIndicator(component);
    Assert.assertEquals("Incorrect indicator type", AbstractWFieldIndicator.FieldIndicatorType.ERROR, indicator.getFieldIndicatorType());
    Assert.assertEquals("Incorrect releated field", component, indicator.getTargetComponent());
    Assert.assertEquals("Incorrect releated field id", component.getId(), indicator.getRelatedFieldId());
}
Also used : WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 15 with WTextField

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

the class WValidationErrors_Test method testGetGroupedErrors.

@Test
public void testGetGroupedErrors() {
    wValidationErrors.setLocked(true);
    UIContext uic = createUIContext();
    setActiveContext(uic);
    errors.clear();
    List<GroupedDiagnositcs> groupedErrors = wValidationErrors.getGroupedErrors();
    Assert.assertTrue("Should not have any groups by default", groupedErrors.isEmpty());
    WComponent component1 = new WTextField();
    WComponent component2 = new WTextField();
    Diagnostic component1Error1 = new DiagnosticImpl(Diagnostic.ERROR, component1, "Error 1");
    Diagnostic component2Error1 = new DiagnosticImpl(Diagnostic.ERROR, component2, "Error 2");
    Diagnostic component2Error2 = new DiagnosticImpl(Diagnostic.ERROR, component2, "Error 3");
    errors.add(component1Error1);
    errors.add(component2Error1);
    errors.add(component2Error2);
    wValidationErrors.setErrors(errors);
    groupedErrors = wValidationErrors.getGroupedErrors();
    Assert.assertEquals("Incorrect number of groups", 2, groupedErrors.size());
    GroupedDiagnositcs group1 = groupedErrors.get(0);
    GroupedDiagnositcs group2 = groupedErrors.get(1);
    Assert.assertEquals("Incorrect number of errors for group 1", 1, group1.getDiagnostics().size());
    Assert.assertSame("Incorrect diagnostic in group 1", component1Error1, group1.getDiagnostics().get(0));
    Assert.assertEquals("Incorrect number of errors for group 2", 2, group2.getDiagnostics().size());
    Assert.assertSame("Incorrect diagnostic in group 2", component2Error1, group2.getDiagnostics().get(0));
    Assert.assertSame("Incorrect diagnostic in group 2", component2Error2, group2.getDiagnostics().get(1));
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) UIContext(com.github.bordertech.wcomponents.UIContext) GroupedDiagnositcs(com.github.bordertech.wcomponents.validation.WValidationErrors.GroupedDiagnositcs) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Aggregations

WTextField (com.github.bordertech.wcomponents.WTextField)117 Test (org.junit.Test)90 SubordinateTarget (com.github.bordertech.wcomponents.SubordinateTarget)21 WCheckBox (com.github.bordertech.wcomponents.WCheckBox)21 WContainer (com.github.bordertech.wcomponents.WContainer)21 Equal (com.github.bordertech.wcomponents.subordinate.Equal)16 GreaterThanOrEqual (com.github.bordertech.wcomponents.subordinate.GreaterThanOrEqual)15 LessThanOrEqual (com.github.bordertech.wcomponents.subordinate.LessThanOrEqual)15 NotEqual (com.github.bordertech.wcomponents.subordinate.NotEqual)15 Rule (com.github.bordertech.wcomponents.subordinate.Rule)15 WSubordinateControl (com.github.bordertech.wcomponents.subordinate.WSubordinateControl)15 SubordinateTrigger (com.github.bordertech.wcomponents.SubordinateTrigger)14 WTextArea (com.github.bordertech.wcomponents.WTextArea)14 WComponentGroup (com.github.bordertech.wcomponents.WComponentGroup)12 WDropdown (com.github.bordertech.wcomponents.WDropdown)12 WButton (com.github.bordertech.wcomponents.WButton)11 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)11 WHeading (com.github.bordertech.wcomponents.WHeading)10 WLabel (com.github.bordertech.wcomponents.WLabel)10 Hide (com.github.bordertech.wcomponents.subordinate.Hide)10