Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to connect two nodes that are not contained in the connection container
How to connect two nodes that are not contained in the connection container [message #793745] Wed, 08 February 2012 14:05 Go to next message
Iban Ayestaran is currently offline Iban AyestaranFriend
Messages: 58
Registered: September 2011
Member
Hi everybody,

In my ecore model, I have some 'modes', 'tasks' and 'connections'. Modes and tasks are contained by the root, and connections are contained by modes (as seen in the attached figure). There is also a bi-directional reference between Modes and Tasks. Mutants and tasks are nodes, and connections are links.

My problem is that as tasks do not belong to modes whereas connections do so, the tool does not allow me to draw a connection between tasks. In fact, when I click the 'connection' tool in the palette and I try to click in the task to draw the line, a prohibition symbol appears, so I cannot draw it.

What I would like is to be able to draw a connection between to tasks, and that the connection should be contained by the mode the task refers to (as you see in the figure, a task can only refer to one mode).

Does anybody know how to solve my problem??

Thanks a lot in advance,

Iban
  • Attachment: Ecore.png
    (Size: 7.20KB, Downloaded 195 times)
Re: How to connect two nodes that are not contained in the connection container [message #795345 is a reply to message #793745] Fri, 10 February 2012 11:07 Go to previous messageGo to next message
Michael Golubev is currently offline Michael GolubevFriend
Messages: 383
Registered: July 2009
Senior Member
Hello,

Your use case, in particular an additional logic of determining the container for just created link, can't be handled in GMF-T without @generated NOT code.

In your generated XXXConnectionCreateCommand, you should have method similar to this (code from ReliableRouteCreateCommand from TaiPan sample):
/**
 * Default approach is to traverse ancestors of the source to find instance of container.
 * Modify with appropriate logic.
 * @generated
 */
private static Aquatory deduceContainer(EObject source, EObject target) {
	// Find container element for the new link.
	// Climb up by containment hierarchy starting from the source
	// and return the first element that is instance of the container class.
	for (EObject element = source; element != null; element = element.eContainer()) {
		if (element instanceof Aquatory) {
			return (Aquatory) element;
		}
	}
	return null;
}


I guess that in the default generated version this method actually returns null so the creation is prohibited. Just change it according to your logic, and it should be fine. If not, debug using the breakpoint in the XXXConnectionCreateCommand #canExecute to see what goes wrong.

Also you probably will find usefull to change the XXXConnectionRerouteCommand in order to maintain the container logic after reroutes.

Regards,
Michael "Borlander" Golubev
at Montages Think Tank, Prague, Czech Republic
Montages AG, Zürich, Switzerland
Re: How to connect two nodes that are not contained in the connection container [message #795516 is a reply to message #795345] Fri, 10 February 2012 15:07 Go to previous message
Iban Ayestaran is currently offline Iban AyestaranFriend
Messages: 58
Registered: September 2011
Member
Thanks Michael!! I think I could achieve it that way, I will try.

[Updated on: Fri, 10 February 2012 15:08]

Report message to a moderator

Previous Topic:Issue with ViewService.createEdge()
Next Topic:How to download GMF plugins for solaris
Goto Forum:
  


Current Time: Fri Apr 26 10:06:34 GMT 2024

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

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

Back to the top