Community
Participate
Working Groups
Breif description to the problem, if you have two documents opened (both are dirty). Try to save as one of the documents, with the same name of the other one, this will lead to having two different opened documnet for the same file (each has different contents) which will cause confusion and errors. I investigated the problem found that in AbstractDocumentProvider::saveDocument, it try to save without checking if this new document is already opened or not. I added the following check to saveDocument which fix the problem. Object obj=null; String newPath = element.toString(); String filePath = null; for (Iterator i = getConnectedElements();i.hasNext();) { obj = i.next(); filePath = obj.toString(); if (filePath.equals(newPath)) { IDocument info= getDocument(obj); if (info != document) { Status status= new Status(IStatus.WARNING, EditorPlugin.getPluginId(), IStatus.ERROR, EditorMessages.Editor_error_saveAsTargetOpenInEditor, null); throw new CoreException(status); } } Note, in this code, I just used string comparison which is not a bright solution. the submitter should do a better check if they are equal. Note 2, unfortunatily I couldn't construct the map key from the file path which might have saved the loop. I don't think it's doable, though it worth a look.
Created attachment 30319 [details] patch for Resource Editor IDE plugin for SaveAs issue Added subclass DiagramDocumentEditorIDE of DiagramDocumentEditor that contains an enhanced performSaveAs method. This method now includes a check if save target file is already open. The FileDiagramEditor class now inherits DiagramDocumentEditorIDE and logic diagrams will no longer be allowed to save to a file that is currently opened.
Created attachment 30320 [details] patch for Resource Editor plugin for SaveAs issue
Committed the code
*** Bug 116081 has been marked as a duplicate of this bug. ***
Renamed DiagramDocumentEditorIDE to IDEDiagramDocumentEditor to be consistent with the IDE naming convention.
[GMF Restructure] Bug 319140 : product GMF and component Runtime Diagram was the original product and component for this bug