diff options
Diffstat (limited to 'server/src/main/java/com/vaadin/data/provider')
-rw-r--r-- | server/src/main/java/com/vaadin/data/provider/DataCommunicator.java | 51 | ||||
-rw-r--r-- | server/src/main/java/com/vaadin/data/provider/HierarchicalDataCommunicator.java | 20 |
2 files changed, 61 insertions, 10 deletions
diff --git a/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java b/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java index 35dad20c49..4b12919176 100644 --- a/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java +++ b/server/src/main/java/com/vaadin/data/provider/DataCommunicator.java @@ -40,6 +40,7 @@ import com.vaadin.shared.data.DataCommunicatorClientRpc; import com.vaadin.shared.data.DataCommunicatorConstants; import com.vaadin.shared.data.DataRequestRpc; import com.vaadin.shared.extension.datacommunicator.DataCommunicatorState; +import com.vaadin.ui.ComboBox; import elemental.json.Json; import elemental.json.JsonArray; @@ -530,7 +531,9 @@ public class DataCommunicator<T> extends AbstractExtension { public void reset() { // Only needed if a full reset is not pending. if (!reset) { - beforeClientResponse(true); + if (getParent() instanceof ComboBox) { + beforeClientResponse(true); + } // Soft reset through client-side re-request. getClientRpc().reset(getDataProviderSize()); } @@ -574,10 +577,28 @@ public class DataCommunicator<T> extends AbstractExtension { * * @param comparator * comparator used to sort data + * @param immediateReset + * {@code true} if an internal reset should be performed + * immediately after updating the comparator (unless full reset + * is already pending), {@code false} if you are going to trigger + * reset separately later + */ + public void setInMemorySorting(Comparator<T> comparator, + boolean immediateReset) { + inMemorySorting = comparator; + if (immediateReset) { + reset(); + } + } + + /** + * Sets the {@link Comparator} to use with in-memory sorting. + * + * @param comparator + * comparator used to sort data */ public void setInMemorySorting(Comparator<T> comparator) { - inMemorySorting = comparator; - reset(); + setInMemorySorting(comparator, true); } /** @@ -595,11 +616,29 @@ public class DataCommunicator<T> extends AbstractExtension { * * @param sortOrder * list of sort order information to pass to a query - */ - public void setBackEndSorting(List<QuerySortOrder> sortOrder) { + * @param immediateReset + * {@code true} if an internal reset should be performed + * immediately after updating the comparator (unless full reset + * is already pending), {@code false} if you are going to trigger + * reset separately later + */ + public void setBackEndSorting(List<QuerySortOrder> sortOrder, + boolean immediateReset) { backEndSorting.clear(); backEndSorting.addAll(sortOrder); - reset(); + if (immediateReset) { + reset(); + } + } + + /** + * Sets the {@link QuerySortOrder}s to use with backend sorting. + * + * @param sortOrder + * list of sort order information to pass to a query + */ + public void setBackEndSorting(List<QuerySortOrder> sortOrder) { + setBackEndSorting(sortOrder, true); } /** diff --git a/server/src/main/java/com/vaadin/data/provider/HierarchicalDataCommunicator.java b/server/src/main/java/com/vaadin/data/provider/HierarchicalDataCommunicator.java index 73bd9e0221..706f0a9391 100644 --- a/server/src/main/java/com/vaadin/data/provider/HierarchicalDataCommunicator.java +++ b/server/src/main/java/com/vaadin/data/provider/HierarchicalDataCommunicator.java @@ -406,19 +406,31 @@ public class HierarchicalDataCommunicator<T> extends DataCommunicator<T> { } @Override - public void setBackEndSorting(List<QuerySortOrder> sortOrder) { + public void setBackEndSorting(List<QuerySortOrder> sortOrder, + boolean immediateReset) { if (mapper != null) { mapper.setBackEndSorting(sortOrder); } - super.setBackEndSorting(sortOrder); + super.setBackEndSorting(sortOrder, immediateReset); } @Override - public void setInMemorySorting(Comparator<T> comparator) { + public void setBackEndSorting(List<QuerySortOrder> sortOrder) { + setBackEndSorting(sortOrder, true); + } + + @Override + public void setInMemorySorting(Comparator<T> comparator, + boolean immediateReset) { if (mapper != null) { mapper.setInMemorySorting(comparator); } - super.setInMemorySorting(comparator); + super.setInMemorySorting(comparator, immediateReset); + } + + @Override + public void setInMemorySorting(Comparator<T> comparator) { + setInMemorySorting(comparator, true); } @Override |