Search in sources :

Example 1 with Subscription

use of com.haulmont.bali.events.Subscription in project cuba by cuba-platform.

the class FilterDelegateImpl method addConditionListener.

protected void addConditionListener(AbstractCondition condition, Subscription current) {
    if (conditionListeners == null) {
        conditionListeners = new HashMap<>();
    }
    AbstractCondition.Listener listener = new AbstractCondition.Listener() {

        protected Subscription previous = current;

        @Override
        public void captionChanged() {
        // do nothing
        }

        @Override
        public void paramChanged(Param oldParam, Param newParam) {
            previous.remove();
            paramValueChangeSubscriptions.remove(previous);
            Subscription newSubscription = newParam.addParamValueChangeListener(event -> applyWithImmediateMode());
            paramValueChangeSubscriptions.add(newSubscription);
            previous = newSubscription;
            applyWithImmediateMode();
        }
    };
    condition.addListener(listener);
    conditionListeners.put(condition, listener);
}
Also used : Subscription(com.haulmont.bali.events.Subscription)

Example 2 with Subscription

use of com.haulmont.bali.events.Subscription in project cuba by cuba-platform.

the class FilterDelegateImpl method subscribeToParamValueChangeEventRecursively.

protected void subscribeToParamValueChangeEventRecursively(List<Node<AbstractCondition>> conditions) {
    if (paramValueChangeSubscriptions == null) {
        paramValueChangeSubscriptions = new ArrayList<>();
    }
    for (Node<AbstractCondition> node : conditions) {
        AbstractCondition condition = node.getData();
        if (condition.isGroup()) {
            subscribeToParamValueChangeEventRecursively(node.getChildren());
        } else {
            Subscription subscription = condition.getParam().addParamValueChangeListener(event -> applyWithImmediateMode());
            paramValueChangeSubscriptions.add(subscription);
            addConditionListener(condition, subscription);
        }
    }
}
Also used : Subscription(com.haulmont.bali.events.Subscription)

Aggregations

Subscription (com.haulmont.bali.events.Subscription)2