}
sourceItems.removeAll(droppedItems);
- listDataProvider.refreshAll();
+
+ // if reordering the same grid, DataProvider's refresh will be done later
+ if (getGridDragSource().getGrid() != getGridDropTarget().getGrid()) {
+ listDataProvider.refreshAll();
+ }
}
private void handleTargetGridDrop(GridDropEvent<T> event, final int index,
verifyDataProvider("1", "2", "0");
}
+ @Test
+ public void listDataProvider_calledOnlyOnce() {
+
+ final int[] times = new int[1];
+
+ source.setItems("0", "1", "2");
+
+ source.getDataProvider().addDataProviderListener(ev -> times[0]++);
+
+ dragger.setDropIndexCalculator(event -> {
+ return Integer.MAX_VALUE;
+ });
+
+ drop("1", DropLocation.ABOVE, "0");
+
+ verifyDataProvider("1", "2", "0");
+
+ Assert.assertArrayEquals("DataProvider should be invoked only once", new int[] { 1 }, times);
+ }
+
@Test
public void noopSourceUpdater() {
source.setItems("0", "1", "2");