I've added a DropTarget (DND.DROP_COPY) to a table in a shell. When I try to drop something on it, the following exception will be thrown:

!ENTRY org.eclipse.ui 4 0 2009-11-25 08:49:40.661
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.IllegalArgumentException: Index out of bounds
at org.eclipse.swt.SWT.error(SWT.java:3865)
at org.eclipse.swt.SWT.error(SWT.java:3799)
at org.eclipse.swt.SWT.error(SWT.java:3770)
at org.eclipse.swt.widgets.Widget.error(Widget.java:619)
at org.eclipse.swt.widgets.Table.getItem(Table.java:1420)
at org.eclipse.swt.dnd.DropTargetEffect.getItem(DropTargetEffect.java:107)
at org.eclipse.swt.dnd.DropTargetEffect.getItem(DropTargetEffect.java:90)
at org.eclipse.swt.dnd.DropTarget.setEventData(DropTarget.java:873)
at org.eclipse.swt.dnd.DropTarget.draggingUpdated(DropTarget.java:280)
at org.eclipse.swt.dnd.DropTarget.dropTargetProc(DropTarget.java:430)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSend_bool(Native Method)
at org.eclipse.swt.internal.cocoa.NSRunLoop.runMode(NSRunLoop.java:42)
at org.eclipse.swt.widgets.Display.sleep(Display.java:3905)
at org.eclipse.ui.application.WorkbenchAdvisor.eventLoopIdle(WorkbenchAdvisor.java:364)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2406)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
...

I've debugged the code and found out that the method Table#getTopIndex returns -1 at DropTargetEvent.class:106.

The result is, that the method Table#getItem will be called with -1 and an IllegalArgumentException (Index out of bounds) will be thrown.

The javadoc of the method Table#getTopIndex says:

Returns the zero-relative index of the item which is currently at the top of the receiver...

Therefore I conclude that something is wrong with #getTopIndex method.

If the table has initially one or more items, everything works just fine.

Thanks for every contribution.

Kind regards

Pierre Schubert
]]>Pierre Schubert2009-11-25T08:24:31-00:00Re: Table#getTopIndex returns negative valuehttps://www.eclipse.org/forums/index.php/mv/msg/158404/500690/#msg_500690
You're seeing https://bugs.eclipse.org/bugs/show_bug.cgi?id=287234 , which
is fixed in the 3.6 stream. The only workaround I can suggest in the
meantime is to give the Table an empty initial item which gets removed when
the Table receives its real content.

Grant

"Pierre Schubert" <pschubert@quintessence.net> wrote in message
news:heipk1$p51$1@build.eclipse.org...
> Hi everyone,
>
> I have a problem with DND in conjunction with a table.
>
> It appears on my Mac (OS X 10.6.2 64 bit) with the swt.cocoa (3.5.1v3555a)
plugin.
>
> I've added a DropTarget (DND.DROP_COPY) to a table in a shell. When I try
to drop something on it, the following exception will be thrown:
>
> !ENTRY org.eclipse.ui 4 0 2009-11-25 08:49:40.661
> !MESSAGE Unhandled event loop exception
> !STACK 0
> java.lang.IllegalArgumentException: Index out of bounds
> at org.eclipse.swt.SWT.error(SWT.java:3865)
> at org.eclipse.swt.SWT.error(SWT.java:3799)
> at org.eclipse.swt.SWT.error(SWT.java:3770)
> at org.eclipse.swt.widgets.Widget.error(Widget.java:619)
> at org.eclipse.swt.widgets.Table.getItem(Table.java:1420)
> at org.eclipse.swt.dnd.DropTargetEffect.getItem(DropTargetEffec t.java:107)
> at org.eclipse.swt.dnd.DropTargetEffect.getItem(DropTargetEffec t.java:90)
> at org.eclipse.swt.dnd.DropTarget.setEventData(DropTarget.java: 873)
> at org.eclipse.swt.dnd.DropTarget.draggingUpdated(DropTarget.ja va:280)
> at org.eclipse.swt.dnd.DropTarget.dropTargetProc(DropTarget.jav a:430)
> at org.eclipse.swt.internal.cocoa.OS.objc_msgSend_bool(Native Method)
> at org.eclipse.swt.internal.cocoa.NSRunLoop.runMode(NSRunLoop.j ava:42)
> at org.eclipse.swt.widgets.Display.sleep(Display.java:3905)
> at
org.eclipse.ui.application.WorkbenchAdvisor.eventLoopIdle(Wo rkbenchAdvisor.j
ava:364)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2406)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 21)
> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
> at
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:332)
> at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:493)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
> ...
> I've debugged the code and found out that the method Table#getTopIndex
returns -1 at DropTargetEvent.class:106.
>
> The result is, that the method Table#getItem will be called with -1 and an
IllegalArgumentException (Index out of bounds) will be thrown.
>
> The javadoc of the method Table#getTopIndex says:
>
> Returns the zero-relative index of the item which is currently at the top
of the receiver...
> Therefore I conclude that something is wrong with #getTopIndex method.
>
> If the table has initially one or more items, everything works just fine.
>
> Thanks for every contribution.
>
> Kind regards
>
> Pierre Schubert
>]]>Grant Gayed2009-11-27T14:16:06-00:00