Search in sources :

Example 6 with WCheckBox

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

the class SubordinateBuilder_Test method testHideIn.

@Test
public void testHideIn() {
    SubordinateBuilder builder = new SubordinateBuilder();
    WCheckBox input1 = new WCheckBox();
    WCheckBox input2 = new WCheckBox();
    WCheckBox input3 = new WCheckBox();
    WComponentGroup<SubordinateTarget> group = new WComponentGroup<>();
    group.addToGroup(input1);
    group.addToGroup(input2);
    group.addToGroup(input3);
    // True Condition
    builder.condition().equals(new WCheckBox(), "false");
    // HideIn Action
    builder.whenTrue().hideIn(input2, group);
    setActiveContext(createUIContext());
    // Set initial states (opposite to end state)
    setFlag(input1, ComponentModel.HIDE_FLAG, true);
    setFlag(input2, ComponentModel.HIDE_FLAG, false);
    setFlag(input3, ComponentModel.HIDE_FLAG, true);
    Assert.assertTrue("hideIn - Input1 Component should be hidden", input1.isHidden());
    Assert.assertFalse("hideIn - Input2 Component should not be hidden", input2.isHidden());
    Assert.assertTrue("hideIn - Input3 Component should be hidden", input3.isHidden());
    builder.build().applyTheControls();
    Assert.assertFalse("hideIn - Input1 Component should not be hidden", input1.isHidden());
    Assert.assertTrue("hideIn - Input2 Component should be hidden", input2.isHidden());
    Assert.assertFalse("hideIn - Input3 Component should not be hidden", input3.isHidden());
}
Also used : SubordinateTarget(com.github.bordertech.wcomponents.SubordinateTarget) WComponentGroup(com.github.bordertech.wcomponents.WComponentGroup) WCheckBox(com.github.bordertech.wcomponents.WCheckBox) Test(org.junit.Test)

Example 7 with WCheckBox

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

the class SubordinateBuilder_Test method testHide.

@Test
public void testHide() {
    SubordinateBuilder builder = new SubordinateBuilder();
    WCheckBox input = new WCheckBox();
    builder.condition().equals(input, "false");
    builder.whenTrue().hide(input);
    setActiveContext(createUIContext());
    Assert.assertFalse("Component should be initially visible", input.isHidden());
    builder.build().applyTheControls();
    Assert.assertTrue("Component should be hidden", input.isHidden());
}
Also used : WCheckBox(com.github.bordertech.wcomponents.WCheckBox) Test(org.junit.Test)

Example 8 with WCheckBox

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

the class SubordinateBuilder_Test method testShow.

@Test
public void testShow() {
    SubordinateBuilder builder = new SubordinateBuilder();
    WCheckBox input = new WCheckBox();
    builder.condition().equals(input, "false");
    builder.whenTrue().show(input);
    setActiveContext(createUIContext());
    setFlag(input, ComponentModel.HIDE_FLAG, true);
    Assert.assertTrue("Component should be initially hidden", input.isHidden());
    builder.build().applyTheControls();
    Assert.assertFalse("Component should be visible", input.isHidden());
}
Also used : WCheckBox(com.github.bordertech.wcomponents.WCheckBox) Test(org.junit.Test)

Example 9 with WCheckBox

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

the class SubordinateBuilder_Test method testEnable.

@Test
public void testEnable() {
    SubordinateBuilder builder = new SubordinateBuilder();
    WCheckBox input = new WCheckBox();
    builder.condition().equals(input, "false");
    builder.whenTrue().disable(input);
    setActiveContext(createUIContext());
    Assert.assertFalse("Component should be initially enabled", input.isDisabled());
    builder.build().applyTheControls();
    Assert.assertTrue("Component should be disabled", input.isDisabled());
}
Also used : WCheckBox(com.github.bordertech.wcomponents.WCheckBox) Test(org.junit.Test)

Example 10 with WCheckBox

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

the class SubordinateBuilder_Test method testDisable.

@Test
public void testDisable() {
    SubordinateBuilder builder = new SubordinateBuilder();
    WCheckBox input = new WCheckBox();
    builder.condition().equals(input, "false");
    builder.whenTrue().disable(input);
    setActiveContext(createUIContext());
    Assert.assertFalse("Component should be initially enabled", input.isDisabled());
    builder.build().applyTheControls();
    Assert.assertTrue("Component should be disabled", input.isDisabled());
}
Also used : WCheckBox(com.github.bordertech.wcomponents.WCheckBox) Test(org.junit.Test)

Aggregations

WCheckBox (com.github.bordertech.wcomponents.WCheckBox)42 Test (org.junit.Test)35 WTextField (com.github.bordertech.wcomponents.WTextField)21 SubordinateTarget (com.github.bordertech.wcomponents.SubordinateTarget)18 WContainer (com.github.bordertech.wcomponents.WContainer)17 Equal (com.github.bordertech.wcomponents.subordinate.Equal)13 Rule (com.github.bordertech.wcomponents.subordinate.Rule)13 WSubordinateControl (com.github.bordertech.wcomponents.subordinate.WSubordinateControl)13 WComponentGroup (com.github.bordertech.wcomponents.WComponentGroup)12 GreaterThanOrEqual (com.github.bordertech.wcomponents.subordinate.GreaterThanOrEqual)11 LessThanOrEqual (com.github.bordertech.wcomponents.subordinate.LessThanOrEqual)11 NotEqual (com.github.bordertech.wcomponents.subordinate.NotEqual)11 SubordinateTrigger (com.github.bordertech.wcomponents.SubordinateTrigger)10 Hide (com.github.bordertech.wcomponents.subordinate.Hide)7 Show (com.github.bordertech.wcomponents.subordinate.Show)7 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)5 WHeading (com.github.bordertech.wcomponents.WHeading)3 WLabel (com.github.bordertech.wcomponents.WLabel)3 Condition (com.github.bordertech.wcomponents.subordinate.Condition)3 MockRequest (com.github.bordertech.wcomponents.util.mock.MockRequest)3