I have an ZZZAddShapeFeature that creates several shapes, the add() method works well when I create all the shapes with a single ContainerShape as parent (as in the tutorial). I tried to group some of the shapes by placing them inside another ContainerShape. Basically:

This gives me some strange NPE, deep inside Draw2D (the stack trace does not include my own classes). As I point out in the code, this works ok if I uncomment the other line, i.e. if I create the shapes with the main container as parent.
I'm using Eclipse 3.6.2, EMF 2.6.1 Graphiti 0.8.0

!ENTRY org.eclipse.graphiti 4 0 2011-08-10 15:09:20.898
!MESSAGE refresh edit part problem
!STACK 0
java.lang.NullPointerException
at org.eclipse.draw2d.Figure.add(Figure.java:148)
at org.eclipse.draw2d.Figure.add(Figure.java:174)
at org.eclipse.graphiti.ui.internal.parts.PictogramElementDelegate.createFigureForPictogramElement(PictogramElementDelegate.java:827)
at org.eclipse.graphiti.ui.internal.parts.PictogramElementDelegate.createFigure(PictogramElementDelegate.java:188)
at org.eclipse.graphiti.ui.internal.parts.ShapeEditPart.createFigure(ShapeEditPart.java:621)
at org.eclipse.graphiti.ui.internal.parts.ContainerShapeEditPart.createFigure(ContainerShapeEditPart.java:98)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.getFigure(AbstractGraphicalEditPart.java:494)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.addChildVisual(AbstractGraphicalEditPart.java:208)
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:773)
at org.eclipse.graphiti.ui.internal.parts.ShapeEditPart.refreshChildren(ShapeEditPart.java:632)
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:552)
at org.eclipse.graphiti.ui.internal.parts.DiagramEditPart.refresh(DiagramEditPart.java:183)
at org.eclipse.graphiti.ui.internal.editor.DiagramEditorInternal.internalRefreshEditPart(DiagramEditorInternal.java:1246)
at org.eclipse.graphiti.ui.internal.editor.DiagramEditorInternal.refresh(DiagramEditorInternal.java:1330)
...

Update: I can reproduce the NPE in the tutorial code, just by adding a dummy containerShape creation in TutorialAddEClassFeature:

i suspect the rendering engine is looking for a GA for your containershape.
what happens if you equip the second containershape with a graphics algorithm?
Does the NPE persist?

Best, Tim

Aha, it seems to work... I'm still warping my mind over the pictogram concepts (thanks Kieler for that graph, it's very useful), it took me some time to getting used at the idea that "a Rectangle is not a Shape", for example

My first idea was: a Shape (in general: a PictogramElement) can contain a Rectangle (in general: a GraphicAlgorithm=GA). And a ContainerShape can contain other Shapes - and besides (because it's a Shape) can contain a GA.

But now, it seems that a Shape not only can but MUST contain a GA; also if it's a ContainerShape, even if it's used only to group other shapes (with their own GAs) (right?).

Ok. It seemed to me a superabundance of Shapes and GA at first sight (for each Shape a GA, and viceversa?) ... but then I came to realize that a Rectangle (a GA) must not necesarily be included in its own Shape, but in a "GAContainer" (can be a Pictogram element, but also a GA!). One should create a Shape for a GA only when that's needed.

But, then, I'm thinking that the tutorial does not make this concept clear, and that in that diagram it would be much more reasonable (both didactically and practically) to NOT create a Shape for the horizontal line, it should be created with the 'roundedRectangle' as container. Do you agree?

think of PEs (Pictogram Elements) and GAs (Graphic Algorithms) as of two distinct worlds.
PEs are used for linking business objects an for defining the containment hierarchy
and also for defining the elements which are selectable and can be manipulated via mouse gestures.
GAs are just about what pixels are spit on the screen.
GAs are linked to PEs. Both, PES and GAs, have there own containment hierarchies...etc
I agree, it is really something to warp the mind....

But you are right, there should be a section in the tutorial exactly describing
the extents and relationship between the two concepts.
Please open a bugzilla to request a respective extra page in the tutorial.

I really would be interested in seeing the object graph mentionned in Hernan latest message, by it is too small a png. Where can I get a large picture please, this PE and GA hierarchy is a bit confusing.

I really would be interested in seeing the object graph mentionned in Hernan
latest message, by it is too small a png. Where can I get a large picture
please, this PE and GA hierarchy is a bit confusing.