@Test public void testDisableIn() { 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"); // DisableIn Action builder.whenTrue().disableIn(input2, group); setActiveContext(createUIContext()); // Set initial states (opposite to end state) input1.setDisabled(true); input2.setDisabled(false); input3.setDisabled(true); Assert.assertTrue("disableIn - Input1 Component should be disabled", input1.isDisabled()); Assert.assertFalse("disableIn - Input2 Component should be enabled", input2.isDisabled()); Assert.assertTrue("disableIn - Input3 Component should be disabled", input3.isDisabled()); builder.build().applyTheControls(); Assert.assertFalse("disableIn - Input1 Component should be enabled", input1.isDisabled()); Assert.assertTrue("disableIn - Input2 Component should be disabled", input2.isDisabled()); Assert.assertFalse("disableIn - Input3 Component should be enabled", input3.isDisabled()); }
@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()); }
/** * Set the audio configuration options. */ private void setupAudio() { audio.setAutoplay(cbAutoPlay.isSelected()); audio.setLoop(!cbLoop.isDisabled() && cbLoop.isSelected()); audio.setControls(cbControls.isSelected() ? WAudio.Controls.PLAY_PAUSE : WAudio.Controls.NATIVE); audio.setDisabled(cbControls.isSelected() && cbDisable.isSelected()); } }
@Test public void testEnableIn() { 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"); // EnableIn Action builder.whenTrue().enableIn(input2, group); setActiveContext(createUIContext()); // Set initial states (opposite to end state) input1.setDisabled(false); input2.setDisabled(true); input3.setDisabled(false); Assert.assertFalse("enableIn - Input1 Component should be enabled", input1.isDisabled()); Assert.assertTrue("enableIn - Input2 Component should be disabled", input2.isDisabled()); Assert.assertFalse("enableIn - Input3 Component should be enabled", input3.isDisabled()); builder.build().applyTheControls(); Assert.assertTrue("enableIn - Input1 Component should be disabled", input1.isDisabled()); Assert.assertFalse("enableIn - Input2 Component should be enabled", input2.isDisabled()); Assert.assertTrue("enableIn - Input3 Component should be disabled", input3.isDisabled()); }
@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()); }
/** * Set the video configuration options. */ private void setupVideo() { video.setAutoplay(cbAutoPlay.isSelected()); video.setLoop(cbLoop.isSelected()); video.setMuted(!cbMute.isDisabled() && cbMute.isSelected()); video.setControls(cbControls.isSelected() ? WVideo.Controls.PLAY_PAUSE : WVideo.Controls.NATIVE); video.setDisabled(cbControls.isSelected() && cbDisable.isSelected()); } }
String groupName = group == null ? null : group.getId(); xml.appendOptionalAttribute("groupName", groupName); xml.appendOptionalAttribute("disabled", checkBox.isDisabled(), "true"); xml.appendOptionalAttribute("required", checkBox.isMandatory(), "true"); xml.appendOptionalAttribute("submitOnChange", checkBox.isSubmitOnChange(), "true");