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 14:14 Go to next message
Hernan Gonzalez is currently offline Hernan Gonzalez
Messages: 180
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 12:12]

Report message to a moderator

Re: DefaultRemoveFeature.removeAllConnections() with nested shapes? [message #875117 is a reply to message #873634] Tue, 22 May 2012 03:13 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1574
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 12:18 Go to previous messageGo to next message
Hernan Gonzalez is currently offline Hernan Gonzalez
Messages: 180
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 09:36 Go to previous message
Matthias Gorning is currently offline Matthias Gorning
Messages: 80
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: Tue Jul 29 08:45:59 EDT 2014

Powered by FUDForum. Page generated in 0.03029 seconds