From d3f34eec308419808e86069cfcb06f8cf49d0f44 Mon Sep 17 00:00:00 2001 From: Maxim Gorbunkov Date: Fri, 13 Mar 2015 12:53:15 +0000 Subject: [PATCH] Adding multiple conditions to filter at time #PL-4488 --- .../components/filter/AddConditionHelper.java | 10 ++++--- .../addcondition/AddConditionWindow.java | 28 ++++++++++++------- .../filter/addcondition/add-condition.xml | 2 +- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/modules/gui/src/com/haulmont/cuba/gui/components/filter/AddConditionHelper.java b/modules/gui/src/com/haulmont/cuba/gui/components/filter/AddConditionHelper.java index 2391ec3e73..d8155e0115 100644 --- a/modules/gui/src/com/haulmont/cuba/gui/components/filter/AddConditionHelper.java +++ b/modules/gui/src/com/haulmont/cuba/gui/components/filter/AddConditionHelper.java @@ -22,6 +22,7 @@ import com.haulmont.cuba.gui.components.filter.edit.RuntimePropConditionEditor; import com.haulmont.cuba.gui.config.WindowConfig; import com.haulmont.cuba.gui.config.WindowInfo; +import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -72,14 +73,15 @@ public class AddConditionHelper { @Override public void windowClosed(String actionId) { if (Window.COMMIT_ACTION_ID.equals(actionId)) { - AbstractConditionDescriptor descriptor = window.getDescriptor(); - if (descriptor != null) { - _addCondition(descriptor); + Collection descriptors = window.getDescriptors(); + if (descriptors != null) { + for (AbstractConditionDescriptor descriptor : descriptors) { + _addCondition(descriptor); + } } } } }); - } protected void _addCondition(AbstractConditionDescriptor descriptor) { diff --git a/modules/gui/src/com/haulmont/cuba/gui/components/filter/addcondition/AddConditionWindow.java b/modules/gui/src/com/haulmont/cuba/gui/components/filter/addcondition/AddConditionWindow.java index a7809bd54a..6c9fc55d98 100644 --- a/modules/gui/src/com/haulmont/cuba/gui/components/filter/addcondition/AddConditionWindow.java +++ b/modules/gui/src/com/haulmont/cuba/gui/components/filter/addcondition/AddConditionWindow.java @@ -6,6 +6,7 @@ package com.haulmont.cuba.gui.components.filter.addcondition; import com.haulmont.chile.core.model.MetaProperty; +import com.haulmont.cuba.core.entity.Entity; import com.haulmont.cuba.core.global.AppBeans; import com.haulmont.cuba.core.global.Metadata; import com.haulmont.cuba.gui.components.*; @@ -19,6 +20,7 @@ import com.haulmont.cuba.gui.xml.layout.ComponentsFactory; import javax.inject.Inject; import java.util.Collection; import java.util.Map; +import java.util.Set; import java.util.UUID; /** @@ -85,16 +87,23 @@ public class AddConditionWindow extends AbstractWindow { } public void select() { - AbstractConditionDescriptor item = conditionDescriptorsDs.getItem(); - if (item == null) { + Set selectedItems = tree.getSelected(); + if (selectedItems.isEmpty()) { showNotification(getMessage("AddCondition.selectCondition"), NotificationType.WARNING); - } else if (item instanceof HeaderConditionDescriptor) { - showNotification(getMessage("AddCondition.youSelectedGroup"), NotificationType.WARNING); - } else if (isEmbeddedProperty(item)) { - showNotification(getMessage("AddCondition.youSelectedEmbedded"), NotificationType.WARNING); + return; } else { - close(COMMIT_ACTION_ID); + for (Entity item : selectedItems) { + if (item instanceof HeaderConditionDescriptor) { + showNotification(getMessage("AddCondition.youSelectedGroup"), NotificationType.WARNING); + return; + } else if (isEmbeddedProperty((AbstractConditionDescriptor) item)) { + showNotification(getMessage("AddCondition.youSelectedEmbedded"), NotificationType.WARNING); + return; + } + } } + + close(COMMIT_ACTION_ID); } protected boolean isEmbeddedProperty(AbstractConditionDescriptor item) { @@ -111,8 +120,7 @@ public class AddConditionWindow extends AbstractWindow { close(CLOSE_ACTION_ID); } - public AbstractConditionDescriptor getDescriptor() { - AbstractConditionDescriptor item = conditionDescriptorsDs.getItem(); - return item; + public Collection getDescriptors() { + return tree.getSelected(); } } diff --git a/modules/gui/src/com/haulmont/cuba/gui/components/filter/addcondition/add-condition.xml b/modules/gui/src/com/haulmont/cuba/gui/components/filter/addcondition/add-condition.xml index 526788e187..17af18702a 100644 --- a/modules/gui/src/com/haulmont/cuba/gui/components/filter/addcondition/add-condition.xml +++ b/modules/gui/src/com/haulmont/cuba/gui/components/filter/addcondition/add-condition.xml @@ -19,7 +19,7 @@