Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Dropping Shape onto Connection
Dropping Shape onto Connection [message #1744259] Fri, 23 September 2016 16:13 Go to next message
Alex Kravets is currently offline Alex KravetsFriend
Messages: 561
Registered: November 2009
Senior Member
I am implementing a diagram where a an object from palette can be dropped onto a connection and the connection would change its start and end values accordingly:

A -> Z --- object drop --- A -> B -> Z

To do this I am getting the targetConnection onto which object is being dropped and change end of connection1 to B and then create new Connection from B to Z. This works on first drop. But if I try to drop another object onto connection A -> B then all connections are going haywire. Looks like end and start values of targetConnection are not being updated correctly.

Here is my code:

public PictogramElement add(IAddContext context) {
                 // add object
                 ...
                 ...
                 updateConnection(context, containerShape)
}

private void updateConnection(IAddContext context, ContainerShape containerShape) {
		Connection targetConnection = context.getTargetConnection();
		Anchor end = targetConnection.getEnd();
		targetConnection.setEnd(containerShape.getAnchors().get(0));
		
		AddConnectionContext addConnectionContext = new AddConnectionContext(containerShape.getAnchors().get(0), end);
		IAddFeature addFeature = getFeatureProvider().getAddFeature(addConnectionContext);
		addFeature.execute(addConnectionContext);
		layoutPictogramElement(containerShape);
	}


What am I doing wrong here?

Thanks,
Alex
Re: Dropping Shape onto Connection [message #1744495 is a reply to message #1744259] Tue, 27 September 2016 12:47 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Alex,

not sure what is done inside your add feature. There is a working example (I just tried to iteratively drop a shape onto connections there) in our Sketch test tool. The corresponding move feature can be found here:
http://git.eclipse.org/c/graphiti/org.eclipse.graphiti.git/tree/tests/org.eclipse.graphiti.testtool.sketch/src/org/eclipse/graphiti/testtool/sketch/features/SketchMoveShapeFeature.java

It directly add the new connection in the move feature, which is not that clean as well...

HTH,
Michael
Re: Dropping Shape onto Connection [message #1744504 is a reply to message #1744495] Tue, 27 September 2016 14:00 Go to previous messageGo to next message
Alex Kravets is currently offline Alex KravetsFriend
Messages: 561
Registered: November 2009
Senior Member
Thanks Michael
Re: Dropping Shape onto Connection [message #1746999 is a reply to message #1744259] Tue, 08 November 2016 12:51 Go to previous messageGo to next message
Proutprout Canard is currently offline Proutprout CanardFriend
Messages: 3
Registered: November 2016
Junior Member
Have you achieved to drop an element onto an existing connection? I am facing the same issue. Even if the code provided by Michael is useful, it doesn't work in my case.
Re: Dropping Shape onto Connection [message #1747013 is a reply to message #1746999] Tue, 08 November 2016 15:01 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Philippe,

can you provide more details on what is different in your case?

Michael
Re: Dropping Shape onto Connection [message #1747014 is a reply to message #1747013] Tue, 08 November 2016 15:04 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Sorry, I just saw that you have posted a new question.

Michael
Previous Topic:delete it
Next Topic:Update diagram when drag and drop
Goto Forum:
  


Current Time: Tue Mar 19 06:49:12 GMT 2024

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

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

Back to the top