Search in sources :

Example 1 with AddConditionWindow

use of com.haulmont.cuba.gui.components.filter.addcondition.AddConditionWindow in project cuba by cuba-platform.

the class AddConditionHelper method addCondition.

/**
 * Opens AddCondition window. When condition is selected/created a {@code Handler#handle} method will be called
 *
 * @param conditionsTree conditions tree is necessary for custom condition editing. It is used for suggestion of
 *                       other component names in 'param where' field.
 */
public void addCondition(final ConditionsTree conditionsTree) {
    Map<String, Object> params = new HashMap<>();
    ConditionDescriptorsTreeBuilderAPI descriptorsTreeBuilder = AppBeans.getPrototype(ConditionDescriptorsTreeBuilderAPI.NAME, filter, clientConfig.getGenericFilterPropertiesHierarchyDepth(), hideDynamicAttributes, hideCustomConditions, conditionsTree);
    Tree<AbstractConditionDescriptor> descriptorsTree = descriptorsTreeBuilder.build();
    params.put("descriptorsTree", descriptorsTree);
    WindowInfo windowInfo = windowConfig.getWindowInfo("addCondition");
    AddConditionWindow window = (AddConditionWindow) windowManager.openWindow(windowInfo, OpenType.DIALOG, params);
    window.addCloseListener(actionId -> {
        if (Window.COMMIT_ACTION_ID.equals(actionId)) {
            Collection<AbstractConditionDescriptor> descriptors = window.getDescriptors();
            if (descriptors != null) {
                for (AbstractConditionDescriptor descriptor : descriptors) {
                    _addCondition(descriptor, conditionsTree);
                }
            }
        }
    });
}
Also used : AbstractConditionDescriptor(com.haulmont.cuba.gui.components.filter.descriptor.AbstractConditionDescriptor) HashMap(java.util.HashMap) AddConditionWindow(com.haulmont.cuba.gui.components.filter.addcondition.AddConditionWindow) ConditionDescriptorsTreeBuilderAPI(com.haulmont.cuba.gui.components.filter.addcondition.ConditionDescriptorsTreeBuilderAPI) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Aggregations

AddConditionWindow (com.haulmont.cuba.gui.components.filter.addcondition.AddConditionWindow)1 ConditionDescriptorsTreeBuilderAPI (com.haulmont.cuba.gui.components.filter.addcondition.ConditionDescriptorsTreeBuilderAPI)1 AbstractConditionDescriptor (com.haulmont.cuba.gui.components.filter.descriptor.AbstractConditionDescriptor)1 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)1 HashMap (java.util.HashMap)1