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 |
Javier 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 |
Daniel Rippel 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 |
Javier 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.
|
|
| | | | |
Goto Forum:
Current Time: Fri Apr 26 15:54:53 GMT 2024
Powered by FUDForum. Page generated in 0.03357 seconds
|