Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Diagram Partitioning, problems at saving and synchronization
Diagram Partitioning, problems at saving and synchronization [message #231750] Thu, 28 May 2009 16:29 Go to next message
Javier is currently offline JavierFriend
Messages: 57
Registered: July 2009
Member
Hi guys,

I have diagram partitioning for my editor using an OpenDiagramEditPolicy.
The canvas element is the same for all, a Process.

Let's say I have ProcessA as the initial process, and then I add a
ProcessB inside A, and I open a new tab for ProcessB. Now, I make some
modification to second tab (let's say, I add a new element) so its tab
gets marked with *. The first tab doesn't get marked that way. Now I go to
the first tab and I made another modification, so it get's marked with *.
From now, I'm running into problems.

If I save the first tab and then I go to the second, it will ask me if I
want to load the resource because some changes were made. If I say yes,
then I lose changes I made in the second. I can also say no, and then try
to save this second tab, it will tell me that I'm going to overwrite some
previous modifications. If I continue, I keep changes made in second tab
but I'm losing changes I made in the first tab. I check this behaviour
with another simple editor and the same is happening.

But I saw that Ecoretools editor works in a different way. If you make a
change in a tab, then all tabs will get marked. If you save one of them,
all of them will be updated (or saved). How can I get this behavior? Does
anyone know where might the solution be?

Any help would be appreciated, thanks!
Re: Diagram Partitioning, problems at saving and synchronization [message #231764 is a reply to message #231750] Fri, 29 May 2009 06:39 Go to previous messageGo to next message
Daniel Rippel is currently offline Daniel RippelFriend
Messages: 29
Registered: July 2009
Junior Member
The problem you are describing results from the fact, that Eclipse
assignes an editing domain to each editor which is open. This means,
that every editor gets its own copy of the resource (file) you are
working with. When saving, the respective changes made in the one editor
are written to the file and the other editors try to reload the changes,
disposing their own ones. There are several ways to cope with this problem:

Easiest way: Close all other editors when one is opened. This not a very
nice solution but prevents from oversaving other editors changes.

Another solution would be to manually synchronize the editors. You could
for example save each editor if it looses focus or is closed. In this
way all changes will be saved and updated in the other editors.

The most preferable way would be to share the editing domain across all
editors. A tutorial can be found here:
http://wiki.eclipse.org/index.php/GMF_Tips#Sharing_single_Ed itingDomain_instance_across_several_diagrams

I'm not sure if there are other ways within GMF 2.2. I in my case chose
to manually synchronize the eds. by just allowing to open the root
editor and one of the partitioned editors at time, manually keeping the
editing domains in synch by carefully placed autosave operations.

Javier schrieb:
> Hi guys,
>
> I have diagram partitioning for my editor using an
> OpenDiagramEditPolicy. The canvas element is the same for all, a Process.
>
> Let's say I have ProcessA as the initial process, and then I add a
> ProcessB inside A, and I open a new tab for ProcessB. Now, I make some
> modification to second tab (let's say, I add a new element) so its tab
> gets marked with *. The first tab doesn't get marked that way. Now I go
> to the first tab and I made another modification, so it get's marked
> with *. From now, I'm running into problems.
>
> If I save the first tab and then I go to the second, it will ask me if I
> want to load the resource because some changes were made. If I say yes,
> then I lose changes I made in the second. I can also say no, and then
> try to save this second tab, it will tell me that I'm going to overwrite
> some previous modifications. If I continue, I keep changes made in
> second tab but I'm losing changes I made in the first tab. I check this
> behaviour with another simple editor and the same is happening.
>
> But I saw that Ecoretools editor works in a different way. If you make a
> change in a tab, then all tabs will get marked. If you save one of them,
> all of them will be updated (or saved). How can I get this behavior?
> Does anyone know where might the solution be?
>
> Any help would be appreciated, thanks!
Re: Diagram Partitioning, problems at saving and synchronization [message #231862 is a reply to message #231764] Mon, 01 June 2009 10:01 Go to previous messageGo to next message
Javier is currently offline JavierFriend
Messages: 57
Registered: July 2009
Member
Hello Daniel, thanks for your answer.

As you said, the "new" opened editor was using a new EditingDomain with a
copy of the resource at the moment of opening. From there, changes in both
tabs were "independent", I mean, the semantic model was getting modified
differently for each of them... until the moment of salvation, in which it
needed to solve conflicts.

I followed your advice and I shared the same instance of the
EditingDomain, at the initialization in the DocumentProvider. I also made
some modifications following what EcoreToolsDocumentProvider has. And it
seems to work fine but I can see some "weird" behavior in some
circumstances.

For example, I create a new Diagram and save. I add a new Process (Process
A) and afterwards (without saving) double-click on A to get a new tab.
Then I save. After this, something weird is happening in the initial tab:
when I call the eResource() method for all the View elements in that tab,
it returns NULL. The tab seems to be locked (I cant do anything, I cant
move, I cant resize...) and if I try to open a tab, it also throws an
exception (since I can't access the resource). If I close the editors and
I open it again, everything works fine now. And if I save before I open
the new tab for the new diagram, it also works fine. Any idea on what's
happening here?

Thank you,

Javier.
Re: Diagram Partitioning, problems at saving and synchronization [message #231894 is a reply to message #231862] Mon, 01 June 2009 11:25 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Javier,

Looks like some code works incorrectly in one of the DocumentProviders..
I can suggest you to place a breakpoint into setDocumentContent()/handleElementChanged()
methods and try to realize what's happening.

-----------------
Alex Shatalin
Re: Diagram Partitioning, problems at saving and synchronization [message #231944 is a reply to message #231894] Mon, 01 June 2009 15:27 Go to previous messageGo to next message
Javier is currently offline JavierFriend
Messages: 57
Registered: July 2009
Member
Hi Alex,

I'll take care with those methods you're telling me. For now, I got this
"apparently" working by fixing some code in the OpenDiagramEditPolicy.
Generated code was performing a WorkspaceModification and saving the new
diagram... commenting lines related to that, it works fine now. I
realized of that by looking at the OpenDiagramEditPolicy implemented in
EcoreTools plugin.

Thanks!

javier.


Alex Shatalin escribió:
> Hello Javier,
>
> Looks like some code works incorrectly in one of the DocumentProviders..
> I can suggest you to place a breakpoint into
> setDocumentContent()/handleElementChanged() methods and try to realize
> what's happening.
>
> -----------------
> Alex Shatalin
>
>
Re: Diagram Partitioning, problems at saving and synchronization [message #232556 is a reply to message #231944] Fri, 05 June 2009 09:44 Go to previous messageGo to next message
Javier is currently offline JavierFriend
Messages: 57
Registered: July 2009
Member
Working further on this issue of synchronization, I got several times
the problem of "apparently" losing the View elements of a Diagram and
not being able to work with it.

The fact of sharing the EditingDomain was triggering some code in the
handleResourceChanged method that was unloading the resource of one of
the diagrams. That was why afterwards I couldn't modify anything ... so
it is necessary to make some adjustments to the ones made in the
EcoretoolsPlugin, in the DocumentProvider.



Javier escribió:
> Hi Alex,
>
> I'll take care with those methods you're telling me. For now, I got this
> "apparently" working by fixing some code in the OpenDiagramEditPolicy.
> Generated code was performing a WorkspaceModification and saving the new
> diagram... commenting lines related to that, it works fine now. I
> realized of that by looking at the OpenDiagramEditPolicy implemented in
> EcoreTools plugin.
>
> Thanks!
>
> javier.
>
>
> Alex Shatalin escribió:
>> Hello Javier,
>>
>> Looks like some code works incorrectly in one of the DocumentProviders..
>> I can suggest you to place a breakpoint into
>> setDocumentContent()/handleElementChanged() methods and try to realize
>> what's happening.
>>
>> -----------------
>> Alex Shatalin
>>
>>
Re: Diagram Partitioning, problems at saving and synchronization [message #235663 is a reply to message #232556] Wed, 08 July 2009 14:35 Go to previous message
Andreas Schoeneck is currently offline Andreas SchoeneckFriend
Messages: 22
Registered: July 2009
Junior Member
Hi Javier,

since I am running into similar problems with my partitiones, shared
EditingDomain editor, could you please point out the adjustments you made?

Do you mean handleElementChanged() ? What to do there?

Furthermore it seems that ???DiagramEditor::getNavigatorSelection()
needs adjustments to check whether diagram.eResource() isn't null.

Thanks & regards
Andreas


Javier schrieb:
> Working further on this issue of synchronization, I got several times
> the problem of "apparently" losing the View elements of a Diagram and
> not being able to work with it.
>
> The fact of sharing the EditingDomain was triggering some code in the
> handleResourceChanged method that was unloading the resource of one of
> the diagrams. That was why afterwards I couldn't modify anything ... so
> it is necessary to make some adjustments to the ones made in the
> EcoretoolsPlugin, in the DocumentProvider.
>
>
Previous Topic:Issue with Layouts before in gmfgraph diagrams
Next Topic:Connections disappear between shortcut elements on refresh/reload
Goto Forum:
  


Current Time: Fri Apr 26 15:54:53 GMT 2024

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

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

Back to the top