Search in sources :

Example 6 with WComponentGroup

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

the class HideInGroup_Test method testActionType.

@Test
public void testActionType() {
    SubordinateTarget target = new WTextField();
    WComponentGroup<SubordinateTarget> group = new WComponentGroup<>();
    group.addToGroup(target);
    HideInGroup action = new HideInGroup(target, group);
    Assert.assertEquals("Incorrect Action Type", action.getActionType(), AbstractAction.ActionType.HIDEIN);
}
Also used : SubordinateTarget(com.github.bordertech.wcomponents.SubordinateTarget) WComponentGroup(com.github.bordertech.wcomponents.WComponentGroup) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 7 with WComponentGroup

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

the class ShowInGroup_Test method testConstructor.

@Test
public void testConstructor() {
    SubordinateTarget target = new MyTarget();
    WComponentGroup<SubordinateTarget> group = new WComponentGroup<>();
    ShowInGroup action = new ShowInGroup(target, group);
    Assert.assertEquals("Value for ShowIn should be false", Boolean.FALSE, action.getValue());
    Assert.assertEquals("Target for ShowIn should be the group", group, action.getTarget());
    Assert.assertEquals("TargetInGroup for ShowIn should be the target", target, action.getTargetInGroup());
}
Also used : SubordinateTarget(com.github.bordertech.wcomponents.SubordinateTarget) WComponentGroup(com.github.bordertech.wcomponents.WComponentGroup) Test(org.junit.Test)

Example 8 with WComponentGroup

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

the class ShowInGroup_Test method testActionType.

@Test
public void testActionType() {
    SubordinateTarget target = new WTextField();
    WComponentGroup<SubordinateTarget> group = new WComponentGroup<>();
    group.addToGroup(target);
    ShowInGroup action = new ShowInGroup(target, group);
    Assert.assertEquals("Incorrect Action Type", action.getActionType(), AbstractAction.ActionType.SHOWIN);
}
Also used : SubordinateTarget(com.github.bordertech.wcomponents.SubordinateTarget) WComponentGroup(com.github.bordertech.wcomponents.WComponentGroup) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 9 with WComponentGroup

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

the class Action_Test method testConstructor2.

@Test
public void testConstructor2() {
    SubordinateTarget target = new MyTarget();
    WComponentGroup<SubordinateTarget> group = new WComponentGroup<>();
    Action action = new Action(com.github.bordertech.wcomponents.subordinate.Action.ActionType.DISABLE, target, group);
    Assert.assertEquals("Incorrect type returned", com.github.bordertech.wcomponents.subordinate.Action.ActionType.DISABLE, action.getType());
    Assert.assertEquals("Incorrect target returned", target, action.getTarget());
    Assert.assertEquals("Incorrect group returned", group, action.getGroup());
}
Also used : SubordinateTarget(com.github.bordertech.wcomponents.SubordinateTarget) WComponentGroup(com.github.bordertech.wcomponents.WComponentGroup) Test(org.junit.Test)

Example 10 with WComponentGroup

use of com.github.bordertech.wcomponents.WComponentGroup 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)

Aggregations

WComponentGroup (com.github.bordertech.wcomponents.WComponentGroup)34 SubordinateTarget (com.github.bordertech.wcomponents.SubordinateTarget)30 Test (org.junit.Test)30 WCheckBox (com.github.bordertech.wcomponents.WCheckBox)12 WTextField (com.github.bordertech.wcomponents.WTextField)12 WContainer (com.github.bordertech.wcomponents.WContainer)10 Equal (com.github.bordertech.wcomponents.subordinate.Equal)9 Rule (com.github.bordertech.wcomponents.subordinate.Rule)9 WSubordinateControl (com.github.bordertech.wcomponents.subordinate.WSubordinateControl)9 GreaterThanOrEqual (com.github.bordertech.wcomponents.subordinate.GreaterThanOrEqual)7 LessThanOrEqual (com.github.bordertech.wcomponents.subordinate.LessThanOrEqual)7 NotEqual (com.github.bordertech.wcomponents.subordinate.NotEqual)7 SubordinateTrigger (com.github.bordertech.wcomponents.SubordinateTrigger)6 WLabel (com.github.bordertech.wcomponents.WLabel)5 Hide (com.github.bordertech.wcomponents.subordinate.Hide)4 WButton (com.github.bordertech.wcomponents.WButton)3 Show (com.github.bordertech.wcomponents.subordinate.Show)3 WComponent (com.github.bordertech.wcomponents.WComponent)2 WHorizontalRule (com.github.bordertech.wcomponents.WHorizontalRule)2 Disable (com.github.bordertech.wcomponents.subordinate.Disable)2