Search in sources :

Example 1 with CompareType

use of com.github.bordertech.wcomponents.subordinate.AbstractCompare.CompareType in project wcomponents by BorderTech.

the class SubordinateControlOptionsExample method createCondition.

/**
 * @return the condition for the subordinate control.
 */
private Condition createCondition() {
    // Compare value
    Object value;
    switch((TriggerType) drpTriggerType.getSelected()) {
        case DateField:
            value = dateCompareValue.getValue();
            break;
        case NumberField:
            value = numberCompareValue.getValue();
            break;
        default:
            value = comboCompareValue.getValue();
            break;
    }
    // Create condition
    Condition condition;
    switch((CompareType) drpCompareType.getSelected()) {
        case EQUAL:
            condition = new Equal(trigger, value);
            break;
        case NOT_EQUAL:
            condition = new NotEqual(trigger, value);
            break;
        case LESS_THAN:
            condition = new LessThan(trigger, value);
            break;
        case LESS_THAN_OR_EQUAL:
            condition = new LessThanOrEqual(trigger, value);
            break;
        case GREATER_THAN:
            condition = new GreaterThan(trigger, value);
            break;
        case GREATER_THAN_OR_EQUAL:
            condition = new GreaterThanOrEqual(trigger, value);
            break;
        case MATCH:
            condition = new Match(trigger, (String) value);
            break;
        default:
            throw new SystemException("Compare type not valid");
    }
    return condition;
}
Also used : Condition(com.github.bordertech.wcomponents.subordinate.Condition) NotEqual(com.github.bordertech.wcomponents.subordinate.NotEqual) LessThanOrEqual(com.github.bordertech.wcomponents.subordinate.LessThanOrEqual) CompareType(com.github.bordertech.wcomponents.subordinate.AbstractCompare.CompareType) GreaterThanOrEqual(com.github.bordertech.wcomponents.subordinate.GreaterThanOrEqual) Match(com.github.bordertech.wcomponents.subordinate.Match) LessThan(com.github.bordertech.wcomponents.subordinate.LessThan) SystemException(com.github.bordertech.wcomponents.util.SystemException) 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) GreaterThan(com.github.bordertech.wcomponents.subordinate.GreaterThan)

Aggregations

CompareType (com.github.bordertech.wcomponents.subordinate.AbstractCompare.CompareType)1 Condition (com.github.bordertech.wcomponents.subordinate.Condition)1 Equal (com.github.bordertech.wcomponents.subordinate.Equal)1 GreaterThan (com.github.bordertech.wcomponents.subordinate.GreaterThan)1 GreaterThanOrEqual (com.github.bordertech.wcomponents.subordinate.GreaterThanOrEqual)1 LessThan (com.github.bordertech.wcomponents.subordinate.LessThan)1 LessThanOrEqual (com.github.bordertech.wcomponents.subordinate.LessThanOrEqual)1 Match (com.github.bordertech.wcomponents.subordinate.Match)1 NotEqual (com.github.bordertech.wcomponents.subordinate.NotEqual)1 SystemException (com.github.bordertech.wcomponents.util.SystemException)1