Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » "Copy" bendpoints into another FreeFormConnection
"Copy" bendpoints into another FreeFormConnection [message #1319639] Mon, 28 April 2014 05:44 Go to next message
Soeren M is currently offline Soeren M
Messages: 77
Registered: September 2011
Member
Hey all,

I came across a behaviour I've never noticed before.

If I create a FreeFormConnection and add the bendpoints from another FreeFormConnection into it, the bendpoints from the first one are deleted afterwards.

AddConnectionContext addContext = new AddConnectionContext(start, end);
FreeFormConnection newCon = (FreeFormConnection) getFeatureProvider().addIfPossible(addContext);

FreeFormConnection tc = (FreeFormConnection) c;
System.out.println(tc.getBendpoints().size()); //returns 2
newCon.getBendpoints().addAll(tc.getBendpoints());
System.out.println(tc.getBendpoints().size()); //returns 0


Am I doing something wrong?

[Updated on: Mon, 28 April 2014 05:46]

Report message to a moderator

Re: "Copy" bendpoints into another FreeFormConnection [message #1327771 is a reply to message #1319639] Fri, 02 May 2014 06:28 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard Traetteberg
Messages: 594
Registered: July 2009
Location: Trondheim, Norway
Senior Member
This typically happens when copying references to contained objects.
Since en EObject can only be contained in one container, such a copy
becomes a move. Use EcoreUtil.copy to create a deep copy and add the
copies instead.

On 28.04.14 11:44, Soeren M wrote:
> Hey all,
>
> I came across a behaviour I've never noticed before.
>
> If I create a FreeFormConnection and add the bendpoints from another
> FreeFormConnection into it, the bendpoints from the first one are
> deleted afterwards.
>
>
> AddConnectionContext addContext = new AddConnectionContext(start, end);
> FreeFormConnection newCon = (FreeFormConnection)
> getFeatureProvider().addIfPossible(addContext);
>
> FreeFormConnection tc = (FreeFormConnection) c;
> System.out.println(tc.getBendpoints().size());
> newCon.getBendpoints().addAll(tc.getBendpoints());
> System.out.println(tc.getBendpoints().size());
>
>
> Am I doing something wrong?
Re: "Copy" bendpoints into another FreeFormConnection [message #1327941 is a reply to message #1327771] Fri, 02 May 2014 08:20 Go to previous message
Soeren M is currently offline Soeren M
Messages: 77
Registered: September 2011
Member
Hi Hallvard, thank you very much for the explanation Smile
Previous Topic:Displaying Images
Next Topic:Double-click palette entry
Goto Forum:
  


Current Time: Tue Jul 29 10:54:39 EDT 2014

Powered by FUDForum. Page generated in 0.05709 seconds