Adding multiple conditions to filter at time #PL-4488

This commit is contained in:
Maxim Gorbunkov 2015-03-13 12:53:15 +00:00
parent 2f1bcc8b38
commit d3f34eec30
3 changed files with 25 additions and 15 deletions

View File

@ -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<AbstractConditionDescriptor> descriptors = window.getDescriptors();
if (descriptors != null) {
for (AbstractConditionDescriptor descriptor : descriptors) {
_addCondition(descriptor);
}
}
}
}
});
}
protected void _addCondition(AbstractConditionDescriptor descriptor) {

View File

@ -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<Entity> 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<AbstractConditionDescriptor> getDescriptors() {
return tree.getSelected();
}
}

View File

@ -19,7 +19,7 @@
<textField id="treeFilter"/>
<button id="searchBtn" action="search"/>
</hbox>
<tree id="tree" width="100%">
<tree id="tree" width="100%" multiselect="true">
<treechildren datasource="conditionDescriptorsDs" captionProperty="treeCaption"/>
</tree>
<hbox spacing="true">