GMF multidiagram editor - avoid data lost [message #1691799] |
Thu, 09 April 2015 13:44  |
Eclipse User |
|
|
|
Hi,
I have a simple question.
In my GMF/EMF tool, I can edit a diagram from an "active part" of Eclipse and from that (the active Tab) I can edit details of the diagrams in other "active part", my problem is:
when I switch between the "active part" I can meet data loss if I do not save before switching.
I need a solution to show to the user a dialog that inform him about the possibility of data loss, the dialog should appear when a user click on a different Tab.
Have you some suggestions?
Thanks
|
|
|
|
|
|
|
Re: GMF multidiagram editor - avoid data lost [message #1692604 is a reply to message #1692564] |
Thu, 16 April 2015 14:58   |
Eclipse User |
|
|
|
Ok, then it is clear that you do not deal with a multipage editor here.
This is a multipage editor and what I was referring as tabs. (look at selection|tree|etc|Diagram at the bottom)

In your case you just have a different instance of the same file opened in new eclipse tabs. It is like you open three instances of a single file and attempt to edit them without saving. When you attempt to save the file, eclipse identifies that this resource has changed and that's why you get the message that "File Changed - The File Has Been changed on the file system do you want to load the changes" when you attempt to open the other tabs. Because when you opened them the IEditorInput(the content of the file) given to eclipse in order to display the file was different. This is a "strategy" of eclipse in order to prevent data loss.
Sharing the editingDomain is not applicable in your case. Generally, I believe that this is not a good approach to edit the file (through partitioning). Even if you move and save each tab separately, when you move back to the previous tabs you will get the dialog message.
Possibly you could search on how to refresh all the open instances of the same file if that changes (without closing them). In case that you do something like that, you will then need to call it in the method doSave of your xxxDiagramEditor that is located under pluginName.diagram -> src --> part --> xxxDiagramEditor.java --> doSave method. However, I still say that this is not a good approach to deal with the problem.
You could combine, all the nodes in a single editor(having them all available in your palette) and allow elements and relations to be added only under/in those containers, that are of course resizable. This is consider partitioning too, in a different way..
Best.
[Updated on: Thu, 16 April 2015 15:20] by Moderator
|
|
|
Re: GMF multidiagram editor - avoid data lost [message #1692789 is a reply to message #1692604] |
Sat, 18 April 2015 11:08  |
Eclipse User |
|
|
|
I appreciated your suggestions.
Combine all the node in a single editor is not suitable in my scenario.
I found a simple solution, without writing code, installing this plugin:
[https://]github.com/mystilleef/eclipse4-smartsave
The plugin implement a function that intelligently saves files when editor loses focus.
I will investigate for an alternative solution.
Gregorio
|
|
|
Powered by
FUDForum. Page generated in 0.08788 seconds