use of com.github.bordertech.wcomponents.subordinate.Not in project wcomponents by BorderTech.
the class WSubordinateControlRenderer method paintCondition.
/**
* Paints a condition.
*
* @param condition the condition to paint.
* @param xml the writer to send the output to
*/
private void paintCondition(final Condition condition, final XmlStringBuilder xml) {
if (condition instanceof And) {
xml.appendTag("ui:and");
for (Condition operand : ((And) condition).getConditions()) {
paintCondition(operand, xml);
}
xml.appendEndTag("ui:and");
} else if (condition instanceof Or) {
xml.appendTag("ui:or");
for (Condition operand : ((Or) condition).getConditions()) {
paintCondition(operand, xml);
}
xml.appendEndTag("ui:or");
} else if (condition instanceof Not) {
xml.appendTag("ui:not");
paintCondition(((Not) condition).getCondition(), xml);
xml.appendEndTag("ui:not");
} else if (condition instanceof AbstractCompare) {
AbstractCompare compare = (AbstractCompare) condition;
xml.appendTagOpen("ui:condition");
xml.appendAttribute("controller", compare.getTrigger().getId());
xml.appendAttribute("value", compare.getComparePaintValue());
xml.appendOptionalAttribute("operator", getCompareTypeName(compare.getCompareType()));
xml.appendEnd();
} else {
throw new SystemException("Unknown condition: " + condition);
}
}
use of com.github.bordertech.wcomponents.subordinate.Not in project wcomponents by BorderTech.
the class SubordinateControlOptionsExample method buildControl.
/**
* Build the subordinate control.
*/
private void buildControl() {
buildControlPanel.reset();
buildTargetPanel.reset();
// Setup Trigger
setupTrigger();
// Create target
SubordinateTarget target = setupTarget();
// Create Actions
com.github.bordertech.wcomponents.subordinate.Action trueAction;
com.github.bordertech.wcomponents.subordinate.Action falseAction;
switch((ControlActionType) drpActionType.getSelected()) {
case ENABLE_DISABLE:
trueAction = new Enable(target);
falseAction = new Disable(target);
break;
case SHOW_HIDE:
trueAction = new Show(target);
falseAction = new Hide(target);
break;
case MAN_OPT:
trueAction = new Mandatory(target);
falseAction = new Optional(target);
break;
case SHOWIN_HIDEIN:
trueAction = new ShowInGroup(target, targetGroup);
falseAction = new HideInGroup(target, targetGroup);
break;
case ENABLEIN_DISABLEIN:
trueAction = new EnableInGroup(target, targetGroup);
falseAction = new DisableInGroup(target, targetGroup);
break;
default:
throw new SystemException("ControlAction type not valid");
}
// Create Condition
Condition condition = createCondition();
if (cbNot.isSelected()) {
condition = new Not(condition);
}
// Create Rule
Rule rule = new Rule(condition, trueAction, falseAction);
// Create Subordinate
WSubordinateControl control = new WSubordinateControl();
control.addRule(rule);
buildControlPanel.add(control);
if (targetCollapsible.getDecoratedLabel() != null) {
targetCollapsible.getDecoratedLabel().setTail(new WText(control.toString()));
}
control = new WSubordinateControl();
rule = new Rule(new Equal(cbClientDisableTrigger, true), new Disable((SubordinateTarget) trigger), new Enable((SubordinateTarget) trigger));
control.addRule(rule);
buildControlPanel.add(control);
}
use of com.github.bordertech.wcomponents.subordinate.Not in project wcomponents by BorderTech.
the class GroupExpression_Test method testBuildNot.
@Test
public void testBuildNot() {
GroupExpression expr = new GroupExpression(GroupExpression.Type.NOT);
BooleanExpression operand1 = new CompareExpression(CompareType.EQUAL, new WTextField(), "1");
expr.add(operand1);
Not condition = (Not) expr.build();
Assert.assertEquals("Incorrect 1st operand for NOT", operand1.build().toString(), condition.getCondition().toString());
}
Aggregations