Search in sources :

Example 1 with AbstractCompare

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

Aggregations

AbstractCompare (com.github.bordertech.wcomponents.subordinate.AbstractCompare)1 And (com.github.bordertech.wcomponents.subordinate.And)1 Condition (com.github.bordertech.wcomponents.subordinate.Condition)1 Not (com.github.bordertech.wcomponents.subordinate.Not)1 Or (com.github.bordertech.wcomponents.subordinate.Or)1 SystemException (com.github.bordertech.wcomponents.util.SystemException)1