mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for Bug 167806 - [Editor] External files are not editable
This commit is contained in:
parent
9405806525
commit
2a9b29e5bf
2 changed files with 37 additions and 18 deletions
|
@ -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.CFileElementWorkingCopy;
|
||||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||||
import org.eclipse.cdt.internal.ui.text.IProblemRequestorExtension;
|
import org.eclipse.cdt.internal.ui.text.IProblemRequestorExtension;
|
||||||
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CDocumentProvider2
|
* CDocumentProvider2
|
||||||
|
@ -862,7 +861,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
tuInfo.fModel= new ExternalSearchAnnotationModel(markerResource, storage);
|
tuInfo.fModel= new ExternalSearchAnnotationModel(markerResource, storage);
|
||||||
IAnnotationModel fileBufferAnnotationModel= tuInfo.fTextFileBuffer.getAnnotationModel();
|
IAnnotationModel fileBufferAnnotationModel= tuInfo.fTextFileBuffer.getAnnotationModel();
|
||||||
if (fileBufferAnnotationModel != null) {
|
if (fileBufferAnnotationModel != null) {
|
||||||
((AnnotationModel)tuInfo.fModel).addAnnotationModel("secondaryModel", fileBufferAnnotationModel); //$NON-NLS-1$
|
((AnnotationModel)tuInfo.fModel).addAnnotationModel("fileBufferModel", fileBufferAnnotationModel); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
tuInfo.fCachedReadOnlyState= true;
|
tuInfo.fCachedReadOnlyState= true;
|
||||||
}
|
}
|
||||||
|
@ -883,11 +882,15 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
* @see org.eclipse.ui.editors.text.TextFileDocumentProvider#isReadOnly(java.lang.Object)
|
* @see org.eclipse.ui.editors.text.TextFileDocumentProvider#isReadOnly(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public boolean isReadOnly(Object element) {
|
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
|
// because of missing functionality in CFileElementWorkingCopy
|
||||||
if (element instanceof ExternalEditorInput) {
|
FileInfo info= getFileInfo(element);
|
||||||
|
if (info instanceof TranslationUnitInfo) {
|
||||||
|
TranslationUnitInfo tuInfo= (TranslationUnitInfo)info;
|
||||||
|
if (tuInfo.fCopy instanceof CFileElementWorkingCopy) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return super.isReadOnly(element);
|
return super.isReadOnly(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -895,11 +898,15 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
* @see org.eclipse.ui.editors.text.TextFileDocumentProvider#isModifiable(java.lang.Object)
|
* @see org.eclipse.ui.editors.text.TextFileDocumentProvider#isModifiable(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public boolean isModifiable(Object element) {
|
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
|
// because of missing functionality in CFileElementWorkingCopy
|
||||||
if (element instanceof ExternalEditorInput) {
|
FileInfo info= getFileInfo(element);
|
||||||
|
if (info instanceof TranslationUnitInfo) {
|
||||||
|
TranslationUnitInfo tuInfo= (TranslationUnitInfo)info;
|
||||||
|
if (tuInfo.fCopy instanceof CFileElementWorkingCopy) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return super.isModifiable(element);
|
return super.isModifiable(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,24 +23,38 @@ import org.eclipse.jface.text.source.IAnnotationModel;
|
||||||
import org.eclipse.ui.IPathEditorInput;
|
import org.eclipse.ui.IPathEditorInput;
|
||||||
import org.eclipse.ui.IStorageEditorInput;
|
import org.eclipse.ui.IStorageEditorInput;
|
||||||
import org.eclipse.ui.editors.text.ILocationProvider;
|
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.core.resources.FileStorage;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
|
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
|
||||||
|
|
||||||
public class ExternalSearchDocumentProvider extends CStorageDocumentProvider {
|
public class ExternalSearchDocumentProvider extends TextFileDocumentProvider {
|
||||||
|
|
||||||
/** Location attribute for breakpoints. See <code>ICBreakpoint.SOURCE_HANDLE</code> */
|
public ExternalSearchDocumentProvider() {
|
||||||
private static final String DEBUG_SOURCE_HANDLE = "org.eclipse.cdt.debug.core.sourceHandle"; //$NON-NLS-1$
|
super(new CStorageDocumentProvider());
|
||||||
|
|
||||||
public ExternalSearchDocumentProvider(){
|
|
||||||
super();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @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 {
|
protected IAnnotationModel createAnnotationModel(Object element) throws CoreException {
|
||||||
if (element instanceof ExternalEditorInput) {
|
if (element instanceof ExternalEditorInput) {
|
||||||
return createExternalSearchAnnotationModel((ExternalEditorInput)element);
|
return createExternalSearchAnnotationModel((ExternalEditorInput)element);
|
||||||
|
@ -65,7 +79,7 @@ public class ExternalSearchDocumentProvider extends CStorageDocumentProvider {
|
||||||
return createExternalSearchAnnotationModel(storage, null);
|
return createExternalSearchAnnotationModel(storage, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.createAnnotationModel(element);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -96,8 +110,6 @@ public class ExternalSearchDocumentProvider extends CStorageDocumentProvider {
|
||||||
markerResource= CUIPlugin.getWorkspace().getRoot();
|
markerResource= CUIPlugin.getWorkspace().getRoot();
|
||||||
model = new ExternalSearchAnnotationModel(markerResource, storage, IResource.DEPTH_ONE);
|
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;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue