@Override public void setFilter(Filter filter) { this.filter = filter; addConditionHelper = new AddConditionHelper(filter, condition -> { try { addCondition(condition); } catch (Exception e) { conditions.removeCondition(condition); throw e; } }); }
public void addCondition() { addConditionHelper.addCondition(conditions); }
/** * 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, PROPERTIES_HIERARCHY_DEPTH, 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); } } } }); }
addConditionHelper = new AddConditionHelper(filter, BooleanUtils.isTrue(hideDynamicAttributes), BooleanUtils.isTrue(hideCustomConditions), condition -> { AbstractCondition item = conditionsDs.getItem(); if (item != null && item instanceof GroupCondition) {
addConditionBtn.setCaption(getMainMessage("filter.addCondition")); addConditionBtn.addClickListener(e -> addConditionHelper.addCondition(conditions) ); filterHelper.setInternalDebugId(addConditionBtn, "addConditionBtn");