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

Bug 435203

Summary: ClassCastException: DNodeListSpec cannot be cast to DNodeListElement
Product: [Modeling] Sirius Reporter: Stephane Begaudeau <stephane.begaudeau>
Component: DiagramAssignee: Maxime Porhel <maxime.porhel>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P3 CC: error-reports-inbox, florian.barbin, maxime.porhel, pierre-charles.david
Version: 1.0.0M7Keywords: triaged
Target Milestone: 1.0.1   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 436465    
Bug Blocks:    

Description Stephane Begaudeau CLA 2014-05-19 08:54:37 EDT
Steps to reproduce:
- Eclipse Kepler SR2 with Sirius M7 and EcoreTools 2.0 M7
- Create an Ecore model with the Ecore tree-based editor
- Convert your project to a modeling project
- Select all the viewpoints of EcoreTools 2.0
- Open the newly created empty class diagram (created by EcoreTools on the root package of your Ecore)
- Click on Add since the diagram is not synchronized to add elements in the class diagram, select multiple elements -> the exception appear (if you select one element, it works).

org.eclipse.core.commands.ExecutionException: While executing the operation, an exception occurred
	at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:521)
	at org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramCommandStack.execute(DDiagramCommandStack.java:75)
	at org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramCommandStack.execute(DDiagramCommandStack.java:57)
	at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack.execute(DiagramCommandStack.java:156)
	at org.eclipse.gef.tools.AbstractTool.executeCommand(AbstractTool.java:425)
	at org.eclipse.gef.tools.AbstractTool.executeCurrentCommand(AbstractTool.java:438)
	at org.eclipse.gef.tools.CreationTool.performCreation(CreationTool.java:269)
	at org.eclipse.gef.tools.CreationTool.handleButtonUp(CreationTool.java:189)
	at org.eclipse.gef.tools.AbstractTool.mouseUp(AbstractTool.java:1200)
	at org.eclipse.gef.EditDomain.mouseUp(EditDomain.java:301)
	at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouseReleased(DomainEventDispatcher.java:380)
	at org.eclipse.draw2d.LightweightSystem$EventHandler.mouseUp(LightweightSystem.java:548)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:220)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4170)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:140)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:611)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	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:354)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
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)
	at org.eclipse.sirius.business.internal.helper.task.ExecuteToolOperationTask.executeTask(ExecuteToolOperationTask.java:103)
	at org.eclipse.sirius.business.internal.helper.task.ExecuteToolOperationTask.execute(ExecuteToolOperationTask.java:88)
	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.sirius.diagram.ui.tools.internal.commands.emf.SelectionWizardCommand.doExecute(SelectionWizardCommand.java:91)
	at org.eclipse.emf.transaction.RecordingCommand.execute(RecordingCommand.java:135)
	at org.eclipse.sirius.diagram.ui.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.common.core.command.CompositeCommand.doExecuteWithResult(CompositeCommand.java:403)
	at org.eclipse.gmf.runtime.common.core.command.AbstractCommand.execute(AbstractCommand.java:134)
	at org.eclipse.gmf.runtime.common.core.command.CompositeCommand.doExecuteWithResult(CompositeCommand.java:403)
	at org.eclipse.gmf.runtime.common.core.command.AbstractCommand.execute(AbstractCommand.java:134)
	at org.eclipse.gmf.runtime.common.core.command.CompositeCommand.doExecuteWithResult(CompositeCommand.java:403)
	at org.eclipse.gmf.runtime.common.core.command.AbstractCommand.execute(AbstractCommand.java:134)
	at org.eclipse.sirius.diagram.ui.tools.internal.commands.WrappingCommandIgnoringAffectedFiles.execute(WrappingCommandIgnoringAffectedFiles.java:124)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:513)
	... 38 more
Comment 1 Florian Barbin CLA 2014-05-21 09:53:39 EDT
I reproduced the issue. I've tested by adding two EClass in my diagram. According to the exception, it's like it tried to add the second EClass (a DNoeList) as a DNodeListElement of the first EClass. It may be a container context issue.
Comment 2 Maxime Porhel CLA 2014-07-16 09:47:09 EDT
If you select two EClass, during the second CreateViewTask, the var:containerView evaluation return the first created DNodeList. 

If I replace the "var:containerView" expression by "[containerView/]", I get the expected DSemanticDiagram.

The refrehs called from the first CreateViewTask change the containerView value when it computes the semantic candidates of the attributes mapping:

Thread [main] (Suspended (breakpoint at line 318 in ODesignGenericInterpreter))	
 ODesignGenericInterpreter.setVariable(String, Object) line: 318	
 AbstractNodeMappingSpecOperations.getSemanticIterator(AbstractNodeMapping, EObject, EObject, EObject) line: 166	
 AbstractNodeMappingSpecOperations.createBorderingNodes(AbstractNodeMapping, EObject, DDiagramElement, Collection, DDiagram) line: 136	
 CreateViewTask.createView(DSemanticDiagram, DSemanticDecorator, Session) line: 181	
 CreateViewTask.execute() line: 124


The issue is that the org.eclipse.sirius.common.tools.internal.interpreter.AbstractInterpreter.unSetVariable(String) is not implemented. This variable/service/feature interpreter should use a multimap or a variable manager to have a "stack" of values.
Comment 3 Maxime Porhel CLA 2014-07-16 09:54:32 EDT
This bug is a duplicate of Bug 436465. 

I do not close it as DUPLICATE because Bug 436465 has 2.0.0 as target milestone whereas this bug is planned for 1.0.1.
Comment 4 Maxime Porhel CLA 2014-07-24 05:04:49 EDT
See https://git.eclipse.org/r/30410
Comment 5 Maxime Porhel CLA 2014-07-24 10:59:00 EDT
Corrected by commit 482e8d763f7b64946e4355e1d489235d2a479db4
Comment 6 Pierre-Charles David CLA 2014-10-15 04:21:59 EDT
*** Bug 446785 has been marked as a duplicate of this bug. ***
Comment 7 Pierre-Charles David CLA 2015-05-20 07:55:35 EDT
Available in Sirius 1.0.1.