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 7bb6e85c2b4..1239e7460f9 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 @@ -73,7 +73,6 @@ import org.eclipse.cdt.internal.core.model.IBufferFactory; import org.eclipse.cdt.internal.ui.CFileElementWorkingCopy; import org.eclipse.cdt.internal.ui.CPluginImages; import org.eclipse.cdt.internal.ui.text.IProblemRequestorExtension; -import org.eclipse.cdt.internal.ui.util.ExternalEditorInput; /** * CDocumentProvider2 @@ -862,7 +861,7 @@ public class CDocumentProvider extends TextFileDocumentProvider { tuInfo.fModel= new ExternalSearchAnnotationModel(markerResource, storage); IAnnotationModel fileBufferAnnotationModel= tuInfo.fTextFileBuffer.getAnnotationModel(); if (fileBufferAnnotationModel != null) { - ((AnnotationModel)tuInfo.fModel).addAnnotationModel("secondaryModel", fileBufferAnnotationModel); //$NON-NLS-1$ + ((AnnotationModel)tuInfo.fModel).addAnnotationModel("fileBufferModel", fileBufferAnnotationModel); //$NON-NLS-1$ } tuInfo.fCachedReadOnlyState= true; } @@ -883,10 +882,14 @@ public class CDocumentProvider extends TextFileDocumentProvider { * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#isReadOnly(java.lang.Object) */ public boolean isReadOnly(Object element) { - // external editor input must not be modified + // external translation unit must not be modified // because of missing functionality in CFileElementWorkingCopy - if (element instanceof ExternalEditorInput) { - return true; + FileInfo info= getFileInfo(element); + if (info instanceof TranslationUnitInfo) { + TranslationUnitInfo tuInfo= (TranslationUnitInfo)info; + if (tuInfo.fCopy instanceof CFileElementWorkingCopy) { + return true; + } } return super.isReadOnly(element); } @@ -895,10 +898,14 @@ public class CDocumentProvider extends TextFileDocumentProvider { * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#isModifiable(java.lang.Object) */ public boolean isModifiable(Object element) { - // external editor input must not be modified + // external translation unit must not be modified // because of missing functionality in CFileElementWorkingCopy - if (element instanceof ExternalEditorInput) { - return false; + FileInfo info= getFileInfo(element); + if (info instanceof TranslationUnitInfo) { + TranslationUnitInfo tuInfo= (TranslationUnitInfo)info; + if (tuInfo.fCopy instanceof CFileElementWorkingCopy) { + return false; + } } return super.isModifiable(element); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchDocumentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchDocumentProvider.java index 0b2d66edafa..e6365b9f670 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchDocumentProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchDocumentProvider.java @@ -23,24 +23,38 @@ import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.ui.IPathEditorInput; import org.eclipse.ui.IStorageEditorInput; import org.eclipse.ui.editors.text.ILocationProvider; +import org.eclipse.ui.editors.text.TextFileDocumentProvider; import org.eclipse.cdt.core.resources.FileStorage; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.ui.util.ExternalEditorInput; -public class ExternalSearchDocumentProvider extends CStorageDocumentProvider { +public class ExternalSearchDocumentProvider extends TextFileDocumentProvider { - /** Location attribute for breakpoints. See ICBreakpoint.SOURCE_HANDLE */ - private static final String DEBUG_SOURCE_HANDLE = "org.eclipse.cdt.debug.core.sourceHandle"; //$NON-NLS-1$ - - public ExternalSearchDocumentProvider(){ - super(); + public ExternalSearchDocumentProvider() { + super(new CStorageDocumentProvider()); } /* - * @see org.eclipse.ui.editors.text.StorageDocumentProvider#createAnnotationModel(java.lang.Object) + * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#createFileInfo(java.lang.Object) */ + protected FileInfo createFileInfo(Object element) throws CoreException { + final FileInfo info= super.createFileInfo(element); + if (info.fModel == null) { + info.fModel= createAnnotationModel(element); + if (info.fModel != null) { + IAnnotationModel fileBufferAnnotationModel= info.fTextFileBuffer.getAnnotationModel(); + if (fileBufferAnnotationModel != null) { + ((AnnotationModel)info.fModel).addAnnotationModel("fileBufferModel", fileBufferAnnotationModel); //$NON-NLS-1$ + } + setUpSynchronization(info); + } + } + return info; + } + + protected IAnnotationModel createAnnotationModel(Object element) throws CoreException { if (element instanceof ExternalEditorInput) { return createExternalSearchAnnotationModel((ExternalEditorInput)element); @@ -65,7 +79,7 @@ public class ExternalSearchDocumentProvider extends CStorageDocumentProvider { return createExternalSearchAnnotationModel(storage, null); } } - return super.createAnnotationModel(element); + return null; } /** @@ -96,8 +110,6 @@ public class ExternalSearchDocumentProvider extends CStorageDocumentProvider { markerResource= CUIPlugin.getWorkspace().getRoot(); model = new ExternalSearchAnnotationModel(markerResource, storage, IResource.DEPTH_ONE); } - // attach annotation model for C breakpoints - model.addAnnotationModel("debugMarkerModel", new ExternalSearchAnnotationModel(markerResource, storage, IResource.DEPTH_ZERO, DEBUG_SOURCE_HANDLE)); //$NON-NLS-1$ return model; }