fredsa / gwt-dnd

Library providing easy to use mouse or touch based drag-and-drop capabilities to GWT
42 stars 41 forks source link

IndexOutOfBoundsException on drop in case of multipleSelection #113

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
GWT version 2.0.3
GWT-DnD 3.0.1

Steps to reproduce the problem:
1. multipleSelectionAllowed is true for the used drag controller 
(PickupDragController)
2. the drop controller is extended from AbstractInsertPanelDropController
3. the drop panel (bound to the drop controller is extended from 
ComplexPanel
4. the drop panel contains N widgets and all of them are registered as 
draggable (the same drag controller)
5. in a drag operation, all N widgets are selected and than dropped just 
before the last widget within the panel
6. the drop panel throws IndexOutOfBoundsException from method 
checkIndexBoundsForInsertion() because
    AbstractInsertPanelDropController.onDrop() tries to insert a widget 
on an invalid index (grater than the current widget count)

As a quick work-around I overrided the insert() method of the drop panel in 
the following way:

@Override
protected void insert(Widget child, com.google.gwt.user.client.Element 
container, int beforeIndex, boolean domInsert) {
  if ( beforeIndex <= this.getWidgetCount() ) {
  super.insert(child, container, beforeIndex, domInsert);
  } else {
    super.add(child, container);
  }
  ...
}

But I think the real solution would be to correct the behavour of 
AbstractInsertPanelDropController.onDrop().

Original issue reported on code.google.com by ivancevi...@gmail.com on 3 Jun 2010 at 10:37

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I place this workaround in public domain.

Original comment by ivancevi...@gmail.com on 2 Nov 2010 at 7:29

GoogleCodeExporter commented 9 years ago
Appears to have been fixed. I was unable to reproduce using 
https://gwt-dnd.appspot.com/#FlowPanelExample

Original comment by fredsa@google.com on 28 Mar 2013 at 10:16