| Summary: | Nested GA inside Anchors are not correctly refreshed | ||
|---|---|---|---|
| Product: | [Modeling] Graphiti | Reporter: | Hernan Gonzalez <hjg.com.ar> |
| Component: | Core | Assignee: | Matthias Gorning <matthias.gorning> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | matthias.gorning, michael.wenz |
| Version: | 0.8.0 | Flags: | matthias.gorning:
juno+
|
| Target Milestone: | 0.9.0 | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | Juno M4 Theme_bugs | ||
|
Description
Hernan Gonzalez
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) |