-/*
- * Created on 06.09.2003
- *
- */
package net.sourceforge.phpeclipse.builder;
import java.io.ByteArrayInputStream;
*/
public class ExternalStorageDocumentProvider extends StorageDocumentProvider {
- /* (non-Javadoc)
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#doSaveDocument(org.eclipse.core.runtime.IProgressMonitor, java.lang.Object, org.eclipse.jface.text.IDocument, boolean)
- */
- protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite)
- throws CoreException {
- if (element instanceof ExternalEditorInput) {
- ExternalEditorInput external = (ExternalEditorInput) element;
- FileStorage storage = (FileStorage)external.getStorage();
- String encoding = getEncoding(element);
- if (encoding == null)
- encoding = getDefaultEncoding();
- try {
- InputStream stream = new ByteArrayInputStream(document.get().getBytes(encoding));
- try {
- // inform about the upcoming content change
- fireElementStateChanging(element);
- storage.setContents(stream, overwrite, true, monitor);
- } catch (RuntimeException e) {
- // inform about failure
- fireElementStateChangeFailed(element);
- throw e;
- }
- } catch (IOException e) {
- IStatus s = new Status(IStatus.ERROR, PHPeclipsePlugin.PLUGIN_ID, IStatus.OK, e.getMessage(), e);
- throw new CoreException(s);
- }
-
- } else {
- super.doSaveDocument(monitor, element, document, overwrite);
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#doSaveDocument(org.eclipse.core.runtime.IProgressMonitor,
+ * java.lang.Object, org.eclipse.jface.text.IDocument, boolean)
+ */
+ protected void doSaveDocument(IProgressMonitor monitor, Object element,
+ IDocument document, boolean overwrite) throws CoreException {
+ if (element instanceof ExternalEditorInput) {
+ ExternalEditorInput external = (ExternalEditorInput) element;
+ FileStorage storage = (FileStorage) external.getStorage();
+ String encoding = getEncoding(element);
+ if (encoding == null)
+ encoding = getDefaultEncoding();
+ try {
+ InputStream stream = new ByteArrayInputStream(document.get()
+ .getBytes(encoding));
+ try {
+ // inform about the upcoming content change
+ fireElementStateChanging(element);
+ storage.setContents(stream, overwrite, true, monitor);
+ } catch (RuntimeException e) {
+ // inform about failure
+ fireElementStateChangeFailed(element);
+ throw e;
+ }
+ } catch (IOException e) {
+ IStatus s = new Status(IStatus.ERROR,
+ PHPeclipsePlugin.PLUGIN_ID, IStatus.OK, e.getMessage(),
+ e);
+ throw new CoreException(s);
}
- }
-}
+ } else {
+ super.doSaveDocument(monitor, element, document, overwrite);
+ }
+ }
+}