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

Bug 328355

Summary: Exceptions while creating relations in JPA Diagram Editor
Product: [Modeling] Graphiti Reporter: Stefan Dimov <stefan.dimov>
Component: CoreAssignee: Project Inbox <graphiti-inbox>
Status: CLOSED WORKSFORME QA Contact:
Severity: major    
Priority: P3 CC: michael.wenz
Version: 0.7.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Whiteboard:

Description Stefan Dimov CLA 2010-10-21 10:27:19 EDT
Perhaps it's some syncronizational problem, because it appears often, but not always:

Please, use the last JPA Digram editor sources from the HEAD branch.

1. Create JPA 1.0 project 
2. Open JPA Editor
3. Create an entity in diagram
4. Using JPA Details view change the entity mapping to 'Embeddable'
5. The entity will disappear from diagram
6. Open the embeddable class in java editor.
7. Change it's mapping back to 'Entity'
8. Drag and drop it into the diagram (see the note below)
9. Create another entity in the diagram
10. Create 1-1 bidir relation from the first entity to the second

(Note: At step 8 use the entity node shown under 'JPA Content Node' instead of the java resource node)

Result you will get the following exception in the error log:

-------------------------------------------------------------------
java.lang.IndexOutOfBoundsException: Index does not exist
	at org.eclipse.draw2d.Figure.add(Figure.java:139)
	at org.eclipse.draw2d.Figure.add(Figure.java:184)
	at org.eclipse.gef.editparts.AbstractGraphicalEditPart.addChildVisual(AbstractGraphicalEditPart.java:209)
	at org.eclipse.graphiti.ui.internal.parts.ContainerShapeEditPart.addChildVisual(ContainerShapeEditPart.java:161)
	at org.eclipse.gef.editparts.AbstractEditPart.addChild(AbstractEditPart.java:210)
	at org.eclipse.gef.editparts.AbstractEditPart.refreshChildren(AbstractEditPart.java:771)
	at org.eclipse.graphiti.ui.internal.parts.ShapeEditPart.refreshChildren(ShapeEditPart.java:626)
	at org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractEditPart.java:718)
	at org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh(AbstractGraphicalEditPart.java:633)
	at org.eclipse.graphiti.ui.internal.parts.ShapeEditPart.deleteChildAndRefresh(ShapeEditPart.java:141)
	at org.eclipse.graphiti.ui.internal.parts.PictogramElementDelegate.refreshFigureForEditPart(PictogramElementDelegate.java:337)
	at org.eclipse.graphiti.ui.internal.parts.ShapeEditPart.refreshVisuals(ShapeEditPart.java:648)
	at org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractEditPart.java:717)
	at org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh(AbstractGraphicalEditPart.java:633)
	at org.eclipse.graphiti.ui.internal.parts.ShapeEditPart.refresh(ShapeEditPart.java:546)
	at org.eclipse.graphiti.ui.internal.parts.PictogramElementDelegate.refreshEditPartsForModelChildrenAndSourceConnections(PictogramElementDelegate.java:293)
	at org.eclipse.graphiti.ui.internal.parts.ShapeEditPart.refreshChildren(ShapeEditPart.java:629)
	at org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractEditPart.java:718)
	at org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh(AbstractGraphicalEditPart.java:633)
	at org.eclipse.graphiti.ui.internal.parts.ShapeEditPart.deleteChildAndRefresh(ShapeEditPart.java:141)
	at org.eclipse.graphiti.ui.internal.parts.PictogramElementDelegate.refreshFigureForEditPart(PictogramElementDelegate.java:337)
	at org.eclipse.graphiti.ui.internal.parts.ShapeEditPart.refreshVisuals(ShapeEditPart.java:648)
	at org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractEditPart.java:717)
	at org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh(AbstractGraphicalEditPart.java:633)
	at org.eclipse.graphiti.ui.internal.parts.ShapeEditPart.refresh(ShapeEditPart.java:546)
	at org.eclipse.graphiti.ui.internal.parts.PictogramElementDelegate.refreshEditPartsForModelChildrenAndSourceConnections(PictogramElementDelegate.java:293)
	at org.eclipse.graphiti.ui.internal.parts.ShapeEditPart.refreshChildren(ShapeEditPart.java:629)
	at org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractEditPart.java:718)
	at org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh(AbstractGraphicalEditPart.java:633)
	at org.eclipse.graphiti.ui.internal.parts.ShapeEditPart.refresh(ShapeEditPart.java:546)
	at org.eclipse.graphiti.ui.internal.parts.PictogramElementDelegate.refreshEditPartsForModelChildrenAndSourceConnections(PictogramElementDelegate.java:293)
	at org.eclipse.graphiti.ui.internal.parts.ShapeEditPart.refreshChildren(ShapeEditPart.java:629)
	at org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractEditPart.java:718)
	at org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh(AbstractGraphicalEditPart.java:633)
	at org.eclipse.graphiti.ui.internal.parts.ShapeEditPart.refresh(ShapeEditPart.java:546)
	at org.eclipse.graphiti.ui.internal.parts.DiagramEditPart.refresh(DiagramEditPart.java:181)
	at org.eclipse.graphiti.ui.internal.editor.DiagramEditorInternal.internalRefreshEditPart(DiagramEditorInternal.java:1201)
	at org.eclipse.graphiti.ui.internal.editor.DiagramEditorInternal.refresh(DiagramEditorInternal.java:1285)
	at org.eclipse.graphiti.ui.internal.editor.DiagramRefreshJob.runInUIThread(DiagramRefreshJob.java:99)
	at org.eclipse.graphiti.ui.internal.editor.DiagramChangeListener.resourceSetChanged(DiagramChangeListener.java:140)
	at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl$1.run(TransactionalEditingDomainImpl.java:781)
	at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328)
	at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.postcommit(TransactionalEditingDomainImpl.java:771)
	at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.deactivate(TransactionalEditingDomainImpl.java:543)
	at org.eclipse.emf.transaction.impl.TransactionImpl.close(TransactionImpl.java:712)
	at org.eclipse.emf.transaction.impl.TransactionImpl.commit(TransactionImpl.java:474)
	at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:155)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:511)
	at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.doExecute(WorkspaceCommandStackImpl.java:208)
	at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:165)
	at org.eclipse.graphiti.ui.internal.editor.GFWorkspaceCommandStackImpl.execute(GFWorkspaceCommandStackImpl.java:47)
	at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:219)
	at org.eclipse.graphiti.ui.internal.editor.GFWorkspaceCommandStackImpl.execute(GFWorkspaceCommandStackImpl.java:39)
	at org.eclipse.jpt.ui.diagrameditor.feature.RemoveRelationFeature.remove(RemoveRelationFeature.java:78)
	at org.eclipse.jpt.ui.diagrameditor.util.JpaArtifactFactory.removeOldRelations(JpaArtifactFactory.java:2007)
	at org.eclipse.jpt.ui.diagrameditor.util.JpaArtifactFactory.remakeRelations(JpaArtifactFactory.java:1940)
	at org.eclipse.jpt.ui.diagrameditor.util.EntityChangeListener$UpdateFromModel.exec(EntityChangeListener.java:119)
	at org.eclipse.jpt.ui.diagrameditor.util.EntityChangeListener$UpdateFromModel.run(EntityChangeListener.java:104)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4041)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	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:369)
	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:619)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
-------------------------------------------------------------------
Comment 1 Stefan Dimov CLA 2010-10-21 10:30:56 EDT
I've tried to debug the issue and I've put some breakpoints in:

org.eclipse.jpt.ui.diagrameditor.provider.JPAEditorFeatureProvider

at rows: 427, 431 and 435

and when I debug, the exception never appears and diagram seems fine.
Comment 2 Stefan Dimov CLA 2010-10-21 13:07:30 EDT
Seems that the problem was on our side (JPA Editor) and I've fixed it
Comment 3 Michael Wenz CLA 2010-10-25 04:32:28 EDT
Corrected status, so that we son't find it in our list of fixed bugs for the next release.

Michael