Skip to main content


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 09:44 Go to next message
Soeren M is currently offline Soeren MFriend
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 09:46]

Report message to a moderator

Re: "Copy" bendpoints into another FreeFormConnection [message #1327771 is a reply to message #1319639] Fri, 02 May 2014 10:28 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
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 12:20 Go to previous message
Soeren M is currently offline Soeren MFriend
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: Thu Apr 25 13:34:20 GMT 2024

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

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

Back to the top