mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix PR 38047, unable to save changes in CDebugEditor.
This commit is contained in:
parent
151c03d458
commit
cf3d839940
6 changed files with 68 additions and 135 deletions
|
@ -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;
|
||||
IDocument document = null;
|
||||
IStorage storage = null;
|
||||
|
||||
if (element instanceof IStorageEditorInput) {
|
||||
IStorage storage= ((IStorageEditorInput) element).getStorage();
|
||||
|
||||
document= new CDocument();
|
||||
setDocumentContent(document, storage.getContents(), getDefaultEncoding());
|
||||
} else {
|
||||
return 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -369,7 +369,7 @@ public class CDebugEditor extends CEditor
|
|||
public CDebugEditor()
|
||||
{
|
||||
super();
|
||||
setDocumentProvider( CDebugUIPlugin.getDefault().getDocumentProvider() );
|
||||
setDocumentProvider( CUIPlugin.getDefault().getDocumentProvider() );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue