/* * @see org.eclipse.ui.texteditor.AbstractDocumentProvider.DocumentProviderOperation#execute(org.eclipse.core.runtime.IProgressMonitor) */ protected void execute(IProgressMonitor pm) throws CoreException { ElementInfo info = (ElementInfo) fElementInfoMap.get(element); if (info != null) { if (info.fDocument != document) { Status status = new Status( IStatus.WARNING, TextEditorPlugin.PLUGIN_ID, IStatus.ERROR, EditorMessages.AbstractDocumentProvider_error_save_inuse, null); throw new CoreException(status); } doSaveDocument(pm, element, document, overwrite); if (pm != null && pm.isCanceled()) return; info.fCanBeSaved = false; addUnchangedElementListeners(element, info); fireElementDirtyStateChanged(element, false); } else { doSaveDocument(pm, element, document, overwrite); } }
/** * Executes the actual work of reseting the given elements document. * * @param element the element * @param monitor the progress monitor * @throws CoreException if resetting fails * @since 3.0 */ protected void doResetDocument(Object element, IProgressMonitor monitor) throws CoreException { ElementInfo info = (ElementInfo) fElementInfoMap.get(element); if (info != null) { IDocument original = null; IStatus status = null; try { original = createDocument(element); } catch (CoreException x) { status = x.getStatus(); } info.fStatus = status; if (original != null) { fireElementContentAboutToBeReplaced(element); info.fDocument.set(original.get()); if (info.fCanBeSaved) { info.fCanBeSaved = false; addUnchangedElementListeners(element, info); } fireElementContentReplaced(element); fireElementDirtyStateChanged(element, false); } } }
/* * @see IDocumentProviderExtension#setCanSaveDocument(Object) * @since 2.0 */ public void setCanSaveDocument(Object element) { if (element != null) { ElementInfo info = (ElementInfo) fElementInfoMap.get(element); if (info != null) { info.fCanBeSaved = true; removeUnchangedElementListeners(element, info); fireElementDirtyStateChanged(element, info.fCanBeSaved); } } }