|
|
|
Re: GMF multidiagram editor - avoid data lost [message #1692143 is a reply to message #1692130] |
Mon, 13 April 2015 21:30 |
|
Hello,
could you please post a screenshot showing your opened file and the tabs? So as for everyone to understand the concept and which editor you are using. For example, are you using the default multipage editor generated by GMF (that is the model editor) or you have created a new multipage editor which combines the diagram and some EMF views?
If you provide the requested details I can give you a hint in which Class/Methods to look at.
Generally, the diagram editor class is located in the .diagram plugin under the xxx.diagram.parts > XXXDiagramEditor.java
The EMF(model views) editor is located under the .editor plugin under the xxx.presentation > XXXEditor.java
Now if you are sharing a single file between these tabs and the tabs include GMF and EMF views of the same file (only), then following the tutorial that I provided is the best way to go.
You will not have to start from scratch in order to follow the tutorial. You will just need to have a working GMF project.
Best, Nikos
|
|
|
Re: GMF multidiagram editor - avoid data lost [message #1692564 is a reply to message #1692143] |
Thu, 16 April 2015 13:58 |
Gregorio Barberio Messages: 5 Registered: April 2015 |
Junior Member |
|
|
I followed the instructions explained in this article:
[http://] hflorezf-en.blogspot.it/2014/04/gmf-partitioning.html
My case is very similar to the case of the example: the differences relate the names and the amount of the elements but the structure of the ecore is the same.
I have created and customized the code of the diagram Model and Container (respectively in my example are Model and Machine ).
When I try to model different Containers (or rather Machines), occurs data loss in the Container (Machine) that I have not saved.
This is a classical situation in which occurs data loss
(Please refers to TEST section of the referenced example)
1) Create a Partitioning Diagram.
2) Add Container1 and Container2
3) Select Container1 and double click. The container editor will be opened.
4) Draw elements and relations
5) Turn back on the Partitioning Diagram
6) Select Container2 and double click. The container editor will be opened.
7) Draw elements and relations
8) Save the changes on the active tab (Container 2 editor, figure above step 9 in the example)
Results
When turn back to Container 1 diagram, a message box appears:
"File Changed - The File Has Been changed on the file system do you want to load the changes"
If I choose "Yes" I lose unsaved data in Container 1
If I choose "No", the data saved in Container 2 are not loaded in the Container 1 and if I save again a data loss occurs in changes made in Container 1
This is only a simple scenario but it is simple to create more scenarios which are prone to data lose.
Thanks!
[Updated on: Thu, 16 April 2015 13:58] Report message to a moderator
|
|
|
Re: GMF multidiagram editor - avoid data lost [message #1692604 is a reply to message #1692564] |
Thu, 16 April 2015 18:58 |
|
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 19:20] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03542 seconds