Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to get a corresponding view to an element
How to get a corresponding view to an element [message #520023] Wed, 10 March 2010 21:02 Go to next message
Pavol is currently offline PavolFriend
Messages: 4
Registered: March 2010
Junior Member
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 #520220 is a reply to message #520023] Thu, 11 March 2010 15:28 Go to previous messageGo to next message
Matthias M. is currently offline Matthias M.Friend
Messages: 27
Registered: July 2009
Junior Member

Hi Pavol,

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.

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.

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.

Regards
Matthias


Re: How to get a corresponding view to an element [message #520239 is a reply to message #520220] Thu, 11 March 2010 16:39 Go to previous messageGo to next message
Pavol is currently offline PavolFriend
Messages: 4
Registered: March 2010
Junior Member
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] Sat, 13 March 2010 01:50 Go to previous message
Pavol is currently offline PavolFriend
Messages: 4
Registered: March 2010
Junior Member
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.
Previous Topic:One domain file and multiple diagram files: is it possible?
Next Topic:GMF Customization Help - Recreate Connection on drop of a node
Goto Forum:
  


Current Time: Sat Sep 19 13:32:48 GMT 2020

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

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

Back to the top