diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java index 543070aba0b..836cb443677 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java @@ -18,6 +18,7 @@ import org.eclipse.cdt.internal.core.model.IBufferFactory; import org.eclipse.cdt.internal.core.model.IWorkingCopy; import org.eclipse.cdt.internal.ui.CStatusConstants; import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.IEditorInputDelegate; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IStorage; @@ -140,16 +141,24 @@ public class CDocumentProvider extends FileDocumentProvider { * @see AbstractDocumentProvider#createDocument(Object) */ protected IDocument createDocument(Object element) throws CoreException { - IDocument document; - - if (element instanceof IStorageEditorInput) { - IStorage storage= ((IStorageEditorInput) element).getStorage(); - - document= new CDocument(); - setDocumentContent(document, storage.getContents(), getDefaultEncoding()); - } else { - return null; + IDocument document = null; + IStorage storage = null; + + if (element instanceof IEditorInputDelegate) { + if (((IEditorInputDelegate) element).getDelegate() != null) + return createDocument(((IEditorInputDelegate) element).getDelegate()); + else + storage = ((IEditorInputDelegate) element).getStorage(); } + + if (element instanceof IStorageEditorInput) + storage= ((IStorageEditorInput) element).getStorage(); + + if ( storage != null ) { + document = new CDocument(); + setDocumentContent(document, storage.getContents(), getDefaultEncoding()); + } + //IDocument document= super.createDocument(element); initializeDocument(document); return document; @@ -159,6 +168,8 @@ public class CDocumentProvider extends FileDocumentProvider { * @see AbstractDocumentProvider#createAnnotationModel(Object) */ protected IAnnotationModel createAnnotationModel(Object element) throws CoreException { + if ( element instanceof IEditorInputDelegate && ((IEditorInputDelegate)element).getDelegate() != null ) + return createAnnotationModel( ((IEditorInputDelegate)element).getDelegate() ); if (element instanceof IFileEditorInput) { IFileEditorInput input= (IFileEditorInput) element; return new CMarkerAnnotationModel(input.getFile()); @@ -399,4 +410,16 @@ public class CDocumentProvider extends FileDocumentProvider { return getElementInfo(input) != null; } + /** + * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#getStatus(Object) + */ + public IStatus getStatus(Object element) { + if (element instanceof IEditorInputDelegate) { + if (((IEditorInputDelegate) element).getDelegate() != null) + return super.getStatus(((IEditorInputDelegate) element).getDelegate()); + else + return new Status(IStatus.INFO,CUIPlugin.getPluginId(),0,"",null); + } + return super.getStatus(element); + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IEditorInputDelegate.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IEditorInputDelegate.java new file mode 100644 index 00000000000..afbf58bd680 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IEditorInputDelegate.java @@ -0,0 +1,33 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ + +package org.eclipse.cdt.ui; + +import org.eclipse.core.resources.IStorage; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.ui.IEditorInput; + +/** + * This interface allows to create flexible editor inputs. + * + * @since May 21, 2003 + */ +public interface IEditorInputDelegate extends IEditorInput { + /** + * Returns the editor input delegate for this editor input. + * + * @return editor input delegate + */ + IEditorInput getDelegate(); + + /** + * Returns the storage associated with this editor input. + * + * @return stirage associated with this editor input + * @throws CoreException on failure. Reasons include: + */ + IStorage getStorage() throws CoreException; +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/CDebugDocumentProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/CDebugDocumentProvider.java deleted file mode 100644 index 6c66cccb8cd..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/CDebugDocumentProvider.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - *(c) Copyright QNX Software Systems Ltd. 2002. - * All Rights Reserved. - * - */ -package org.eclipse.cdt.debug.internal.ui.editors; - -import org.eclipse.cdt.debug.ui.CDebugUIPlugin; -import org.eclipse.cdt.internal.core.model.IBufferFactory; -import org.eclipse.cdt.internal.ui.editor.CDocumentProvider; -import org.eclipse.cdt.ui.CUIPlugin; -import org.eclipse.core.resources.IStorage; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IDocumentPartitioner; -import org.eclipse.jface.text.source.IAnnotationModel; - -/** - * - * Enter type comment. - * - * @since Mar 4, 2003 - */ -public class CDebugDocumentProvider extends CDocumentProvider -{ - /** - * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#createDocument(Object) - */ - protected IDocument createDocument( Object element ) throws CoreException - { - if ( element instanceof EditorInputDelegate ) - { - if ( ((EditorInputDelegate)element).getDelegate() != null ) - { - return super.createDocument( ((EditorInputDelegate)element).getDelegate() ); - } - else - { - IDocument document = null; - IStorage storage = ((EditorInputDelegate)element).getStorage(); - if ( storage != null ) - { - document = new CDocument(); - setDocumentContent( document, storage.getContents(), getDefaultEncoding() ); - } - else - { - return null; - } - if ( document != null) - { - IDocumentPartitioner partitioner= CUIPlugin.getDefault().getTextTools().createDocumentPartitioner(); - partitioner.connect( document ); - document.setDocumentPartitioner( partitioner ); - } - return document; - } - } - return super.createDocument( element ); - } - - /** - * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#getStatus(Object) - */ - public IStatus getStatus( Object element ) - { - if ( element instanceof EditorInputDelegate ) - { - if ( ((EditorInputDelegate)element).getDelegate() != null ) - { - return super.getStatus( ((EditorInputDelegate)element).getDelegate() ); - } - else - { - return createFileNotFoundStatus( ((EditorInputDelegate)element).getElement() ); - } - } - return super.getStatus( element ); - } - - private IStatus createFileNotFoundStatus( FileNotFoundElement element ) - { - return new Status( IStatus.INFO, CDebugUIPlugin.getUniqueIdentifier(), 0, "", null ); - } - - protected IAnnotationModel createAnnotationModel( Object element ) throws CoreException - { - if ( element instanceof EditorInputDelegate && ((EditorInputDelegate)element).getDelegate() != null ) - return super.createAnnotationModel( ((EditorInputDelegate)element).getDelegate() ); - return super.createAnnotationModel( element ); - } - - /* (non-Javadoc) - * This hack is important for the the outliner to work correctly. - * The outliner looks at the working copy and it is maintain by - * CUIPlugin.getDefault().getWorkingCopyManager() - * CUIPlugin.getDefault().getDocumentProvider(); - * They are singletons. - * - * @see org.eclipse.cdt.internal.ui.editor.CDocumentProvider#getBufferFactory() - */ - public IBufferFactory getBufferFactory() { - return CUIPlugin.getDefault().getDocumentProvider().getBufferFactory(); - } - -} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/CDebugEditor.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/CDebugEditor.java index 4ed8ac7c339..f5da1d06294 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/CDebugEditor.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/CDebugEditor.java @@ -369,7 +369,7 @@ public class CDebugEditor extends CEditor public CDebugEditor() { super(); - setDocumentProvider( CDebugUIPlugin.getDefault().getDocumentProvider() ); + setDocumentProvider( CUIPlugin.getDefault().getDocumentProvider() ); } /* (non-Javadoc) diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/EditorInputDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/EditorInputDelegate.java index 9cce600f72a..2a7dba26943 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/EditorInputDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/EditorInputDelegate.java @@ -8,6 +8,7 @@ package org.eclipse.cdt.debug.internal.ui.editors; import java.io.ByteArrayInputStream; import java.io.InputStream; +import org.eclipse.cdt.ui.IEditorInputDelegate; import org.eclipse.core.resources.IStorage; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; @@ -22,7 +23,7 @@ import org.eclipse.ui.IStorageEditorInput; * * @since Mar 4, 2003 */ -public class EditorInputDelegate implements IEditorInput +public class EditorInputDelegate implements IEditorInputDelegate { public static final int TYPE_ATTACH_SOURCE = 0; public static final int TYPE_WORKSPACE_FILE = 1; diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java index 93a5461290c..9deb4521e26 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java @@ -13,7 +13,6 @@ import org.eclipse.cdt.debug.core.sourcelookup.IDisassemblyStorage; import org.eclipse.cdt.debug.internal.ui.CDTDebugModelPresentation; import org.eclipse.cdt.debug.internal.ui.CDebugImageDescriptorRegistry; import org.eclipse.cdt.debug.internal.ui.ColorManager; -import org.eclipse.cdt.debug.internal.ui.editors.CDebugDocumentProvider; import org.eclipse.cdt.debug.internal.ui.editors.DisassemblyDocumentProvider; import org.eclipse.cdt.debug.internal.ui.editors.DisassemblyEditorInput; import org.eclipse.cdt.debug.internal.ui.preferences.CDebugPreferencePage; @@ -76,9 +75,6 @@ public class CDebugUIPlugin extends AbstractUIPlugin // Document provider for disassembly editor private DisassemblyDocumentProvider fDisassemblyDocumentProvider = null; - // Document provider for C/C++ debug editor - private CDebugDocumentProvider fDocumentProvider; - /** * The constructor. */ @@ -512,16 +508,4 @@ public class CDebugUIPlugin extends AbstractUIPlugin display.asyncExec( runnable ); } } - - /** - * Returns the used document provider - */ - public CDebugDocumentProvider getDocumentProvider() - { - if (fDocumentProvider == null) - { - fDocumentProvider = new CDebugDocumentProvider(); - } - return fDocumentProvider; - } }