DefaultRemoveFeature.removeAllConnections() with nested shapes? [message #873634] |
Fri, 18 May 2012 18:14 |
Hernan Gonzalez Messages: 188 Registered: October 2010 Location: Buenos Aires, Argentina |
Senior Member |
|
|
I'm not sure if this is a bug:
The DefaultRemoveFeature class, when applied to a Shape, before removing the PictogramElement pe, tries to remove all connections :
if (pe instanceof Shape) {
Shape shape = (Shape) pe;
removeAllConnections(shape);
} else if (pe instanceof AdvancedAnchor) {
removeAllConnections((AdvancedAnchor) pe);
}
...
protected void removeAllConnections(Shape shape) {
List<Anchor> anchors = shape.getAnchors();
for (Anchor anchor : anchors) {
removeAllConnections(anchor);
}
}
But ... what if my shape contains other shapes and the anchors are inside those inner shapes? This seems to be broken to me, perhaps one need a recursive removeAllConnections() ? I actually had to extend RemoveFeature and override the method to make it work for me:
@Override
protected void removeAllConnections(Shape shape) {
// recursive!
if(shape instanceof ContainerShape) {
for (Shape innerShape : ((ContainerShape)shape).getChildren()) {
removeAllConnections(innerShape);
}
}
List<Anchor> anchors = shape.getAnchors();
for (Anchor anchor : anchors) {
removeAllConnections(anchor);
}
}
Should I fill a bug?
[Updated on: Mon, 21 May 2012 16:12] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04306 seconds