Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Hide containment of nodes
Hide containment of nodes [message #539531] Fri, 11 June 2010 08:28 Go to next message
Davte is currently offline DavteFriend
Messages: 4
Registered: June 2010
Location: Aachen
Junior Member
Hi,

i am new to GMF and just started my first own project, which is supposed to display a recursive structure of my meta-model. That works fine with the concept of "phantom nodes".

But defining my containment relations with a link mapping, causes all parent nodes to show the newly added child, which with a growing number of nodes gets quite confusing.

Unfortunately I found nothing like a "show containment" - property for my Node Mapping Laughing , so where and how do I have to start my hide-containment-approach?

Thanks in advance

[Updated on: Fri, 11 June 2010 08:31]

Report message to a moderator

Re: Hide containment of nodes [message #540516 is a reply to message #539531] Wed, 16 June 2010 12:46 Go to previous messageGo to next message
Davte is currently offline DavteFriend
Messages: 4
Registered: June 2010
Location: Aachen
Junior Member
Hi again,

is it because my question is not pointed out accurat enough, that there is no response?

I don't want to seem demanding, but I'm really stuck in that and could use a little help. Any hint into the right direction or any idea would be appreciated. Any question on my question???

Thanks in advance
Re: Hide containment of nodes [message #540818 is a reply to message #539531] Thu, 17 June 2010 12:51 Go to previous messageGo to next message
emil salageanu is currently offline emil salageanuFriend
Messages: 94
Registered: June 2010
Location: Nice, France
Member
I think it is an interesting issue to be able to hide the children of a Node, but I don't think GMF generates code for offers such a functionality.
The only solution I see is to specifically add an attribute (show: boolean, for instance) in your ECORE model, to set the value for this attribute under certain circumstances (for instance to be able to set this attribute to false for all children and respective connections of a Node) and then, in the Edit part, check the value of the attribute when drawing the figure.

I'm not sure at all if its a good solution, I'm new myself with GMF.
I see a big issue for this approach:

- You need to modify your ecore model and add an attribute related to the View. Very bad for the MVC pattern, it mixes up the model data and the view data.


If this message has nothing to do with your problem, then indeed your question "is not pointed out accurat enough" Smile

Cheers,
emil
Re: Hide containment of nodes [message #540864 is a reply to message #540818] Thu, 17 June 2010 13:52 Go to previous messageGo to next message
Davte is currently offline DavteFriend
Messages: 4
Registered: June 2010
Location: Aachen
Junior Member
Hi Emil,

first of all thanks for replying.
Well, you're right, changing my .ecore really is mixing up MVC and wouldn't help for my problem either (i guess).

The point is (to get more accurate Rolling Eyes ) that using the phantom node technique enables me to put non-containment -elements of my root (represented by the canvas itself) directly on the canvas of my diagram. My next step is using a linkmapping to define whose child it will be. After that my node is shown on the canvas and as a containment inside his parents (all of them Confused ).

Lets say that: [ ... ] is a node and that:
|
V
my containment defining connection.

Now my diagram looks like this (starting with "A:"):

[ A: B C]
|
v
[ B: C ]
|
v
[ C: ]

but is supposed to look like:
[ A: ]
|
v
[ B: ]
|
v
[ C: ]

I've already read about solutions to hide nodes but trying that my nodes are hidden completly, my model looks like:

[ A: ]

Don't know wether that was accurate Razz .

Actually that seems to be a very intuitive why of displaying a model, so why is it so complicated?

greets
davte

[Updated on: Thu, 17 June 2010 13:53]

Report message to a moderator

Re: Hide containment of nodes [message #541055 is a reply to message #539531] Fri, 18 June 2010 08:02 Go to previous messageGo to next message
emil salageanu is currently offline emil salageanuFriend
Messages: 94
Registered: June 2010
Location: Nice, France
Member
You're right, your first post was not clear enough, it's only now that I see the problem.

It would be nice if would post a few lines to explain your "phantom nodes" approach - how did you reached to your current implementation.

Together with the solution for this thread, it might be useful for other people too.


Here's how I see your problem:
Let's take, for example, an element of Type C from your example above.
For this element, you have one model object (an instance of the C EClass) and 2 EditPart instances: one EditPart is a child of your Canvas EditPart and the other EditPart is a child of a BEditPart. Each EditPart will draw a figure, right? This is why you have 2 C figures, corresponding to one C model object.
I think you should take a look at the BEditPart class and override some method from its super class.
I would try to find out when are created the children (of type EditPart) of the BEditPart and try not to create children of type C.

Or, as a stupid-but-working solution, in the CEditpart, in the method
protected void refreshVisuals() check if the parent EditPart is of type B, in which case don't draw the figure.

Hope it helps.

Do not forget to tell us how did you do to have phantom nodes and of course, the solution you chose for this issue.

Cheers,
Emil





Re: Hide containment of nodes [message #541985 is a reply to message #541055] Wed, 23 June 2010 13:03 Go to previous messageGo to next message
Davte is currently offline DavteFriend
Messages: 4
Registered: June 2010
Location: Aachen
Junior Member
Hey Emil,

sorry for that delay, I'm still here Smile. At first my phantom node's build up. It took quite a while for me to figure this out, because I found no reasonable explanations, they mostly were too short. If there are still questions on the following, go ahead.

Here the important parts.

My .ecore looks like this:
http://img267.imageshack.us/img267/3929/ecore.jpg

All references you see are containment references.

The more important part, my link mapping looks like this:
http://img188.imageshack.us/img188/333/gmfmap.jpg

The important parts about that are:
-The "Top Node Reference" "<:Asset/Asset>" and "<:Node/Node>" have there "Containment Feature" left blank. You can place these Nodes directly on the canvas now, but for the moment they are homeless.

-To define where they should be put I use "Link Mapping"s. These link mappings only have their "Target Feature" set (and "Diagram Link" and "Tool" of course).
For example "Link Mapping <{RootAsset.node:Node}/RootAssetNode}>" has its "Target Feature" set to "RootAsset.node:Node". So now if I draw a line on the diagram from my "RootAsset" to a "Node" it will become a containment of my "RootAsset". All the other link-mappings work the same way.

Actually this is pretty easy ... afterwards.


Now, to the choosen solution. I wasn't able to figure out how to override "refreshVisuals()" (f.i. in my NodeEditPart). And I also haven't found the right point to prevent my EditParts from being created.
Quote:
Each EditPart will draw a figure, right? This is why you have 2 C figures, corresponding to one C model object.

That gave me the batch into the right direction. There is one EditPart for nodes created on the canvas one for nodes in another node and one in for nodes in assets named "Node2EditPart" and "Node3EditPart". I wasn't really aware of that, but of course that's right (there are even three of them).

First I let their "createNodeShape" method return null ... pretty ugly and causes a lot of NullPointerException ... *surprise surprise* Very Happy . So that's kind of ugly.
Then I deleted those EditParts ... I had to change a lot of code afterwards ... but it worked. Not very pretty yet.
Then I simply deleted those unnecessary EditParts from my gmfgen and recreated my diagram.

So all I had to do was regenerate my .gmfgen then delete all "Gen Child Node"s in my "Gen Diagram" with a number in it regenerate my diagram code and taadaa ... there we are.

So thanks a lot for your help Smile , I find it pretty hard to understand all the relations between the generated classes. Maybe you know a good summary on that, I have not found one that could rather give you a good overview than a detailed look into one specific part.

Cheers
David
Re: Hide containment of nodes [message #542013 is a reply to message #539531] Wed, 23 June 2010 14:19 Go to previous message
emil salageanu is currently offline emil salageanuFriend
Messages: 94
Registered: June 2010
Location: Nice, France
Member
Hi Davte,

I'm glad you managed to solve the problem. And thanks for sharing the solution on the forum.

Quote:

So thanks a lot for your help, I find it pretty hard to understand all the relations between the generated classes. Maybe you know a good summary on that, I have not found one that could rather give you a good overview than a detailed look into one specific part.



I think GMF is great technology, but there's a big lack of documentation on the field. A complete documentation on the generated classes would be great but I don't think there is any up till now.

Hear you,
Emil.
Previous Topic:Artefact in the display of compartments
Next Topic:Add a context menu
Goto Forum:
  


Current Time: Sat Nov 09 02:14:02 GMT 2024

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

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

Back to the top