Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 357764 - IndexOutOfBounsException when creating new ContainerShape inside existing one
Summary: IndexOutOfBounsException when creating new ContainerShape inside existing one
Status: CLOSED FIXED
Alias: None
Product: Graphiti
Classification: Modeling
Component: Core (show other bugs)
Version: 0.7.0   Edit
Hardware: All All
: P2 major (vote)
Target Milestone: 0.8.0   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard: Juno M2 Theme_bugs Indigo SR2
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-15 06:20 EDT by Elima CLA
Modified: 2012-06-28 10:39 EDT (History)
1 user (show)

See Also:
michael.wenz: indigo+
michael.wenz: juno+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Elima CLA 2011-09-15 06:20:21 EDT
ContainerShape, say Pool, is created with GFRectangleFigure, GFText (part of inactive Shape) and DecoratorImageFigure. To this, new ContainerShape, say Process Step, is added which will call addChildVisual() in AbstractGraphicalEditPart. This initializes contentPaneChilds of ContainerShapeEditPart to 3. Save on Pool will remove DecoratorImageFigure. After this whenever a new Process Step containerShape is added to the Pool, indexOutOfBoundException is thrown. 

This issue occurs because ContainerShapeEditPart stores children count (contentPaneChilds) which is never updated once error marker is removed. But this count is updated in the Figure class in GEF. So the new process step’s index which is calculated in ContainerShapeEditPart will be greater than children size in Figure class.

Below is the stack trace for the exception:

!ENTRY org.eclipse.emf.transaction 4 45 2011-09-14 09:48:03.017
!MESSAGE Uncaught exception during post-commit listener notifications
!STACK 0
java.lang.IndexOutOfBoundsException: Index does not exist
	at org.eclipse.draw2d.Figure.add(Figure.java:137)
	at org.eclipse.draw2d.Figure.add(Figure.java:179)
	at org.eclipse.gef.editparts.AbstractGraphicalEditPart.addChildVisual(AbstractGraphicalEditPart.java:205)
	at org.eclipse.graphiti.ui.internal.parts.ContainerShapeEditPart.addChildVisual(ContainerShapeEditPart.java:161)
	at org.eclipse.gef.editparts.AbstractEditPart.addChild(AbstractEditPart.java:197)
	at org.eclipse.gef.editparts.AbstractEditPart.refreshChildren(AbstractEditPart.java:727)
	at org.eclipse.graphiti.ui.internal.parts.ShapeEditPart.refreshChildren(ShapeEditPart.java:626)
	at org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractEditPart.java:677)
	at org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh(AbstractGraphicalEditPart.java:571)
	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:677)
	at org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh(AbstractGraphicalEditPart.java:571)
	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:1203)
	at org.eclipse.graphiti.ui.internal.editor.DiagramEditorInternal.refresh(DiagramEditorInternal.java:1287)
	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 com.sap.bpl.util.BPLWorkspaceCommandStackImpl.execute(BPLWorkspaceCommandStackImpl.java:59)
	at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:219)
	at com.sap.bpl.util.BPLWorkspaceCommandStackImpl.execute(BPLWorkspaceCommandStackImpl.java:34)
	at org.eclipse.graphiti.ui.internal.editor.GFCommandStack.execute(GFCommandStack.java:108)
	at org.eclipse.gef.tools.AbstractTool.executeCommand(AbstractTool.java:399)
	at org.eclipse.gef.tools.AbstractTool.executeCurrentCommand(AbstractTool.java:411)
	at org.eclipse.gef.tools.CreationTool.performCreation(CreationTool.java:254)
	at org.eclipse.gef.tools.CreationTool.handleButtonUp(CreationTool.java:178)
	at org.eclipse.gef.tools.AbstractTool.mouseUp(AbstractTool.java:1064)
	at org.eclipse.gef.EditDomain.mouseUp(EditDomain.java:263)
	at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouseReleased(DomainEventDispatcher.java:374)
	at org.eclipse.draw2d.LightweightSystem$EventHandler.mouseUp(LightweightSystem.java:538)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:207)
	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:3910)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3503)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
Comment 1 Michael Wenz CLA 2011-09-15 07:01:12 EDT
Requestor is CPL, relevant for 0.7 track
Comment 2 Michael Wenz CLA 2011-09-21 09:32:54 EDT
The issue occurs when a shape already has a decorator when children are added. In this case the offset is calculated wrong (takes the decorator also in account). The fix is to calculate the offset before any children are added.

Fixed in head with
commit 029327db60f55a9409814c7f8cabb26c5e3bd86d
Author: mgorning <matthias.gorning@sap.com> 2011-09-21 15:14:04
Committer: mgorning <matthias.gorning@sap.com> 2011-09-21 15:14:04
Parent: 6a34f78d70f6cf335f49a23dbf5fd237d63b646b (.)
Branches: origin/master, master
Comment 3 Michael Wenz CLA 2011-09-21 09:34:59 EDT
Downported the fix to the 0.8 stream (targeting for Indigo SR2):
commit 981017ed972c09ac31129e327f643c9303e739d7
Author: mgorning <matthias.gorning@sap.com> 2011-09-21 15:14:04
Committer: mwenz <michael.wenz@sap.com> 2011-09-21 15:18:50
Parent: 60416b671042a808605cd52571127b50f046dd8e (Updates News&Noteworthy)
Branches: origin/b0_8_x, b0_8_x
Comment 4 Michael Wenz CLA 2011-09-21 10:43:28 EDT
Downported the fix to the 0.7.x track (targeting for 0.7.3):
commit 20071569801e9b9d49980192cc373685287644e4
Author: mgorning <matthias.gorning@sap.com> 2011-09-21 15:14:04
Committer: mwenz <michael.wenz@sap.com> 2011-09-21 15:49:53
Parent: 4e2eb2da74c71c5dff7fdde15cc328804dd78b39 (Updated versions to 0.7.2)
Branches: origin/b0_7_0, b0_7_0
Comment 5 Michael Wenz CLA 2011-09-23 07:57:20 EDT
Issue has been fixed through all codelines
Comment 6 Michael Wenz CLA 2011-09-23 08:04:22 EDT
Fix was checked by CPL
Comment 7 Michael Wenz CLA 2012-04-11 10:31:33 EDT
Bookkeeping: Set target release: 0.8.1
Comment 8 Michael Wenz CLA 2012-06-28 10:39:56 EDT
Part of Graphiti 0.9.0 (Eclipse Juno)