|
|
Re: Hide containment of nodes [message #540818 is a reply to message #539531] |
Thu, 17 June 2010 08:51   |
Eclipse User |
|
|
|
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 04:02   |
Eclipse User |
|
|
|
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 09:03   |
Eclipse User |
|
|
|
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
|
|
|
Re: Hide containment of nodes [message #542013 is a reply to message #539531] |
Wed, 23 June 2010 10:19  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.04732 seconds