diff options
author | david_williams | 2005-12-07 19:17:36 +0000 |
---|---|---|
committer | david_williams | 2005-12-07 19:17:36 +0000 |
commit | 469eb7d3202335f643c7b685cb9483f62c22e02b (patch) | |
tree | 4a12f0b59cf6ad06564bbe2ce9c695173cf1d897 /bundles/org.eclipse.wst.sse.core/src | |
parent | 947306a9eea27024450c166cb2f0a2f766b97e4a (diff) | |
download | webtools.sourceediting-469eb7d3202335f643c7b685cb9483f62c22e02b.tar.gz webtools.sourceediting-469eb7d3202335f643c7b685cb9483f62c22e02b.tar.xz webtools.sourceediting-469eb7d3202335f643c7b685cb9483f62c22e02b.zip |
[119204] canceling web.xml save does not undo (reload) fresh, insynch values -- proposed fix
Diffstat (limited to 'bundles/org.eclipse.wst.sse.core/src')
2 files changed, 46 insertions, 10 deletions
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/FileBufferModelManager.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/FileBufferModelManager.java index 9d35372f30..7eb7a45d2f 100644 --- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/FileBufferModelManager.java +++ b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/FileBufferModelManager.java @@ -533,9 +533,10 @@ public class FileBufferModelManager { if (Logger.DEBUG_FILEBUFFERMODELMANAGEMENT) { Logger.log(Logger.INFO, "FileBufferModelManager connecting to IFile " + file.getLocation()); //$NON-NLS-1$ } - // see TextFileDocumentProvider#createFileInfo about why we use IFile#getFullPath + // see TextFileDocumentProvider#createFileInfo about why we use + // IFile#getFullPath // here, not IFile#getLocation. - IPath location= file.getFullPath(); + IPath location = file.getFullPath(); if (location != null) { bufferManager.connect(location, getProgressMonitor()); ITextFileBuffer buffer = bufferManager.getTextFileBuffer(location); @@ -546,18 +547,18 @@ public class FileBufferModelManager { * Note: "info" being null at this point is a slight * error. * - * The connect call from above (or at some time earlier in - * the session) would have notified the FileBufferMapper - * of the creation of the corresponding text buffer and - * created the DocumentInfo object for - * IStructuredDocuments. + * The connect call from above (or at some time + * earlier in the session) would have notified the + * FileBufferMapper of the creation of the + * corresponding text buffer and created the + * DocumentInfo object for IStructuredDocuments. */ info.selfConnected = true; } /* * Check the document type. Although returning null for - * unknown documents would be fair, try to get a model if the - * document is at least a valid type. + * unknown documents would be fair, try to get a model if + * the document is at least a valid type. */ IDocument bufferDocument = buffer.getDocument(); if (bufferDocument instanceof IStructuredDocument) { @@ -659,4 +660,29 @@ public class FileBufferModelManager { } } } + + public void revert(IDocument document) { + if (document == null) { + Exception iae = new IllegalArgumentException("can not release a model without a document reference"); //$NON-NLS-1$ + Logger.logException(iae); + return; + } + DocumentInfo info = (DocumentInfo) fDocumentMap.get(document); + if (info == null) { + Logger.log(Logger.ERROR, "FileBufferModelManager was asked to revert a document but was not being managed"); + } + else { + // get path just for potential error message + IPath location = info.buffer.getLocation(); + try { + // ISSUE: in future, clients should provide progress monitor + info.buffer.revert(getProgressMonitor()); + } + catch (CoreException e) { + // ISSUE: shoudl we not be re-throwing CoreExceptions? Or + // not catch them at all? + Logger.logException("Error reverting model for " + location, e); //$NON-NLS-1$ + } + } + } } diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/model/ModelManagerImpl.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/model/ModelManagerImpl.java index 94980739be..e4f716d48f 100644 --- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/model/ModelManagerImpl.java +++ b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/model/ModelManagerImpl.java @@ -1358,12 +1358,22 @@ public class ModelManagerImpl implements IModelManager { if ((sharedObject.referenceCountForRead == 0) && (sharedObject.referenceCountForEdit == 0)) { discardModel(id, sharedObject); } - // ISSUE: if edit goes to zero, but still open for read, + // if edit goes to zero, but still open for read, // then we should reload here, so we are in synch with // contents on disk. + // ISSUE: should we check isDirty here? + if ((sharedObject.referenceCountForRead > 0) && (sharedObject.referenceCountForEdit == 0)) { + revertModel(id, sharedObject); + } } } } + + // private for now, though public forms have been requested, in past. + private void revertModel(Object id, SharedObject sharedObject) { + IStructuredDocument structuredDocument = sharedObject.theSharedModel.getStructuredDocument(); + FileBufferModelManager.getInstance().revert(structuredDocument); + } private void discardModel(Object id, SharedObject sharedObject) { fManagedObjects.remove(id); |