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

Bug 430086

Summary: ClassCastException ResizableLabelLocator / Rectangle when moving label of edge
Product: [Modeling] Sirius Reporter: Cedric Brun <cedric.brun>
Component: DiagramAssignee: Project Inbox <sirius.diagram-inbox>
Status: CLOSED FIXED QA Contact: Jessy Mallet <jessy.mallet>
Severity: normal    
Priority: P3 CC: error-reports-inbox, jessy.mallet, julien.dupont, laurent.redor, pierre-charles.david
Version: 1.0.0M6Keywords: triaged
Target Milestone: 3.1.0   
Hardware: PC   
OS: Linux   
See Also: https://git.eclipse.org/r/53461
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=cb3b9eef35b9eea2cd9000a0c12fcf157c9f1111
Whiteboard:
Bug Depends on:    
Bug Blocks: 451053, 477205    

Description Cedric Brun CLA 2014-03-11 07:01:09 EDT
When using EcoreTools 2 I sometime have a few ClassCastException being trown.

I don't have yet a perfectly reproductible scenario but it happens when I am moving edges (which have a rectilinear routing) to layout them.

java.lang.ClassCastException: org.eclipse.gmf.runtime.diagram.ui.internal.figures.ResizableLabelLocator cannot be cast to org.eclipse.draw2d.geometry.Rectangle
	at org.eclipse.gef.editpolicies.XYLayoutEditPolicy.getCurrentConstraintFor(XYLayoutEditPolicy.java:102)
	at org.eclipse.sirius.diagram.graphical.edit.policies.AirXYLayoutEditPolicy.getCurrentConstraintFor(AirXYLayoutEditPolicy.java:262)
	at org.eclipse.gef.editpolicies.XYLayoutEditPolicy.getConstraintFor(XYLayoutEditPolicy.java:55)
	at org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy.getConstraintFor(ConstrainedLayoutEditPolicy.java:244)
	at org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy.getConstraintFor(XYLayoutEditPolicy.java:227)
	at org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy.getAddCommand(ConstrainedLayoutEditPolicy.java:184)
	at org.eclipse.gef.editpolicies.LayoutEditPolicy.getCommand(LayoutEditPolicy.java:216)
	at org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy.getCommand(ConstrainedLayoutEditPolicy.java:214)
	at org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy.getCommand(XYLayoutEditPolicy.java:329)
	at org.eclipse.gef.editparts.AbstractEditPart.getCommand(AbstractEditPart.java:502)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.access$1(GraphicalEditPart.java:1)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart$1.run(GraphicalEditPart.java:482)
	at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.getCommand(GraphicalEditPart.java:477)
	at org.eclipse.sirius.diagram.edit.api.part.AbstractDDiagramEditPart.getCommand(AbstractDDiagramEditPart.java:409)
	at org.eclipse.gef.tools.DragEditPartsTracker.getCommand(DragEditPartsTracker.java:281)
	at org.eclipse.gef.tools.DragEditPartsTracker.handleDragInProgress(DragEditPartsTracker.java:370)
	at org.eclipse.gef.tools.AbstractTool.mouseDrag(AbstractTool.java:1114)
	at org.eclipse.gef.tools.SelectionTool.mouseDrag(SelectionTool.java:538)
	at org.eclipse.gef.EditDomain.mouseDrag(EditDomain.java:259)
	at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouseMoved(DomainEventDispatcher.java:363)
	at org.eclipse.draw2d.LightweightSystem$EventHandler.mouseMove(LightweightSystem.java:543)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:212)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1276)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3562)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3186)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	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:353)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1414)

May be you have enough to get going?
Comment 1 Laurent Redor CLA 2014-03-11 07:58:56 EDT
I analyzed the stack. But I have no idea about what's going wrong.

For information, the ResizableLabelLocator is set as layoutConstraint by the LabelEditPart, org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart.handleResizableRefreshBounds(). So this problem is probably linked to the label of the edge that you move. This could help you to find a reproduction use case.
Is the label selected when you move egde?
Comment 2 Cedric Brun CLA 2014-03-11 08:51:17 EDT
I narrowed it down a bit.
The CCE actually happens when I am "moving" the center label of the edge.
But it's not easy to catch, I have to :
1- select the label by clicking on it
2- move my mouse on the side of rectangle which appears when the label. There  is a small spot (like 1 pixel wide) which makes my mouse cursor change into a "move handle" (a hand)
3- click and drag the shape => the error log is getting filed with exceptions.
Comment 3 Laurent Redor CLA 2014-03-11 10:06:21 EDT
Reproduced with Sirius 1.0.0 M6 since GEF 3.7

This problem seems to come from a change in GEF: http://git.eclipse.org/c/gef/org.eclipse.gef.git/commit/org.eclipse.gef/src/org/eclipse/gef/editpolicies/ConstrainedLayoutEditPolicy.java?id=b55147c9f85937b992c214c59a2b206e9f625ebb

I have not analyzed enough to say if it is a regresion in GEF or if Sirius should adapt its code to this change.
Comment 4 Cedric Brun CLA 2014-10-23 11:03:46 EDT
*** Bug 447156 has been marked as a duplicate of this bug. ***
Comment 5 Cedric Brun CLA 2014-10-23 11:06:46 EDT
It looks like this still bug happens in the wild and affects other projects (See Bug 448475) . Shouldn't we ping the GEF team ?
Comment 6 EPP Error Reports CLA 2014-10-25 03:10:41 EDT
*** Bug 448475 has been marked as a duplicate of this bug. ***
Comment 7 EPP Error Reports CLA 2014-11-01 03:51:39 EDT
*** Bug 449346 has been marked as a duplicate of this bug. ***
Comment 8 Laurent Redor CLA 2014-11-18 11:31:01 EST
*** Bug 452127 has been marked as a duplicate of this bug. ***
Comment 9 Eclipse Genie CLA 2015-08-10 04:45:23 EDT
New Gerrit change created: https://git.eclipse.org/r/53461
Comment 11 Pierre-Charles David CLA 2015-08-10 05:54:59 EDT
Fixed by cb3b9eef35b9eea2cd9000a0c12fcf157c9f1111.
Comment 12 Jessy Mallet CLA 2015-09-28 06:05:14 EDT
Validated with Sirius 3.1.0.201509241504
Comment 13 Pierre-Charles David CLA 2015-10-16 09:10:36 EDT
Available in Sirius 3.1.0.