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);
}
}
}
});
}
Aggregations