Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » multiple diagrams and a shared model
multiple diagrams and a shared model [message #213933] Thu, 18 December 2008 09:38 Go to next message
Eclipse UserFriend
I want to do something is would have thought was pretty common, but i just
can't figure out how to get GMF to support it.

I have a simple EMF model, which i open in a CNF navigator and from there
i launch GMF diagram editors. The model has multiple "Design" nodes
(EObjects) which i open and edit using the diagram editors. However, each
of these "Designs" also reference other EObjects from a large set of
shared objects ("Notes").

I have many problems with this apparently simple arrangement!

1) I can't get the CNF navigator to update when i edit a "Design". I
eventually got it to share a TransactionalEditingDomain with the GMF
diagram editor, and this works until the editor closes the diagram. Then
the resource set seems to get unloaded and all the model objects that the
CNF navigator pointed to are left dangling. Am i supposed to listen for
this event and load it all up again? Can i stop the editor dumping it all
in the first place?

2) Am i right to think that i can't really just register a
TransactionalEditingDomain with an ID via an extension point and use
TransactionalEditingDomain.Registry.INSTANCE.getEditingDomai n( "myID")
since i can have several projects open at once and each must use a
different editing domain. Anyway, from the code i've seen, the
???DocumentProvider creates the editing domain and registers the ID - it
doesn't look it up.

3) If i share the single TransactionalEditingDomain between all the
editors then things quickly go wrong - dirty editors don't get marked as
such, saves don't work and changes i've made disappear. Is there a way to
make this system work?

4) I get the feeling i'm on the wrong track and i should have one domain
per editor, each with its own undo/redo. This would be fine for me - but
then how do i manage the shared resources and CNF navigator?
a) Can i get a GMF editor to load just its own model and not try and
load the shared resource model? (it is big and i don't want it loaded
multiple times)
b) How do i get to see the shared resource data that the "Design" i'm
editing is pointing to if i've not loaded it in this editing domain? How
do i make changes to it?
c) How can i get the CNF viewer to show a tree of the entire model if
it is in a separate domain?

I've REALLY struggled here - any help much appreciated.
Re: multiple diagrams and a shared model [message #213962 is a reply to message #213933] Thu, 18 December 2008 12:18 Go to previous messageGo to next message
Eclipse UserFriend
Hello pv,

> 1) I can't get the CNF navigator to update when i edit a "Design". I
Try saving the diagram – generated navigator providers should reflect changes
on saving domain/diagram files from the editor.

> Then the resource set seems to get unloaded and all the model objects
> that the CNF navigator pointed to are left dangling. Am i supposed to
> listen for this event and load it all up again? Can i stop the editor
Right. If you modify generated code you should handle these situations manually.

> 2) Am i right to think that i can't really just register a
> TransactionalEditingDomain with an ID via an extension point and use
> TransactionalEditingDomain.Registry.INSTANCE.getEditingDomai n( "myID")
> since i can have several projects open at once and each must use a
> different editing domain. Anyway, from the code i've seen, the
Right.

> ???DocumentProvider creates the editing domain and registers the ID -
> it doesn't look it up.
It was done intentionally to create new EditingDomain instance for each instance
of the diagram editor.

> 3) If i share the single TransactionalEditingDomain between all the
> editors then things quickly go wrong - dirty editors don't get marked
> as such, saves don't work and changes i've made disappear. Is there a
> way to make this system work?
Try following this HOWTO (be careful – it can be outdated) http://wiki.eclipse.org/GMF_Tips#Sharing_single_EditingDomai n_instance_across_several_diagrams

> 4) I get the feeling i'm on the wrong track and i should have one
> domain per editor, each with its own undo/redo. This would be fine for me –
Well, you can configure the software you are working on using any approaches,
but I currently advocate an idea to create own EditingDomain instance for
each diagram editor and perform necessary synchronization using save action.
But this approach has some drawbacks as well.

