Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Disable a connection
Disable a connection [message #1670770] Fri, 13 March 2015 10:29 Go to next message
Jerome S. is currently offline Jerome S.Friend
Messages: 9
Registered: March 2015
Junior Member
Hello Graphiti team,

I am implementing a Graphiti-based application aimed at viewing EMF objects. For this application I have drawn several shapes and I would like to connect some of them using FreeFormConnection(s).

This part is done but I would like to set the connections as "inactive", so that the user can't select them and modify them. If that is not possible I would like to disable the possibility to move the elements of the connection, and also disable the "automatic creation" of bendpoints when selecting the connection and moving it around.

How can I do that? I have tried:

  • connection.setActive(false) -> doesn't appear to do anything
  • Override getMoveBendpointFeature() -> I can't move the bendpoints already existing but I can create new ones and destroy the original FreeForm shape
  • Override getUpdateFeature() -> doesn't appear to do anything


Here is my code to create the FreeFormConnection :
FreeFormConnection connection = peCreateService.createFreeFormConnection(diagram);
gaService.createPolyline(connection);
connection.setStart(sourceAnchor);
connection.setEnd(targetAnchor);


Thanks for any help Smile.
Re: Disable a connection [message #1681347 is a reply to message #1670770] Tue, 17 March 2015 09:15 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1898
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Jerome,

the inactive flag for connections is not supported. The main focus of
inactive is not spanning a coordinate systen for a shape, which does not
make sense for a connection.

The features are the right way to go: providing your own subclass of
DefaultMoveBendpointFeature can prevent dragging of existing bendpoints.
Besides there is a DefaultAddBendpointFeature that can be adapted to prevent
creation of new bendpoints; that seems to be the missing part for you.

Michael
Re: Disable a connection [message #1681404 is a reply to message #1681347] Tue, 17 March 2015 09:46 Go to previous message
Jerome S. is currently offline Jerome S.Friend
Messages: 9
Registered: March 2015
Junior Member
Dear Michael,

Thanks for this quick and precise reply ! Actually it was really easy to implement. Here are the relevant pieces of code.

public class AddBendpointFeature extends DefaultAddBendpointFeature {

	public AddBendpointFeature(IFeatureProvider fp) {
		super(fp);
	}

	@Override
	public boolean canAddBendpoint(IAddBendpointContext context) {
		return false;
	}

	@Override
	public boolean canExecute(IContext context) {
		if (context instanceof IAddBendpointContext) {
			return canAddBendpoint((IAddBendpointContext) context);
		}
		return false;
	}
}


public class MoveBendpointFeature extends DefaultMoveBendpointFeature {
	
	public MoveBendpointFeature(IFeatureProvider fp) {
		super(fp);
	}

	@Override
	public boolean canMoveBendpoint(IMoveBendpointContext context) {
		return false;
	}

	@Override
	public boolean canExecute(IContext context) {
		if (context instanceof IMoveBendpointContext) {
			return canMoveBendpoint((IMoveBendpointContext) context);
		}
		return false;
	}
}


 (... in the FeatureProvider ...)

@Override
public IMoveBendpointFeature getMoveBendpointFeature(IMoveBendpointContext context) {
	return new MoveBendpointFeature(this);
}

@Override
public IAddBendpointFeature getAddBendpointFeature(IAddBendpointContext context) {
	return new AddBendpointFeature(this);
}


Best regards,
Jérôme

[Updated on: Wed, 18 March 2015 09:10]

Report message to a moderator

Previous Topic:SWTBot test
Next Topic:Delete Parent Container shape if Child Shapes are deleted
Goto Forum:
  


Current Time: Tue Sep 25 12:36:29 GMT 2018

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

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

Back to the top