Home » Modeling » GMF (Graphical Modeling Framework) » Hide containment of nodes
Hide containment of nodes [message #539531] |
Fri, 11 June 2010 08:28 |
Davte 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 , 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 #540818 is a reply to message #539531] |
Thu, 17 June 2010 12:51 |
emil salageanu 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"
Cheers,
emil
|
|
| |
Re: Hide containment of nodes [message #541055 is a reply to message #539531] |
Fri, 18 June 2010 08:02 |
emil salageanu 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 |
Davte Messages: 4 Registered: June 2010 Location: Aachen |
Junior Member |
|
|
Hey Emil,
sorry for that delay, I'm still here . 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:
All references you see are containment references.
The more important part, my link mapping looks like this:
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* . 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 , 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
|
|
| |
Goto Forum:
Current Time: Sat Nov 09 02:14:02 GMT 2024
Powered by FUDForum. Page generated in 0.03566 seconds
|