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 12:29  |
Eclipse User |
|
|
|
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 02:39   |
Eclipse User |
|
|
|
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 06:01   |
Eclipse User |
|
|
|
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 #235663 is a reply to message #232556] |
Wed, 08 July 2009 10:35  |
Eclipse User |
|
|
|
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.
>
>
|
|
|
Goto Forum:
Current Time: Wed Jul 23 08:35:14 EDT 2025
Powered by FUDForum. Page generated in 0.04410 seconds
|