Custom ViewPart + Accessing the Model [message #184157] |
Thu, 24 April 2008 10:47  |
Eclipse User |
|
|
|
Hi,
I've created a new ViewPart to display some information about the model
being edited by the currently active editor (the model before it is saved
to disk, that is).
Currently I am sharing the TransactionalEditingDomain and accessing it
from my ViewPart code like this:
TransactionalEditingDomain.Registry.INSTANCE.getEditingDomai n(EDITINGDOMAIN_IDENTIFIER);
(detailed here:
http://wiki.eclipse.org/GMF_Tips#Sharing_single_EditingDomai n_instance_across_several_diagrams)
Hopefully this design is reasonable, as I need to create more ViewParts
which also read the model. If not, I'd appreciate alternate suggestions ;)
The ViewParts must know about the entire model, not just selected
elements, so I'm not sure ISelectionListeners etc. will cut it. My
question about all this is:
How do I identify which model underlies the currently active editor from
the ViewPart code?
At the moment I can iterate through the models available in the
EditingDomain:
default.model
default.model_diagram
default2.model
default2.model_diagram
How do I tell which is currently displaying, so I can have the ViewPart
update itself?
Thanks!
Maurice
|
|
|
Re: Custom ViewPart + Accessing the Model [message #184160 is a reply to message #184157] |
Thu, 24 April 2008 12:33  |
Eclipse User |
|
|
|
Here's my solution, for any hapless newbies following in my footsteps.
Scratch the above junk about sharing the TransactionalEditingDomain. No
need to do this for a ViewPart. In the ViewPart I wrote:
Object o = this.getSite().getPage().getActiveEditor().getEditorInput();
EditingDomain editingDomain =
MyGeneratedDiagramEditorPlugin.getInstance().getDocumentProv ider().getDiagramDocument(o).getEditingDomain();
Using the EditingDomain I can grab the ResourceSet and iterate over it,
locating the nodes I need to access. Gnarly!
Maurice
|
|
|
Powered by
FUDForum. Page generated in 0.03536 seconds