Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Multiple diagrams
Multiple diagrams [message #6676] Sun, 06 August 2006 00:07 Go to next message
Eclipse UserFriend
Originally posted by: bob2.msn.com

Hi,

As I posted in the Load/Save Synchronisation thread of the
eclipse.technology.gmf newsgroup, I am having problems with synchronising
between diagrams.

I have 2 diagrams related be the same model. There is only ever going to be
one instance of Diagram1 but there will be many Diagram2's for 'child'
elements of Diagram1

When these two different types of diagrams are open at the same time,
whenever one of the diagrams is saved, the model is overwritten with the
information in the saved diagram and the model information in the other
diagram is lost. This has been discussed before and the suggestion was to
register the editing domain on the
org.eclipse.emf.transaction.editingDomains extension point. I have done
this to both diagram plugins. I have changed the getEditingDomainID() method
of both diagram editors to return the same value and have also removed the
createEditingDomain() methods of both editors. This causes both diagrams to
use the same ResourceSet and therefore prevent the overwriting of data which
works ok. It also makes the editors become 'dirty' and saving any of the
open editors effectively saves all the diagrams.

The problem I face is that when a diagram is not currently open, if a change
is made in any of the other open editors, all diagram information will be
deleted from this diagram file, leaving just

<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/>

in the xml file.



How can I prevent this from happening?

Thanks a lot

Bob
Re: Multiple diagrams [message #11545 is a reply to message #6676] Wed, 09 August 2006 06:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dzhpingbo.sohu.com

I had encountered the same problem as you, but don't know how to solve, and
it seems nobody gives suggest here for quite a few days. Why not submit a
bug about this ?
"bob" <bob2@msn.com> д
Re: Multiple diagrams [message #16018 is a reply to message #11545] Fri, 11 August 2006 17:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lynchjack.hotmail.com

Hi,

Take a look in the generated DocumentProvider class (it lives in same
package as the generated editor) and extends FileDiagramDocumentProvider.
All the methods in there iterate through all resources in the ResouceSet -
they should only act on resources associated with the changed diagram. The
saveDocumentToFile method will call save on your (now non-loaded) resource
and empty it.

Attached is a file I experimented on literally 10 minutes ago in preparation
for next week. Look at the generated NOT methods, they use a simple way
(URI matching) to identify resources associated with the diagram being
saved. When it comes to it I may attempt to associate related models to the
diagram via say session or persistent properties on the resource, haven't
thought about it yet..

HTH,
Jack

"dzh" <dzhpingbo@sohu.com> wrote in message
news:ebbvnb$a6v$1@utils.eclipse.org...
>I had encountered the same problem as you, but don't know how to solve, and
> it seems nobody gives suggest here for quite a few days. Why not submit a
> bug about this ?
> "bob" <bob2@msn.com> д
Re: Multiple diagrams [message #17044 is a reply to message #16018] Mon, 14 August 2006 09:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bob2.msn.com

Thanks for your help Jack. It works well. I small problem that I dont like,
is that whenever diagram 2 is changed and saved, diagram 1 is marked as
dirty and this then needs to be saved before the model is updated.

An additional problem I have found is that the palette stops working when
the same editing domain is used for multiple diagrams. This problem was
mentioned in the "problem with synchronizing model changes in different
Editor" thread so I'll have to investigate this to remove the problem.

Cheers
Re: Multiple diagrams [message #17367 is a reply to message #16018] Mon, 14 August 2006 17:18 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Jack,

Just few comments:

> Take a look in the generated DocumentProvider class (it lives in same
> package as the generated editor) and extends
> FileDiagramDocumentProvider. All the methods in there iterate through
> all resources in the ResouceSet - they should only act on resources
> associated with the changed diagram. The saveDocumentToFile method
That's true - if you need different behavior you can modify generated code
as you've done it in the attached class.

> will call save on your (now non-loaded) resource and empty it.
If this is the only problem, we can call Resource.isLoaded() method before
saving it and do not save unloaded resources. Can you please check that it
helps and create a bugzilla request for it?


-----------------
Alex Shatalin
Re: Multiple diagrams [message #19281 is a reply to message #17367] Tue, 15 August 2006 13:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lynchjack.hotmail.com

Hi Alex,

Calling Resource.isLoaded() will help prevent loss of data in the case where
a previously opened diagram is closed. I'll log a bugzilla now.

It won't be enough in the case where multiple diagrams are open that share
the same ResourceSet - if you modify both diagrams and save one, the other
will also be saved. A possible solution might be to mark both files with a
persistent property, say in the XXXDiagramEditor.createNewDiagramFile method
(where both are available). Then use this property in
XXXDocumentProvider.saveDocumentToFile to only save related files/resources.

Cheers,
Jack

"Alex Shatalin" <vano@borland.com> wrote in message
news:cd695fb310e128c88ded8c25bb60@news.eclipse.org...
> Hello Jack,
>
> Just few comments:
>
>> Take a look in the generated DocumentProvider class (it lives in same
>> package as the generated editor) and extends
>> FileDiagramDocumentProvider. All the methods in there iterate through
>> all resources in the ResouceSet - they should only act on resources
>> associated with the changed diagram. The saveDocumentToFile method
> That's true - if you need different behavior you can modify generated code
> as you've done it in the attached class.
>
>> will call save on your (now non-loaded) resource and empty it.
> If this is the only problem, we can call Resource.isLoaded() method before
> saving it and do not save unloaded resources. Can you please check that it
> helps and create a bugzilla request for it?
>
>
> -----------------
> Alex Shatalin
>
>
Re: Multiple diagrams [message #19369 is a reply to message #19281] Tue, 15 August 2006 14:45 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Jack,

> It won't be enough in the case where multiple diagrams are open that
> share the same ResourceSet - if you modify both diagrams and save one,
I see, but it's not so easy to select correct set of resources in case of
referencing some EObjects stored in a different resources. I'd say that current
bevahior is ok as a default one and in case of some specific requirements
you can modify corresponding code manually.

-----------------
Alex Shatalin
Previous Topic:Child reference for link mapping
Next Topic:how to use GraphicalNode and CanonicalConnection EditPolicy together
Goto Forum:
  


Current Time: Sat Oct 19 18:54:42 GMT 2024

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

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

Back to the top