Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Using CreateConnectionCommand(Connection not draw for fixed point anchors)
Using CreateConnectionCommand [message #759798] Wed, 30 November 2011 06:27 Go to next message
samim  is currently offline samim
Messages: 7
Registered: August 2011
Junior Member
Hi,

I am using pallets to drag and drop different shapes. As soon as I drop the shape I create fixed point anchors on them.Then when ever user hover over the shape I give him the option to create connection to another shape. When I try to drag and drop connection to another shape the execute method of the CreateConnectionCommand class is called.In the execute method the first two lines are

Anchor sourceAnchor = getAnchor(sourceObject);
Anchor targetAnchor = getAnchor(targetObject);

Below is the getAnchor(sourceObject) method.

private Anchor getAnchor(PictogramElement pe) {
Anchor ret = null;
if (pe instanceof Anchor) {
ret = (Anchor) pe;
} else if (pe instanceof AnchorContainer) {
ret = Graphiti.getPeService().getChopboxAnchor((AnchorContainer) pe);
}
return ret;
}

As you can see if the user tries to drop the connection on the shape then it tries to get the ChopBox anchor only but in my case its Fixed point anchor so I fail to create connections.I am able to create connections only with chop box anchor.But in my use case i need fixed point anchors.

Is this a bug? or there is any way to over come the limitation?
Re: Using CreateConnectionCommand [message #759823 is a reply to message #759798] Wed, 30 November 2011 08:39 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1625
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hi,

actually in case of a FixPointAnchor (or BoxRelativeAnchor) the pe passed to
the getAnchor method will be the anchor itself, that's the intention behind
the coding. ChopboxAnchors are a kind of "shortcut" for standard situations
where you need no special behaviour or representation of your anchors;
therefor they get some special handling in that method.

To get an understanding of how that drag&drop connection creation works have
a look at the TutorialCreateEReferenceFeature that can handle both the
normal connection creation but also the drag&drop case.

HTH,
Michael
Re: Using CreateConnectionCommand [message #760040 is a reply to message #759823] Thu, 01 December 2011 04:41 Go to previous messageGo to next message
samim  is currently offline samim
Messages: 7
Registered: August 2011
Junior Member
Hi Michael,

I want the user to drop the connection on the shape.So the pe in this case would be a ContainerShape and not an Anchor. I don't want user to search for the anchor and drop on it.

Regards
Samim
Re: Using CreateConnectionCommand [message #760071 is a reply to message #760040] Thu, 01 December 2011 08:45 Go to previous message
Michael Wenz is currently offline Michael Wenz
Messages: 1625
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Ah, you mean the target side.

In case you have several anchors on your target and you want to allow the
user to drop on anything you will need to change the target anchor in the
create method of your feature to the one you want to connect to (you will
need to cast the context to CreateConnectionContext to be able to call
setTargetAnchor).

HTH,
Michael
Previous Topic:Selection info for shape
Next Topic:Ellipsis shown in Text when using BoxRelativeAnchor
Goto Forum:
  


Current Time: Fri Oct 31 19:19:07 GMT 2014

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

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