Search in sources :

Example 1 with Not

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);
    }
}
Also used : Condition(com.github.bordertech.wcomponents.subordinate.Condition) AbstractCompare(com.github.bordertech.wcomponents.subordinate.AbstractCompare) Not(com.github.bordertech.wcomponents.subordinate.Not) Or(com.github.bordertech.wcomponents.subordinate.Or) SystemException(com.github.bordertech.wcomponents.util.SystemException) And(com.github.bordertech.wcomponents.subordinate.And)

Example 2 with Not

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);
}
Also used : Hide(com.github.bordertech.wcomponents.subordinate.Hide) Condition(com.github.bordertech.wcomponents.subordinate.Condition) Optional(com.github.bordertech.wcomponents.subordinate.Optional) HideInGroup(com.github.bordertech.wcomponents.subordinate.HideInGroup) WSubordinateControl(com.github.bordertech.wcomponents.subordinate.WSubordinateControl) EnableInGroup(com.github.bordertech.wcomponents.subordinate.EnableInGroup) ShowInGroup(com.github.bordertech.wcomponents.subordinate.ShowInGroup) SubordinateTarget(com.github.bordertech.wcomponents.SubordinateTarget) Not(com.github.bordertech.wcomponents.subordinate.Not) SystemException(com.github.bordertech.wcomponents.util.SystemException) WText(com.github.bordertech.wcomponents.WText) Equal(com.github.bordertech.wcomponents.subordinate.Equal) NotEqual(com.github.bordertech.wcomponents.subordinate.NotEqual) LessThanOrEqual(com.github.bordertech.wcomponents.subordinate.LessThanOrEqual) GreaterThanOrEqual(com.github.bordertech.wcomponents.subordinate.GreaterThanOrEqual) Enable(com.github.bordertech.wcomponents.subordinate.Enable) Show(com.github.bordertech.wcomponents.subordinate.Show) DisableInGroup(com.github.bordertech.wcomponents.subordinate.DisableInGroup) Rule(com.github.bordertech.wcomponents.subordinate.Rule) WHorizontalRule(com.github.bordertech.wcomponents.WHorizontalRule) Disable(com.github.bordertech.wcomponents.subordinate.Disable) Mandatory(com.github.bordertech.wcomponents.subordinate.Mandatory)

Example 3 with Not

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());
}
Also used : Not(com.github.bordertech.wcomponents.subordinate.Not) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Aggregations

Not (com.github.bordertech.wcomponents.subordinate.Not)3 Condition (com.github.bordertech.wcomponents.subordinate.Condition)2 SystemException (com.github.bordertech.wcomponents.util.SystemException)2 SubordinateTarget (com.github.bordertech.wcomponents.SubordinateTarget)1 WHorizontalRule (com.github.bordertech.wcomponents.WHorizontalRule)1 WText (com.github.bordertech.wcomponents.WText)1 WTextField (com.github.bordertech.wcomponents.WTextField)1 AbstractCompare (com.github.bordertech.wcomponents.subordinate.AbstractCompare)1 And (com.github.bordertech.wcomponents.subordinate.And)1 Disable (com.github.bordertech.wcomponents.subordinate.Disable)1 DisableInGroup (com.github.bordertech.wcomponents.subordinate.DisableInGroup)1 Enable (com.github.bordertech.wcomponents.subordinate.Enable)1 EnableInGroup (com.github.bordertech.wcomponents.subordinate.EnableInGroup)1 Equal (com.github.bordertech.wcomponents.subordinate.Equal)1 GreaterThanOrEqual (com.github.bordertech.wcomponents.subordinate.GreaterThanOrEqual)1 Hide (com.github.bordertech.wcomponents.subordinate.Hide)1 HideInGroup (com.github.bordertech.wcomponents.subordinate.HideInGroup)1 LessThanOrEqual (com.github.bordertech.wcomponents.subordinate.LessThanOrEqual)1 Mandatory (com.github.bordertech.wcomponents.subordinate.Mandatory)1 NotEqual (com.github.bordertech.wcomponents.subordinate.NotEqual)1