How to get a corresponding view to an element [message #520023] |
Wed, 10 March 2010 16:02  |
Eclipse User |
|
|
|
Hi,
at first I will explain my situation.
I have one node A, which contains another two nodes B and C (as compartments). B and C are at the same "level". I am able to create nodes D inside of B and C.
If I create node D as a child in C, I have to automatically create another instance of node D also in B.
I am trying to do this in the class myDiagramViewProvider in the createD method.
At first I create another domain element for node D. Then I need to create a view for that element. And for that purpose I need a containerView of node B. I am able to get domain element for node B.
Is there a way how to get corresponding view to this domain element?
I was trying to call ViewUtil.getViewContainer(domain_element_of_B) , but it always returned null.
Thanks a lot.
Pavol.
|
|
|
|
Re: How to get a corresponding view to an element [message #520239 is a reply to message #520220] |
Thu, 11 March 2010 11:39   |
Eclipse User |
|
|
|
Matthias M. wrote on Thu, 11 March 2010 16:28 |
I think you should better put the creation of your second D into your DEditHelper (which you perhaps have to create and register).
This is where "i-have-to-do-something-if-something-else-is-changed"-operations should generally be put.
|
Thanks, I will try it, but I think that there will always be the problem with getting the right view.
Matthias M. wrote on Thu, 11 March 2010 16:28 |
Besides you only have to create the model-element of D and add it to the right containment-feature. GMF will handle the creation of the EditPart and therefore of the View on its own.
|
I think, you are wrong here. I already tried this. I created model-element through MyDiagramFactory.eINSTANCE.createD() and then I set the containment-feature. Well - GMF created the model-element and also the View properly. But I guess, there is something wrong with the View serialization. Because if I close and re-open the editor, the View will not be constructed properly again. Therefore I suppose that the View have to be created with appropriate method from the class MyDiagramViewProvider.
Matthias M. wrote on Thu, 11 March 2010 16:28 |
If that doesn't help you:
There is a findEditPart-method in each GraphicalEditPart. So, if you can somehow get the A-EditPart (EditPartRegistry??), you can get the B-EditPart and from that the B-View.
|
I don't know how to get EditPartRegistry. But I will keep trying ...
Thanks.
Pavol.
|
|
|
Re: How to get a corresponding view to an element [message #520597 is a reply to message #520239] |
Fri, 12 March 2010 20:50  |
Eclipse User |
|
|
|
I override the method ICommand getConfigureCommand(ConfigureRequest req) inside the appropriate EditHelper class.
Now I want to create some domain element and a corresponding View to it. I created .. CreateViewAndElementRequest createReq .. but I cannot get the right Command from createReq.
Any Help how to get the right Command from CreateViewAndElementRequest ? or how to get EditPart?
Thanks.
|
|
|
Powered by
FUDForum. Page generated in 0.04266 seconds