use of com.haulmont.cuba.gui.components.filter.descriptor.AbstractConditionDescriptor in project cuba by cuba-platform.
the class AddConditionWindow method select.
public void select() {
Set<Entity> selectedItems = tree.getSelected();
if (selectedItems.isEmpty()) {
showNotification(messages.getMainMessage("filter.addCondition.selectCondition"), NotificationType.WARNING);
return;
} else {
for (Entity item : selectedItems) {
if (item instanceof HeaderConditionDescriptor) {
showNotification(messages.getMainMessage("filter.addCondition.youSelectedGroup"), NotificationType.WARNING);
return;
} else if (isEmbeddedProperty((AbstractConditionDescriptor) item)) {
showNotification(messages.getMainMessage("filter.addCondition.youSelectedEmbedded"), NotificationType.WARNING);
return;
}
}
}
close(COMMIT_ACTION_ID);
}
use of com.haulmont.cuba.gui.components.filter.descriptor.AbstractConditionDescriptor 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);
}
}
use of com.haulmont.cuba.gui.components.filter.descriptor.AbstractConditionDescriptor 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