Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Possible bug with BoxRelativeAnchor
Possible bug with BoxRelativeAnchor [message #1385329] Thu, 05 June 2014 16:22 Go to next message
Simone Di Cola is currently offline Simone Di ColaFriend
Messages: 60
Registered: February 2014
Member
Hi all,
I think there is a bug within the class CreateConnectionCommand, package org.eclipse.graphiti.ui.internal.command

In particular, having a shape with a BoxRelativeAnchor, every time I click on it in order to drag and drop a connection without using the palette, the connectionContext contains the following info:

CreateConnectionContext sourceAnchor: org.eclipse.graphiti.mm.pictograms.impl.BoxRelativeAnchorImpl@85091a (visible: true, active: true) (useAnchorLocationAsConnectionEndpoint: false) (relativeWidth: 0.5, relativeHeight: 1.0) targetAnchor: null sourcePictogramElement: org.eclipse.graphiti.mm.pictograms.impl.BoxRelativeAnchorImpl@85091a (visible: true, active: true) (useAnchorLocationAsConnectionEndpoint: false) (relativeWidth: 0.5, relativeHeight: 1.0)


in paricular what is wrong is the sourcePictogramElement section. Indeed, it should be the AnchorContainer, and not the anchor itself.

Finally, the method

public boolean canStartConnection() {
		// allow connections only from anchor to anchor

		CreateConnectionContext connectionContext = createContext();
		sourceLocation = connectionContext.getSourceLocation(); // store
																// location for
																// later usage

		for (IFeature feature : features) {

			if (feature instanceof ICreateConnectionFeature) {
				ICreateConnectionFeature ccf = (ICreateConnectionFeature) feature;
				if (ccf.canStartConnection(connectionContext)) {
					return true;
				}
			} else
				return true;
		}

		return false;
	}


when it tries to call anStartConnection(connectionContext) always retrun false (correct).

Am I missing something, or is this a bug?

Thanks
Simone
Re: Possible bug with BoxRelativeAnchor [message #1385330 is a reply to message #1385329] Thu, 05 June 2014 16:29 Go to previous messageGo to next message
Simone Di Cola is currently offline Simone Di ColaFriend
Messages: 60
Registered: February 2014
Member
In particular, I think the problem can be easily solved modifing the constructor:

/**
	 * Instantiate a command that can create a connection between two anchors.
	 * 
	 * @param source
	 *            the source endpoint (a non-null Shape instance)
	 * @param lineStyle
	 *            the desired line style. See Connection#setLineStyle(int) for
	 *            details
	 * @throws IllegalArgumentException
	 *             if source is null
	 * @see Connection#setLineStyle(int)
	 */
	public CreateConnectionCommand(IConfigurationProvider configurationProvider, PictogramElement pe,
			List<IFeature> features) {
		super(configurationProvider);
		setLabel(Messages.CreateConnectionCommand_0_xmsg);

		this.features = features;
		this.sourceObject = pe;  //<------- FIX HERE 
	}


Indeed, pe can be even a BoxRelativeAnchor, and since it is a PictogramElement there are no problems for Java (but a lot for me Smile )
Re: Possible bug with BoxRelativeAnchor [message #1385820 is a reply to message #1385329] Wed, 11 June 2014 12:02 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Simone,

not sure...

What does the metod createContext() do? It seems to fill the
connectionContext you are using afterwards. And what are the features list
you are looping over?

Usually I would have expected that the create connection context passed to
the canStartConnection method should contain the necessary information, e.g.
the shape you can start to search for the anchor to use.

Michael
Previous Topic:[Spray] Problem with anchors
Next Topic:Draw Matrix in Graphiti
Goto Forum:
  


Current Time: Sat Apr 20 00:50:54 GMT 2024

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

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

Back to the top