Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Add link (contained by canvas element) between two nodes not contained by canvas element
Add link (contained by canvas element) between two nodes not contained by canvas element [message #549654] Tue, 27 July 2010 13:33 Go to next message
David is currently offline DavidFriend
Messages: 2
Registered: July 2010
Junior Member
Hello

I am having problems with a gmf graphical editor: I need to define a link between two nodes which represent objects contained by objects other than the canvas object (which contains the links).

It is easier to explain with a simplified example; my models are

Model 1
Class SourceNode
Class SourceNodeContainer [nodes:SourceNode containment=true]
(i.e. two classes, SourceNodeContainer contains SourceNodes)

Model 2
Class TargetNode
Class TargetNodeContainer [nodes:TargetNode containment=true]
(i.e. again two classes, TargetNodeContainer contains TargetNodes)

Model 3
Class Arc [source:SourceNode, target:TargetNode]
Class ArcContainer [arcs:Arc containment=true]
(i.e. again two classes, ArcContainer contains Arc)


ArcContainer is the Canvas element in my gmfmap; I can display SourceNode and TargetNode objects by creating shortcuts to them (they have their own editors and must be kept as separate models). If I represent Arc as a node with two links (one each for source and target properties), it works fine; however I require to represent Arc as a single link (similar to the Relationship class in the MindMap tutorial example - http://wiki.eclipse.org/GMF_Tutorial_Part_2), however when using the generated editor, I select the Arc tool and hover over the source node but am unable to start creating the link (the crossed out circle cursor remains).

I think I have traced this problem to the edit.commands.ArcCreateCommand which is unable to get the correct container (it gets the container of the source, which is of course a SourceNodeContainer not a ArcContainer); can any one tell me how to get the ArcContainer object and add the link to it and the diagram?

Many thanks in advance for any advice you can provide.

David
Re: Add link (contained by canvas element) between two nodes not contained by canvas element [message #550510 is a reply to message #549654] Fri, 30 July 2010 15:24 Go to previous message
David is currently offline DavidFriend
Messages: 2
Registered: July 2010
Junior Member
Hi,

So I seem to have found a way around this by altering the deduceContainer method of the ArcCreateCommand, adding a parameter, ArcCreateCommand obj, and adding the following to the method body:

EObject o = obj.getEditingDomain().getResourceSet().getResources().get(1 ).getContents().get(0);
if (o instanceof ArcContainer){
return (ArcContainer) o;
}

Bit of a hack perhaps, but it works Smile
Previous Topic:Solution: alternative label attribute
Next Topic:Help with using ChangePropertyValueRequest
Goto Forum:
  


Current Time: Thu Jun 13 22:31:36 GMT 2024

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

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

Back to the top