Search in sources :

Example 1 with CustomConditionCreator

use of com.haulmont.cuba.gui.components.filter.descriptor.CustomConditionCreator in project cuba by cuba-platform.

the class AddConditionHelper method _addCondition.

protected void _addCondition(AbstractConditionDescriptor descriptor, ConditionsTree conditionsTree) {
    final AbstractCondition condition = descriptor.createCondition();
    if (descriptor instanceof CustomConditionCreator) {
        WindowInfo windowInfo = windowConfig.getWindowInfo("customConditionEditor");
        Map<String, Object> params = new HashMap<>();
        params.put("condition", condition);
        params.put("conditionsTree", conditionsTree);
        params.put("filter", filter);
        final CustomConditionEditor window = (CustomConditionEditor) windowManager.openWindow(windowInfo, OpenType.DIALOG, params);
        window.addCloseListener(actionId -> {
            if (Window.COMMIT_ACTION_ID.equals(actionId)) {
                handler.handle(condition);
            }
        });
    } else if (descriptor instanceof DynamicAttributesConditionCreator) {
        WindowInfo windowInfo = windowConfig.getWindowInfo("dynamicAttributesConditionEditor");
        Map<String, Object> params = new HashMap<>();
        params.put("condition", condition);
        params.put("filter", filter);
        DynamicAttributesConditionEditor window = (DynamicAttributesConditionEditor) windowManager.openWindow(windowInfo, OpenType.DIALOG, params);
        window.addCloseListener(actionId -> {
            if (Window.COMMIT_ACTION_ID.equals(actionId)) {
                handler.handle(condition);
            }
        });
    } else {
        handler.handle(condition);
    }
}
Also used : CustomConditionCreator(com.haulmont.cuba.gui.components.filter.descriptor.CustomConditionCreator) WindowManager(com.haulmont.cuba.gui.WindowManager) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) Collection(java.util.Collection) AddConditionWindow(com.haulmont.cuba.gui.components.filter.addcondition.AddConditionWindow) HashMap(java.util.HashMap) AbstractCondition(com.haulmont.cuba.gui.components.filter.condition.AbstractCondition) AppBeans(com.haulmont.cuba.core.global.AppBeans) CustomConditionEditor(com.haulmont.cuba.gui.components.filter.edit.CustomConditionEditor) ConditionDescriptorsTreeBuilderAPI(com.haulmont.cuba.gui.components.filter.addcondition.ConditionDescriptorsTreeBuilderAPI) AbstractConditionDescriptor(com.haulmont.cuba.gui.components.filter.descriptor.AbstractConditionDescriptor) Window(com.haulmont.cuba.gui.components.Window) DynamicAttributesConditionCreator(com.haulmont.cuba.gui.components.filter.descriptor.DynamicAttributesConditionCreator) Configuration(com.haulmont.cuba.core.global.Configuration) WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) DynamicAttributesConditionEditor(com.haulmont.cuba.gui.components.filter.edit.DynamicAttributesConditionEditor) Tree(com.haulmont.bali.datastruct.Tree) Map(java.util.Map) ClientConfig(com.haulmont.cuba.client.ClientConfig) WindowManagerProvider(com.haulmont.cuba.gui.WindowManagerProvider) Filter(com.haulmont.cuba.gui.components.Filter) OpenType(com.haulmont.cuba.gui.WindowManager.OpenType) CustomConditionEditor(com.haulmont.cuba.gui.components.filter.edit.CustomConditionEditor) CustomConditionCreator(com.haulmont.cuba.gui.components.filter.descriptor.CustomConditionCreator) HashMap(java.util.HashMap) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) DynamicAttributesConditionEditor(com.haulmont.cuba.gui.components.filter.edit.DynamicAttributesConditionEditor) DynamicAttributesConditionCreator(com.haulmont.cuba.gui.components.filter.descriptor.DynamicAttributesConditionCreator) AbstractCondition(com.haulmont.cuba.gui.components.filter.condition.AbstractCondition) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Tree (com.haulmont.bali.datastruct.Tree)1 ClientConfig (com.haulmont.cuba.client.ClientConfig)1 AppBeans (com.haulmont.cuba.core.global.AppBeans)1 Configuration (com.haulmont.cuba.core.global.Configuration)1 WindowManager (com.haulmont.cuba.gui.WindowManager)1 OpenType (com.haulmont.cuba.gui.WindowManager.OpenType)1 WindowManagerProvider (com.haulmont.cuba.gui.WindowManagerProvider)1 Filter (com.haulmont.cuba.gui.components.Filter)1 Window (com.haulmont.cuba.gui.components.Window)1 AddConditionWindow (com.haulmont.cuba.gui.components.filter.addcondition.AddConditionWindow)1 ConditionDescriptorsTreeBuilderAPI (com.haulmont.cuba.gui.components.filter.addcondition.ConditionDescriptorsTreeBuilderAPI)1 AbstractCondition (com.haulmont.cuba.gui.components.filter.condition.AbstractCondition)1 AbstractConditionDescriptor (com.haulmont.cuba.gui.components.filter.descriptor.AbstractConditionDescriptor)1 CustomConditionCreator (com.haulmont.cuba.gui.components.filter.descriptor.CustomConditionCreator)1 DynamicAttributesConditionCreator (com.haulmont.cuba.gui.components.filter.descriptor.DynamicAttributesConditionCreator)1 CustomConditionEditor (com.haulmont.cuba.gui.components.filter.edit.CustomConditionEditor)1 DynamicAttributesConditionEditor (com.haulmont.cuba.gui.components.filter.edit.DynamicAttributesConditionEditor)1 WindowConfig (com.haulmont.cuba.gui.config.WindowConfig)1 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)1 Collection (java.util.Collection)1