Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 134127

Summary: [DND] DropTarget.notifyListeners(int, Event) causes ClassCastException
Product: [Eclipse Project] Platform Reporter: Dani Megert <daniel_megert>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED WONTFIX QA Contact: Kevin Barnes <cocoakevin>
Severity: normal    
Priority: P3 CC: duongn, snorthov, veronika_irvine
Version: 3.2Keywords: triaged
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description Dani Megert CLA 2006-03-30 13:33:06 EST
I20060330-0010

The following code results in a ClassCastException, which it shouldn't. There's no other way to invoke DropTarget.notifyListeners(...) because the DNDEvent is package visible. Same is true for the DragSource.notifyListeners(...)

Event e= createEvent(e);
DropTarget.notifyListeners(DND.DragEnter, e);

Thread [main] (Suspended (exception ClassCastException))
	DNDListener.handleEvent(Event) line: 46
	EventTable.sendEvent(Event) line: 66
	DropTarget(Widget).sendEvent(Event) line: 925
	DropTarget(Widget).sendEvent(int, Event, boolean) line: 949
	DropTarget(Widget).sendEvent(int, Event) line: 934
	DropTarget(Widget).notifyListeners(int, Event) line: 706
	TextViewer$1.dragEnter(DropTargetEvent) line: 1488
	DNDListener.handleEvent(Event) line: 47
	EventTable.sendEvent(Event) line: 66
	DropTarget(Widget).sendEvent(Event) line: 925
	DropTarget(Widget).sendEvent(int, Event, boolean) line: 949
	DropTarget(Widget).sendEvent(int, Event) line: 934
	DropTarget(Widget).notifyListeners(int, Event) line: 706
	DropTarget.DragEnter(int, int, int, int, int) line: 268
	DropTarget$3.method3(int[]) line: 235
	COMObject.callback3(int[]) line: 90
	COM.DoDragDrop(int, int, int, int[]) line: not available [native method]
	DragSource.drag(Event) line: 306
	DragSource.access$0(DragSource, Event) line: 277
	DragSource$1.handleEvent(Event) line: 164
	EventTable.sendEvent(Event) line: 66
	Tree(Widget).sendEvent(Event) line: 925
Comment 1 Dani Megert CLA 2006-06-27 09:30:34 EDT
ping.
Comment 2 Veronika Irvine CLA 2006-06-27 12:13:05 EDT
Steve - do you want to make DNDEvent API?  Note that StyledTextEvent is also package protected.

The notifyListeners() mechanism is typically used to implement custom widgets that support high level events like Selection.  The use here in TextViewer$1.dragEnter() is not expected.  Why is it necessary to resend a drag enter event on the drop target when one has just been sent?
Comment 3 Dani Megert CLA 2006-06-27 12:24:58 EDT
>Why is it necessary to resend a drag
>enter event on the drop target when one has just been sent?
I tried to hack around the SWT limitation covered by bug 142845. If that bug is fixed I won't need this one.

>The use here in
>TextViewer$1.dragEnter() is not expected.
Why make the even type API then? Is there an event type which would allow me to send a StyledTextEvent?
Comment 4 Leo Ufimtsev CLA 2017-08-03 12:30:08 EDT
This is a one-off bulk update. (The last one in the triage migration).

Moving bugs from swt-triaged@eclipse to platform-swt-inbox@eclipse.org and adding "triaged" keyword as per new triage process:
https://wiki.eclipse.org/SWT/Devel/Triage

See Bug 518478 for details.

Tag for notification/mail filters:
@TriageBulkUpdate
Comment 5 Eclipse Genie CLA 2020-06-01 13:04:54 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.