Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Fix for PR 38047: Unable to save changes in C/C++ debug editor

 
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/ChangeLog,v
retrieving revision 1.97
diff -u -r1.97 ChangeLog
--- ChangeLog	28 Apr 2003 02:36:20 -0000	1.97
+++ ChangeLog	23 May 2003 15:19:03 -0000
@@ -1,3 +1,11 @@
+2003-05-23 Mikhail Khodjaiants
+	PR 38047: Unable to save changes in C/C++ debug editor.
+	* src/org/eclipse/cdt/ui/IEditorInputDelegate.java: new
+	This interface is added to provide support for more flexible editor inputs.
+
+	* src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java:
+	Support of the "IEditorInputDelegate" interface.
+
 2003-04-27 Alain Magloire
 
 	PR 36759, the outline does not update
Index: src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java,v
retrieving revision 1.14
diff -u -r1.14 CDocumentProvider.java
--- src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java	28 Apr 2003 02:37:47 -0000	1.14
+++ src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java	23 May 2003 15:19:04 -0000
@@ -18,6 +18,7 @@
 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 @@
 	 * @see AbstractDocumentProvider#createDocument(Object)
 	 */ 
 	protected IDocument createDocument(Object element) throws CoreException {
-		IDocument document;
-			
-		if (element instanceof IStorageEditorInput) {
-			IStorage storage= ((IStorageEditorInput) element).getStorage();
+		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();
+		}
 			
-			document= new CDocument();
+		if (element instanceof IStorageEditorInput)
+			storage= ((IStorageEditorInput) element).getStorage();
+		
+		if ( storage != null ) {
+			document = new CDocument();
 			setDocumentContent(document, storage.getContents(), getDefaultEncoding());
-		} else {
-			return null;
 		}
+
 		//IDocument document= super.createDocument(element);
 		initializeDocument(document);
 		return document;
@@ -159,6 +168,8 @@
 	 * @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 @@
 		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);
+	}
 }
Index: src/org/eclipse/cdt/ui/IEditorInputDelegate.java
===================================================================
RCS file: src/org/eclipse/cdt/ui/IEditorInputDelegate.java
diff -N src/org/eclipse/cdt/ui/IEditorInputDelegate.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/ui/IEditorInputDelegate.java	23 May 2003 15:19:05 -0000
@@ -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;
+}
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/ChangeLog,v
retrieving revision 1.148
diff -u -r1.148 ChangeLog
--- ChangeLog	14 May 2003 19:24:12 -0000	1.148
+++ ChangeLog	23 May 2003 15:29:04 -0000
@@ -1,3 +1,10 @@
+2003-05-23 Mikhail Khodjaiants
+	Fix for PR 38047: Unable to save changes in C/C++ debug editor.
+	* CDebugEditor.java
+	* EditorInputDelegate.java
+	* CDebugUIPlugin.java
+	* CDebugDocumentProvider.java: removed
+
 2003-05-14 Mikhail Khodjaiants
 	Created preference for the maximum number of disassembly instructions.
 	* CDebugPreferencePage.java
Index: src/org/eclipse/cdt/debug/internal/ui/editors/CDebugDocumentProvider.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/internal/ui/editors/CDebugDocumentProvider.java
diff -N src/org/eclipse/cdt/debug/internal/ui/editors/CDebugDocumentProvider.java
--- src/org/eclipse/cdt/debug/internal/ui/editors/CDebugDocumentProvider.java	28 Apr 2003 02:35:56 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -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();
-	}
-
-}
Index: src/org/eclipse/cdt/debug/internal/ui/editors/CDebugEditor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/CDebugEditor.java,v
retrieving revision 1.4
diff -u -r1.4 CDebugEditor.java
--- src/org/eclipse/cdt/debug/internal/ui/editors/CDebugEditor.java	29 Apr 2003 18:42:18 -0000	1.4
+++ src/org/eclipse/cdt/debug/internal/ui/editors/CDebugEditor.java	23 May 2003 15:29:05 -0000
@@ -369,7 +369,7 @@
 	public CDebugEditor()
 	{
 		super();
-		setDocumentProvider( CDebugUIPlugin.getDefault().getDocumentProvider() );
+		setDocumentProvider( CUIPlugin.getDefault().getDocumentProvider() );
 	}
 
 	/* (non-Javadoc)
Index: src/org/eclipse/cdt/debug/internal/ui/editors/EditorInputDelegate.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/EditorInputDelegate.java,v
retrieving revision 1.1
diff -u -r1.1 EditorInputDelegate.java
--- src/org/eclipse/cdt/debug/internal/ui/editors/EditorInputDelegate.java	6 Mar 2003 00:13:36 -0000	1.1
+++ src/org/eclipse/cdt/debug/internal/ui/editors/EditorInputDelegate.java	23 May 2003 15:29:05 -0000
@@ -8,6 +8,7 @@
 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 @@
  * 
  * @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;
Index: src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java,v
retrieving revision 1.23
diff -u -r1.23 CDebugUIPlugin.java
--- src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java	7 Apr 2003 22:49:08 -0000	1.23
+++ src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java	23 May 2003 15:29:05 -0000
@@ -13,7 +13,6 @@
 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 @@
 	// Document provider for disassembly editor	
 	private DisassemblyDocumentProvider fDisassemblyDocumentProvider = null;
 
-	// Document provider for C/C++ debug editor	
-	private CDebugDocumentProvider fDocumentProvider;
-
 	/**
 	 * The constructor.
 	 */
@@ -511,17 +507,5 @@
 		{
 			display.asyncExec( runnable );
 		}
-	}
-
-	/**
-	 * Returns the used document provider
-	 */
-	public CDebugDocumentProvider getDocumentProvider()
-	{
-		if (fDocumentProvider == null)
-		{
-			fDocumentProvider = new CDebugDocumentProvider();
-		}
-		return fDocumentProvider;
 	}
 }

Back to the top