[Monodevelop-patches-list] r1922 - in trunk/MonoDevelop/Core/src/Main/Base: . Gui/Pads/ClassScout Services/File Services/Tasks

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Wed Jul 28 23:05:41 EDT 2004


Author: fawad
Date: 2004-07-28 23:05:41 -0400 (Wed, 28 Jul 2004)
New Revision: 1922

Modified:
   trunk/MonoDevelop/Core/src/Main/Base/ChangeLog
   trunk/MonoDevelop/Core/src/Main/Base/Gui/Pads/ClassScout/ClassScout.cs
   trunk/MonoDevelop/Core/src/Main/Base/Services/File/DefaultFileService.cs
   trunk/MonoDevelop/Core/src/Main/Base/Services/File/IFileService.cs
   trunk/MonoDevelop/Core/src/Main/Base/Services/Tasks/Task.cs
Log:
Implemented fix for Bug #61928. Implemented same fix for Task Pad as well.


Modified: trunk/MonoDevelop/Core/src/Main/Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/Main/Base/ChangeLog	2004-07-29 02:17:15 UTC (rev 1921)
+++ trunk/MonoDevelop/Core/src/Main/Base/ChangeLog	2004-07-29 03:05:41 UTC (rev 1922)
@@ -1,3 +1,10 @@
+2004-07-28  Fawad Halim <fawad at fawad.net>
+
+	* Services/File/DefaultFileService.cs: Added inner class FileInformation as a container for File Opening information. Overloaded OpenFile to accept a delegate to call after File Opening.
+	* Services/File/IFileService.cs: Added a delegate FileOpeningFinished for use after File Opening.
+	* Services/Tasks/Task.cs: Use OpenFile, having call OnFileOpened after completion.
+	* Gui/Pads/ClassScout/ClassScout.cs: Use OpenFile on node activation, having call OnFileOpened after completion.
+
 2004-07-12  John Luke  <jluke at cfl.rr.com>
 
 	* Gui/Dialogs/NewProjectDialog.cs: catch an IOException when

Modified: trunk/MonoDevelop/Core/src/Main/Base/Gui/Pads/ClassScout/ClassScout.cs
===================================================================
--- trunk/MonoDevelop/Core/src/Main/Base/Gui/Pads/ClassScout/ClassScout.cs	2004-07-29 02:17:15 UTC (rev 1921)
+++ trunk/MonoDevelop/Core/src/Main/Base/Gui/Pads/ClassScout/ClassScout.cs	2004-07-29 03:05:41 UTC (rev 1922)
@@ -166,18 +166,25 @@
 				ClassScoutTag tag = node.Tag as ClassScoutTag;
 				if (tag != null) {
 					IFileService fileService = (IFileService)MonoDevelop.Core.Services.ServiceManager.GetService(typeof(IFileService));
-					fileService.OpenFile(tag.FileName);
-					
-					IViewContent content = fileService.GetOpenFile(tag.FileName).ViewContent;
-					if (content is IPositionable) {
-						if (tag.Line > 0) {
-							((IPositionable)content).JumpTo(tag.Line - 1, 0);
-						}
-					}
+					fileService.OpenFile(tag.FileName,new FileOpeningFinished(OnFileOpened));
 				}
 			}
 		}
 		
+		private void OnFileOpened()
+		{
+			TreeNode node = SelectedNode;
+			ClassScoutTag tag = node.Tag as ClassScoutTag;
+			IFileService fileService = (IFileService)MonoDevelop.Core.Services.ServiceManager.GetService(typeof(IFileService));
+			IWorkbenchWindow window = fileService.GetOpenFile(tag.FileName);
+			if (window == null) {
+				return;
+			}
+			IViewContent content = window.ViewContent;
+			if (content is IPositionable) {
+				((IPositionable)content).JumpTo(Math.Max(0, tag.Line), 0);
+			}
+		}
 		protected override void OnBeforeExpand (TreeViewCancelEventArgs e)
 		{
 			TreeNode nod = e.Node;

Modified: trunk/MonoDevelop/Core/src/Main/Base/Services/File/DefaultFileService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/Main/Base/Services/File/DefaultFileService.cs	2004-07-29 02:17:15 UTC (rev 1921)
+++ trunk/MonoDevelop/Core/src/Main/Base/Services/File/DefaultFileService.cs	2004-07-29 03:05:41 UTC (rev 1922)
@@ -28,6 +28,12 @@
 		string currentFile;
 		RecentOpen       recentOpen = null;
 		FileUtilityService fileUtilityService = (FileUtilityService)ServiceManager.GetService(typeof(FileUtilityService));
+	
+		private class FileInformation
+		{
+			public FileOpeningFinished OnFileOpened;
+			public string FileName;
+		}
 		
 		public RecentOpen RecentOpen {
 			get {
@@ -81,12 +87,31 @@
 		public void OpenFile (string fileName)
 		{
 			DispatchService dispatcher = (DispatchService)ServiceManager.GetService (typeof (DispatchService));
-			dispatcher.GuiDispatch (new StatefulMessageHandler (realOpenFile), fileName);
+			FileInformation openFileInfo=new FileInformation();
+			openFileInfo.OnFileOpened=null;
+			openFileInfo.FileName=fileName;
+			dispatcher.GuiDispatch (new StatefulMessageHandler (realOpenFile), openFileInfo);
 		}
 
-		void realOpenFile (object file)
+		public void OpenFile (string fileName, FileOpeningFinished OnFileOpened){
+			DispatchService dispatcher = (DispatchService)ServiceManager.GetService (typeof (DispatchService));
+			FileInformation openFileInfo=new FileInformation();
+			openFileInfo.OnFileOpened=OnFileOpened;
+			openFileInfo.FileName=fileName;
+			dispatcher.GuiDispatch (new StatefulMessageHandler (realOpenFile), openFileInfo);
+		}
+		
+		void realOpenFile (object openFileInfo)
 		{
-			string fileName = file as string;
+			string fileName;
+			FileInformation oFileInfo;
+			if(openFileInfo is FileInformation){
+				oFileInfo=openFileInfo as FileInformation;
+				fileName=oFileInfo.FileName;
+			}else{
+				return;
+			}
+			
 			if (fileName == null)
 				return;
 
@@ -105,11 +130,13 @@
 					foreach (IViewContent content in WorkbenchSingleton.Workbench.ViewContentCollection) {
 						if (content.IsUntitled && content.UntitledName == origName) {
 							content.WorkbenchWindow.SelectWindow();
+							if(oFileInfo.OnFileOpened!=null) oFileInfo.OnFileOpened();
 							return;
 						}
 					}
 				} else 
 				if (!fileUtilityService.TestFileExists(fileName)) {
+					if(oFileInfo.OnFileOpened!=null) oFileInfo.OnFileOpened();
 					return;
 				}
 			}
@@ -118,6 +145,7 @@
 				if (content.ContentName != null && 
 				    content.ContentName == fileName) {
 					content.WorkbenchWindow.SelectWindow();
+					if(oFileInfo.OnFileOpened!=null) oFileInfo.OnFileOpened();
 					return;
 				}
 			}
@@ -159,6 +187,7 @@
 					}
 				}
 			}
