/* (non-Javadoc) * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#doSaveDocument(org.eclipse.core.runtime.IProgressMonitor, java.lang.Object, org.eclipse.jface.text.IDocument, boolean) * tau 21.03.2005 */ protected void doSaveDocument( IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException { if (element instanceof IFileEditorInput) { doSaveFileResource(monitor, element, document, overwrite); } else if (element instanceof IAdaptable) { // reuses code from TextFileDocumentProvider to handle external files (195615) // TODO consider converting the super class to TextFileDocumentProvider IAdaptable adaptable = (IAdaptable) element; ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager(); ITextFileBuffer fileBuffer = null; LocationKind locationKind = null; ILocationProvider provider = (ILocationProvider) adaptable.getAdapter(ILocationProvider.class); if (provider instanceof ILocationProviderExtension) { URI uri = ((ILocationProviderExtension) provider).getURI(element); if (ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(uri).length == 0) { IFileStore fileStore = EFS.getStore(uri); manager.connectFileStore(fileStore, getProgressMonitor()); fileBuffer = manager.getFileStoreTextFileBuffer(fileStore); } } if (fileBuffer == null && provider != null) { IPath location = provider.getPath(element); if (location != null) { locationKind = LocationKind.NORMALIZE; manager.connect(location, locationKind, getProgressMonitor()); fileBuffer = manager.getTextFileBuffer(location, locationKind); } } if (fileBuffer != null) { fileBuffer.getDocument().set(document.get()); fileBuffer.commit(null, true); } } // tau 21.03.05 // First attempt show Message Connection through SQLScrapbookEditorInput if (element instanceof SQLScrapbookEditorInput) ((SQLScrapbookEditorInput) element).showMessageConnection(); // Second attempt show Message Connection through sqlEditor IEditorPart editor = PlatformUI.getWorkbench() .getActiveWorkbenchWindow() .getActivePage() .findEditor((IEditorInput) element); if ((editor != null) && (editor instanceof SQLEditor)) { ((SQLEditor) editor).refreshConnectionStatus(); } }
protected IDocument createDocument(Object element) throws CoreException { IDocument document = null; document = super.createDocument(element); if (document == null) { document = new Document(""); } // The connection info is restored in SQLScrapbookEditorInput // Attempt show Message Connection through SQLScrapbookEditorInput if (element instanceof SQLScrapbookEditorInput) { ((SQLScrapbookEditorInput) element).showMessageConnection(); } return document; }