Community
Participate
Working Groups
Build Identifier: When a nested GA (GraphicAlgorithm) is added to an Anchor in runtime, sometimes the GEF objects are not correctly created. Reproducible: Always Steps to Reproduce: 1. In the tutorial, modify the TutorialRenameEClassFeature so that, in adition of the name change a circle is added to the BoxRelativeAnchor (code below) under some condition 2. The circle is added to the Diagram (can be seen in the saved diagram), but is not displayed. The editpart is not added. The editor internal listener is notified, PictogramElementDelegate.createFigureForGraphicsAlgorithm() is not reached. 3. Instead, if the circle is added to the ContainerShape of the EClass, it works ok
Here's my code for TutorialRenameEClassFeature: in this example, we add the circle when the new name has a trailing 'X' (and the original hadn't it), and viceversa. in execute() add the line: this.hasDoneChanges = true; addRemoveCircle((Shape) pes[0], newName, currentName); eClass.setName(newName); updatePictogramElement(pes[0]); and the method: private void addRemoveCircle(Shape pes, String newname, String oldname) { if (newname == null || oldname == null) return; boolean useanchor = true; GraphicsAlgorithm ga = useanchor ? pes.getAnchors().get(1).getGraphicsAlgorithm() : pes.getGraphicsAlgorithm(); int r = 2; if (newname.endsWith("X") && !oldname.endsWith("X")) { // add Ellipse c = Graphiti.getGaCreateService().createEllipse(ga); Graphiti.getGaService().setLocationAndSize(c, ga.getWidth() / 2 - r, ga.getHeight() / 2 - r, r * 2, r * 2); c.setFilled(true); } if (oldname.endsWith("X") && !newname.endsWith("X")) { // remove Ellipse c = null; for (GraphicsAlgorithm ga2 : ga.getGraphicsAlgorithmChildren()) { if (ga2 instanceof Ellipse) c = (Ellipse) ga2; } System.err.println("removing circle " + c); if (c != null) ga.getGraphicsAlgorithmChildren().remove(c); } }
I tried to debug the issue, but got tired. There are lots of if(pe instanceof Shape) { } if(pe instanceof Anchor) { } and similar, see PictogramElementDelegate.refreshFigureForEditPart() for example, and I'm not sure about the correcteness of all these. For example, I'm not sure why there seems to be more intensive digging of Shapes than for Anchors (when one tries to create/recrete/update related Figures/Edit parts of the children GA). Perhaps originally the Anchor was conceived to not include nested GAs? (There was recently other related bug, this about positioning). If this is so, perhaps it would be better to disallow or discourage the use of nested GA in Anchors ?
Fixed. commit 13fec4416024403bdf457bdace7a8831fd1608f4 Author: mgorning <matthias.gorning@sap.com> 2011-11-17 12:16:38 Committer: mgorning <matthias.gorning@sap.com> 2011-11-17 12:16:38 Parent: 462a61237ec1f28dbf71817ef5a67a38950db420 (Bug 363229 - Nested GA inside Anchors are not correctly refreshed / refresh corrected for BoxRelativeAnchor's; inner ga's now have the correct location) Child: 8936aee9e7f7924e8b7c1c67757e6df90a6c24b6 (Bug 363229 - Nested GA inside Anchors are not correctly refreshed / comments) Branches: origin/master, master
Looks good to me
Bookkeeping: Set target release
Part of Graphiti 0.9.0 (Eclipse Juno)