+			if(oFileInfo.OnFileOpened!=null) oFileInfo.OnFileOpened();
 		}
 		
 		protected void GetProjectAndCombineFromFile (string fileName, out IProject project, out Combine combine)

Modified: trunk/MonoDevelop/Core/src/Main/Base/Services/File/IFileService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/Main/Base/Services/File/IFileService.cs	2004-07-29 02:17:15 UTC (rev 1921)
+++ trunk/MonoDevelop/Core/src/Main/Base/Services/File/IFileService.cs	2004-07-29 03:05:41 UTC (rev 1922)
@@ -35,6 +35,8 @@
 		/// </remarks>
 		void OpenFile(string fileName);
 		
+		void OpenFile(string fileName, FileOpeningFinished onFileOpened);
+		
 		/// <remarks>
 		/// Opens a new file with a given name, language and file content
 		/// in the workbench window.
@@ -59,7 +61,7 @@
 		/// to know for other parts of the IDE when a file is renamed.
 		/// </remarks>
 		void RenameFile(string oldName, string newName);
-		
+
 		/// <remarks>
 		/// Is called, when a file is renamed.
 		/// </remarks>
@@ -70,4 +72,5 @@
 		/// </remarks>
 		event FileEventHandler FileRemoved;
 	}
+	public delegate void FileOpeningFinished();
 }

Modified: trunk/MonoDevelop/Core/src/Main/Base/Services/Tasks/Task.cs
===================================================================
--- trunk/MonoDevelop/Core/src/Main/Base/Services/Tasks/Task.cs	2004-07-29 02:17:15 UTC (rev 1921)
+++ trunk/MonoDevelop/Core/src/Main/Base/Services/Tasks/Task.cs	2004-07-29 03:05:41 UTC (rev 1922)
@@ -107,16 +107,7 @@
 		{
 			if (fileName != null && fileName.Length > 0) {
 				IFileService fileService = (IFileService)MonoDevelop.Core.Services.ServiceManager.GetService(typeof(IFileService));
-				fileService.OpenFile(fileName);
-				System.Threading.Thread.Sleep (50);
-				IWorkbenchWindow window = fileService.GetOpenFile(fileName);
-				if (window == null) {
-					return;
-				}
-				IViewContent content = window.ViewContent;
-				if (content is IPositionable) {
-					((IPositionable)content).JumpTo(Math.Max(0, line), Math.Max(0, column));
-				}
+				fileService.OpenFile(fileName,new FileOpeningFinished(OnFileOpened));
 			}
 			
 //			CompilerResultListItem li = (CompilerResultListItem)OpenTaskView.FocusedItem;
@@ -135,5 +126,18 @@
 //				ContentWindow window = OpenWindow(filename);
 //			}
 		}
+		
+		private void OnFileOpened()
+		{
+			IFileService fileService = (IFileService)MonoDevelop.Core.Services.ServiceManager.GetService(typeof(IFileService));
+			IWorkbenchWindow window = fileService.GetOpenFile(fileName);
+			if (window == null) {
+				return;
+			}
+			IViewContent content = window.ViewContent;
+			if (content is IPositionable) {
+				((IPositionable)content).JumpTo(Math.Max(0, line), Math.Max(0, column));
+			}
+		}
 	}
 }




More information about the Monodevelop-patches-list mailing list