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

Bug 428079

Summary: ClassCastException when using a Drop tool on a list item
Product: [Modeling] Sirius Reporter: Pierre-Charles David <pierre-charles.david>
Component: DiagramAssignee: Florian Barbin <florian.barbin>
Status: CLOSED FIXED QA Contact: Laurent Redor <laurent.redor>
Severity: normal    
Priority: P3 CC: cedric.brun, florian.barbin, laurent.redor
Version: 1.0.0M5Keywords: triaged
Target Milestone: 3.0.0M5   
Hardware: All   
OS: All   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=437370
Whiteboard:
Bug Depends on: 447727    
Bug Blocks:    
Attachments:
Description Flags
Test project to reproduce the bug none

Description Pierre-Charles David CLA 2014-02-13 04:57:34 EST
Created attachment 239899 [details]
Test project to reproduce the bug

Steps to reproduce:
1. Start Sirius and import the attached project in your workspace.
2. Open the session in fixture.aird and open the diagram it contains.
3. Use the tool in the palette to create a new class inside the non-list container. A green square representing the new class appears.
4. Drag the class out of the container and drop it on the diagram itself: the view disappears from the container and a new one appears on the diagram: OK (it seems to not always appear at the proper location (i.e. under the mouse) but that is not the scope if this issue).
5. Repeat steps 3 and 4 with the list container: create a new class using the tool on the list (a list item appears), drag the list item out of the list and on the diagram: an ClassCastExcetion is raised in the error log: KO.

The stack (only the relevant part):

Caused by: java.lang.ClassCastException: org.eclipse.sirius.business.internal.metamodel.spec.DNodeListElementSpec cannot be cast to org.eclipse.sirius.diagram.DNode
	at org.eclipse.sirius.business.internal.helper.task.DnDTasksOperations$4.execute(DnDTasksOperations.java:196)
	at org.eclipse.sirius.business.api.helper.task.TaskExecutor.operation(TaskExecutor.java:95)
	at org.eclipse.sirius.business.api.helper.task.TaskExecutor.execute(TaskExecutor.java:65)
	at org.eclipse.sirius.tools.api.command.SiriusCommand.doExecute(SiriusCommand.java:80)
	at org.eclipse.emf.transaction.RecordingCommand.execute(RecordingCommand.java:135)
	at org.eclipse.emf.common.command.CompoundCommand.execute(CompoundCommand.java:261)
	at org.eclipse.sirius.diagram.tools.api.command.GMFCommandWrapper.doExecuteWithResult(GMFCommandWrapper.java:103)
	at org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand.doExecute(AbstractTransactionalCommand.java:247)
	at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:150)
	at org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy.execute(ICommandProxy.java:68)
	at org.eclipse.sirius.diagram.graphical.edit.policies.SiriusContainerDropPolicy$1.execute(SiriusContainerDropPolicy.java:268)
Comment 1 Cedric Brun CLA 2014-06-13 08:28:02 EDT
This is reproducible with EcoreTools too.

Open an "entities" diagram on top of an already existing Ecore model.
Use "Add" from the palette.
Select several EClasses at once
Nothing will show up in the diagram and you'll get the following stack trace:

Caused by: java.lang.ClassCastException: org.eclipse.sirius.diagram.business.internal.metamodel.spec.DNodeListSpec cannot be cast to org.eclipse.sirius.diagram.DNodeListElement
	at org.eclipse.sirius.diagram.business.api.helper.SiriusDiagramHelper.addNodeInContainer(SiriusDiagramHelper.java:175)
	at org.eclipse.sirius.diagram.business.internal.experimental.sync.DDiagramElementSynchronizer.createNewNode(DDiagramElementSynchronizer.java:174)
	at org.eclipse.sirius.diagram.business.internal.experimental.sync.DDiagramElementSynchronizer.createNewNode(DDiagramElementSynchronizer.java:150)
	at org.eclipse.sirius.diagram.business.internal.helper.task.operations.CreateViewTask.createView(CreateViewTask.java:179)
	at org.eclipse.sirius.diagram.business.internal.helper.task.operations.CreateViewTask.execute(CreateViewTask.java:124)
	at org.eclipse.sirius.business.internal.helper.task.ExecuteToolOperationTask.executeTask(ExecuteToolOperationTask.java:103)
	at org.eclipse.sirius.business.internal.helper.task.ExecuteToolOperationTask.executeTask(ExecuteToolOperationTask.java:114)
	at org.eclipse.sirius.business.internal.helper.task.ExecuteToolOperationTask.executeTask(ExecuteToolOperationTask.java:114)
	at org.eclipse.sirius.business.internal.helper.task.ExecuteToolOperationTask.execute(ExecuteToolOperationTask.java:88)
	at org.eclipse.sirius.business.internal.helper.task.operations.ForTask.execute(ForTask.java:100)
Comment 2 Florian Barbin CLA 2014-12-12 05:08:20 EST
A gerrit review is available: https://git.eclipse.org/r/#/c/37931/
Comment 4 Laurent Redor CLA 2015-05-21 10:02:23 EDT
Verified with Sirius 3.0.0 rc1
Comment 5 Pierre-Charles David CLA 2015-06-24 11:15:20 EDT
Available in Sirius 3.0.0. See https://wiki.eclipse.org/Sirius/3.0.0.