> but then how do i manage the shared resources and CNF navigator?
If you are working with the providers generated by GMF then there should
be WorkspaceSynchronizer sub-class generated and this class should be responsible
for reloading resources on any changes in eclipse resources subsystem. Try
to debugging this code to see what’s wrong there.

> a) Can i get a GMF editor to load just its own model and not try
> and load the shared resource model? (it is big and i don't want it loaded
> multiple times)
I think all the referenced resources will be loaded by GMFEditingDomainFactory.configure()
during the call rset.eAdapters().add(new CrossReferenceAdapter());. So, you
can modify this place to suppress total loading.

> b) How do i get to see the shared resource data that the "Design"
> i'm editing is pointing to if i've not loaded it in this editing domain?
There is no way to do that.

> c) How can i get the CNF viewer to show a tree of the entire model
> if it is in a separate domain?
What’s wrong with GMF-generated providers for CNF?

-----------------
Alex Shatalin
Re: multiple diagrams and a shared model [message #214095 is a reply to message #213933] Mon, 22 December 2008 17:40 Go to previous message
Eclipse UserFriend
Originally posted by: jan.koehnlein.web.de

Maybe that will give you some hints:
http://code.google.com/p/gmftools/wiki/SharedEditingDomain

You can also use the same shared editing domain in for the CNF views.
Just follow the advices given on the page above, especially

- adapt the calls to EditingDomainFactory.create()
- remove the calls to EditingDomain.dispose()

Note that you might run into memory problems, as references to your
model elements are kept on the command stack, even though you close your
editors, keeping them from being garbage collected.

Regards
Jan

pv wrote:
> I want to do something is would have thought was pretty common, but i
> just can't figure out how to get GMF to support it.
>
> I have a simple EMF model, which i open in a CNF navigator and from
> there i launch GMF diagram editors. The model has multiple "Design"
> nodes (EObjects) which i open and edit using the diagram editors.
> However, each of these "Designs" also reference other EObjects from a
> large set of shared objects ("Notes").
>
> I have many problems with this apparently simple arrangement!
>
> 1) I can't get the CNF navigator to update when i edit a "Design". I
> eventually got it to share a TransactionalEditingDomain with the GMF
> diagram editor, and this works until the editor closes the diagram. Then
> the resource set seems to get unloaded and all the model objects that
> the CNF navigator pointed to are left dangling. Am i supposed to listen
> for this event and load it all up again? Can i stop the editor dumping
> it all in the first place?
>
> 2) Am i right to think that i can't really just register a
> TransactionalEditingDomain with an ID via an extension point and use
> TransactionalEditingDomain.Registry.INSTANCE.getEditingDomai n( "myID")
> since i can have several projects open at once and each must use a
> different editing domain. Anyway, from the code i've seen, the
> ???DocumentProvider creates the editing domain and registers the ID - it
> doesn't look it up.
>
> 3) If i share the single TransactionalEditingDomain between all the
> editors then things quickly go wrong - dirty editors don't get marked as
> such, saves don't work and changes i've made disappear. Is there a way
> to make this system work?
>
> 4) I get the feeling i'm on the wrong track and i should have one domain
> per editor, each with its own undo/redo. This would be fine for me - but
> then how do i manage the shared resources and CNF navigator?
> a) Can i get a GMF editor to load just its own model and not try and
> load the shared resource model? (it is big and i don't want it loaded
> multiple times)
> b) How do i get to see the shared resource data that the "Design" i'm
> editing is pointing to if i've not loaded it in this editing domain? How
> do i make changes to it?
> c) How can i get the CNF viewer to show a tree of the entire model if
> it is in a separate domain?
>
> I've REALLY struggled here - any help much appreciated.
>
Previous Topic:Pre connected children nodes possible?
Next Topic:How to stop child movement on parent Editpart Resize(WEST, NORTH)?
Goto Forum:
  


Current Time: Sat May 24 18:29:20 EDT 2025

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

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

Back to the top