Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » DefaultRemoveFeature.removeAllConnections() with nested shapes?
DefaultRemoveFeature.removeAllConnections() with nested shapes? [message #873634] Fri, 18 May 2012 18:14 Go to next message
Hernan Gonzalez is currently offline Hernan GonzalezFriend
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

Re: DefaultRemoveFeature.removeAllConnections() with nested shapes? [message #875117 is a reply to message #873634] Tue, 22 May 2012 07:13 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Right, that seems to be a gap. Would you please open a bugzilla for this?

Thanks,
Michael
Re: DefaultRemoveFeature.removeAllConnections() with nested shapes? [message #875964 is a reply to message #875117] Wed, 23 May 2012 16:18 Go to previous messageGo to next message
Hernan Gonzalez is currently offline Hernan GonzalezFriend
Messages: 188
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
Done
https://bugs.eclipse.org/bugs/show_bug.cgi?id=380439
Re: DefaultRemoveFeature.removeAllConnections() with nested shapes? [message #900789 is a reply to message #875964] Wed, 08 August 2012 13:36 Go to previous message
Matthias Gorning is currently offline Matthias GorningFriend
Messages: 81
Registered: April 2010
Location: Germany
Member
Bug was fixed in master branch.

commit 04a837c5fb14465311c2accfab147734829c7541
Previous Topic:[Solved] MultiPageEditor with multiple Diagrams from same Resource
Next Topic:The slide can not be found
Goto Forum:
  


Current Time: Sat Apr 20 15:08:06 GMT 2024

Powered by FUDForum. Page generated in 0.04306 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top