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

Bug 266065

Summary: [DnD] TransferDragSourceListener causes ClassCastException with TreeEditPart
Product: [Tools] GEF Reporter: Felix L J Mayer <felix.mayer>
Component: GEF-Legacy GEF (MVC)Assignee: Alexander Nyßen <nyssen>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: nyssen
Version: 3.4   
Target Milestone: 3.7.1 (Indigo) M6   
Hardware: All   
OS: All   
Whiteboard:

Description Felix L J Mayer CLA 2009-02-24 21:19:43 EST
Build ID:  I20080617-2000

Steps To Reproduce:
1. Create a org.eclipse.jface.util.TransferDragSourceListener and add it to the viewer of a org.eclipse.gef.ui.parts.ContentOutlinePage using getViewer().addDragSourceListener().
2. Select something in the outline.
3. Find the following exception because TreeEditPart cannot be cast to GraphicalEditPart. Code inspection shows that the cast to GraphicalEditPart is not necessary, EditPart would do.

java.lang.ClassCastException: com.objectaid.uml.outline.OperationTreeEditPart cannot be cast to org.eclipse.gef.GraphicalEditPart
	at org.eclipse.gef.tools.ToolUtilities.getSelectionWithoutDependants(ToolUtilities.java:38)
	at org.eclipse.gef.tools.DragEditPartsTracker.createOperationSet(DragEditPartsTracker.java:175)
	at org.eclipse.gef.tools.AbstractTool.getOperationSet(AbstractTool.java:574)
	at org.eclipse.gef.tools.DragEditPartsTracker.captureSourceDimensions(DragEditPartsTracker.java:136)
	at org.eclipse.gef.tools.DragEditPartsTracker.setState(DragEditPartsTracker.java:562)
	at org.eclipse.gef.tools.AbstractTool.stateTransition(AbstractTool.java:1368)
	at org.eclipse.gef.tools.SelectEditPartTracker.handleButtonDown(SelectEditPartTracker.java:98)
	at org.eclipse.gef.tools.AbstractTool.mouseDown(AbstractTool.java:975)
	at org.eclipse.gef.tools.SelectionTool.mouseDown(SelectionTool.java:490)
	at org.eclipse.gef.EditDomain.mouseDown(EditDomain.java:219)
	at org.eclipse.gef.ui.parts.TreeViewer$EventDispatcher.mouseDown(TreeViewer.java:70)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:179)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1212)



More information:
Comment 1 Alexander Nyßen CLA 2011-03-05 18:03:38 EST
Indeed, I cannot reproduce the problem described here. 

However, the casts within ToolUtilities seem to be too restricted (EditPart will do in all cases where GraphicalEditPart is currently used), and I think it makes sense to change this.
Comment 2 Alexander Nyßen CLA 2011-03-05 18:08:34 EST
Changed all casts within ToolUtilities from GraphicalEditPart to EditPart. Changes committed to cvs HEAD (3.7M6). Closing as fixed. Please re-open in case you can find other places that cause problems with TreeEditParts.