Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Custom ViewPart + Accessing the Model
Custom ViewPart + Accessing the Model [message #184157] Thu, 24 April 2008 10:47 Go to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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
Previous Topic:Re: gmf
Next Topic:Integrating GMF plugin to an exist RCP
Goto Forum:
  


Current Time: Wed Jul 23 08:14:37 EDT 2025

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

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

Back to the top