[Monodevelop-patches-list] r2484 - in trunk/MonoDevelop/Core/src/MonoDevelop.Base: . Commands Gui/Workbench Gui/Workbench/Layouts Services/DebuggerService Services/File Services/Project

Lluis Sanchez <lluis@ximian.com> lluis at mono-cvs.ximian.com
Wed Apr 27 14:03:14 EDT 2005


Author: lluis
Date: 2005-04-27 14:03:14 -0400 (Wed, 27 Apr 2005)
New Revision: 2484

Added:
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/DebuggerService/BreakpointEventHandler.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/DebuggerService/IBreakpoint.cs
Modified:
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Commands/ProjectCommands.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Commands/ViewCommands.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/DefaultWorkbench.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Makefile.am
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/MonoDevelopCore.addin.xml
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/DebuggerService/IDebuggerService.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/File/DefaultFileService.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Project/IProjectService.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Project/ProjectService.cs
Log:
2005-04-27  Lluis Sanchez Gual  <lluis at novell.com> 

	* Commands/ViewCommands.cs: Use markup for the view list menu.
	* Commands/ProjectCommands.cs: Implemented Debug Application command.
	* Services/File/DefaultFileService.cs: In OpenFile, don't create a
	progress monitor if the file is already open.
	* Services/DebuggerService/IDebuggerService.cs: Added events that notify
	when breakpoints are added/removed. Added methods for getting the
	active breakpoints.
	
	* MonoDevelopCore.addin.xml:
	* Services/Project/IProjectService.cs:
	* Services/Project/ProjectService.cs:
	Added DebugApplication method. In the Debug methods, make sure the
	context switch is done in the gui thread.
	
	* Gui/Workbench/Layouts/SdiWorkspaceLayout.cs: Don't use ShowItem() to
	show a hidden pad, since it is not working properly.
	
	* Gui/Workbench/DefaultWorkbench.cs: Removed most of code related to
	debugging, since it is handled by the editor itself.
	
	* Makefile.am: Added some new files.



Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog	2005-04-27 14:17:03 UTC (rev 2483)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog	2005-04-27 18:03:14 UTC (rev 2484)
@@ -1,3 +1,27 @@
+2005-04-27  Lluis Sanchez Gual  <lluis at novell.com> 
+
+	* Commands/ViewCommands.cs: Use markup for the view list menu.
+	* Commands/ProjectCommands.cs: Implemented Debug Application command.
+	* Services/File/DefaultFileService.cs: In OpenFile, don't create a
+	progress monitor if the file is already open.
+	* Services/DebuggerService/IDebuggerService.cs: Added events that notify
+	when breakpoints are added/removed. Added methods for getting the
+	active breakpoints.
+	
+	* MonoDevelopCore.addin.xml:
+	* Services/Project/IProjectService.cs:
+	* Services/Project/ProjectService.cs:
+	Added DebugApplication method. In the Debug methods, make sure the
+	context switch is done in the gui thread.
+	
+	* Gui/Workbench/Layouts/SdiWorkspaceLayout.cs: Don't use ShowItem() to
+	show a hidden pad, since it is not working properly.
+	
+	* Gui/Workbench/DefaultWorkbench.cs: Removed most of code related to
+	debugging, since it is handled by the editor itself.
+	
+	* Makefile.am: Added some new files.
+
 2005-04-27  Lluis Sanchez Gual  <lluis at novell.com>
 
 	* Makefile.am

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Commands/ProjectCommands.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Commands/ProjectCommands.cs	2005-04-27 14:17:03 UTC (rev 2483)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Commands/ProjectCommands.cs	2005-04-27 18:03:14 UTC (rev 2484)
@@ -11,6 +11,7 @@
 using MonoDevelop.Services;
 using MonoDevelop.Gui;
 using MonoDevelop.Internal.Project;
+using MonoDevelop.Gui.Widgets;
 
 namespace MonoDevelop.Commands
 {
@@ -39,6 +40,7 @@
 		Deploy,
 		ConfigurationSelector,
 		Debug,
+		DebugApplication,
 		Stop
 	}
 	
@@ -128,6 +130,10 @@
 		
 		protected override void Update (CommandInfo info)
 		{
+			if (Runtime.DebuggingService == null) {
+				info.Enabled = false;
+				return;
+			}
 			if (Runtime.ProjectService.CurrentOpenCombine != null) {
 				info.Enabled = Runtime.ProjectService.CurrentSelectedCombineEntry != null && 
 								Runtime.ProjectService.CurrentRunOperation.IsCompleted;
@@ -149,6 +155,26 @@
 		}
 	}
 	
+	public class DebugApplicationHandler: CommandHandler
+	{
+		protected override void Run ()
+		{
+			using (FileSelector fs = new FileSelector (GettextCatalog.GetString ("Application to Debug"))) {
+				int response = fs.Run ();
+				string name = fs.Filename;
+				fs.Hide ();
+				if (response == (int)Gtk.ResponseType.Ok)
+					Runtime.ProjectService.DebugApplication (name);
+			}
+		}
+		
+		protected override void Update (CommandInfo info)
+		{
+			info.Enabled = Runtime.DebuggingService != null &&
+							Runtime.ProjectService.CurrentRunOperation.IsCompleted;
+		}
+	}
+
 	public class BuildHandler: CommandHandler
 	{
 		protected override void Run ()

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Commands/ViewCommands.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Commands/ViewCommands.cs	2005-04-27 14:17:03 UTC (rev 2483)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Commands/ViewCommands.cs	2005-04-27 18:03:14 UTC (rev 2484)
@@ -57,6 +57,7 @@
 				PadContentCollection pads = wb.WorkbenchLayout.PadContentCollection;
 				foreach (IPadContent padContent in pads) {
 					CommandInfo cmd = new CommandInfo (padContent.Title);
+					cmd.UseMarkup = true;
 					cmd.Checked = WorkbenchSingleton.Workbench.WorkbenchLayout.IsVisible (padContent);
 					info.Add (cmd, padContent);
 				}

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/DefaultWorkbench.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/DefaultWorkbench.cs	2005-04-27 14:17:03 UTC (rev 2483)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/DefaultWorkbench.cs	2005-04-27 18:03:14 UTC (rev 2484)
@@ -43,9 +43,6 @@
 		
 		bool closeAll = false;
 
-		string cur_dbgFilename;
-		int    cur_dbgLineNumber;
-		
 		bool            fullscreen;
 		Rectangle       normalBounds       = new Rectangle(0, 0, 640, 480);
 		
@@ -150,8 +147,6 @@
 			IDebuggingService dbgr = Runtime.DebuggingService;
 			if (dbgr != null) {
 				dbgr.PausedEvent += new EventHandler (onDebuggerPaused);
-				dbgr.ResumedEvent += new EventHandler (onDebuggerResumed);		
-				dbgr.StoppedEvent += new EventHandler (onDebuggerStopped);
 			}
 
 			Gtk.Drag.DestSet (this, Gtk.DestDefaults.Motion | Gtk.DestDefaults.Highlight | Gtk.DestDefaults.Drop, targetEntryTypes, Gdk.DragAction.Copy);
@@ -191,37 +186,11 @@
 		{
 			IDebuggingService dbgr = Runtime.DebuggingService;
 			if (dbgr != null) {
-				cur_dbgFilename = dbgr.CurrentFilename;
-				cur_dbgLineNumber = dbgr.CurrentLineNumber - 1;
-
-				if (cur_dbgFilename != String.Empty) {
-					Runtime.FileService.OpenFile (cur_dbgFilename);
-					if (ActiveWorkbenchWindow.ViewContent is IDebuggableEditor) 
-						((IDebuggableEditor)ActiveWorkbenchWindow.ViewContent).ExecutingAt (cur_dbgLineNumber);
-				}
+				if (dbgr.CurrentFilename != String.Empty)
+					Runtime.FileService.OpenFile (dbgr.CurrentFilename);
 			}
 		}
 
-		void onDebuggerResumed (object o, EventArgs e)
-		{
-			foreach (IViewContent content in ViewContentCollection) {
-				if (content.ContentName != null && content.ContentName == cur_dbgFilename) {
-					((IDebuggableEditor)content).ClearExecutingAt (cur_dbgLineNumber);
-					break;
-				}
-			}	
-		}
-
-		void onDebuggerStopped (object o, EventArgs e)
-		{
-			foreach (IViewContent content in ViewContentCollection) {
-				if (content.ContentName != null && content.ContentName == cur_dbgFilename) {
-					((IDebuggableEditor)content).ClearExecutingAt (cur_dbgLineNumber);
-					break;
-				}
-			}
-		}
-		
 		public void InitializeWorkspace()
 		{
 			// FIXME: GTKize

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs	2005-04-27 14:17:03 UTC (rev 2483)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs	2005-04-27 18:03:14 UTC (rev 2484)
@@ -199,7 +199,7 @@
 				if (currentLayout != "")
 					dockLayout.SaveLayout (currentLayout);
 				
-				string newLayout = workbench.Context.ToString () + "." + value;
+				string newLayout = workbench.Context.Id + "." + value;
 
 				if (layouts.Contains (value))
 				{
@@ -403,10 +403,13 @@
 		{
 			DockItem item = GetDockItem (content);
 			if (item != null) {
-				if (item.DefaultPosition != null)
+			
+				// TODO: ShowItem is not working properly in the
+				// managed Gdl.
+/*				if (item.DefaultPosition != null)
 					item.ShowItem();
 				else
-					DockPad (item, content.DefaultPlacement);
+*/					DockPad (item, content.DefaultPlacement);
 			}
 			else
 				AddPad (content, content.DefaultPlacement);

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Makefile.am
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Makefile.am	2005-04-27 14:17:03 UTC (rev 2483)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Makefile.am	2005-04-27 18:03:14 UTC (rev 2484)
@@ -175,6 +175,8 @@
 Commands/ToolsCommands.cs \
 Commands/ViewCommands.cs \
 Services/DebuggerService/IDebuggerService.cs \
+Services/DebuggerService/IBreakpoint.cs \
+Services/DebuggerService/BreakpointEventHandler.cs \
 Services/File/IFileService.cs \
 Services/File/DefaultFileService.cs \
 Services/File/FileEventArgs.cs \

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/MonoDevelopCore.addin.xml
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/MonoDevelopCore.addin.xml	2005-04-27 14:17:03 UTC (rev 2483)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/MonoDevelopCore.addin.xml	2005-04-27 18:03:14 UTC (rev 2484)
@@ -200,6 +200,7 @@
 				defaultHandler = "MonoDevelop.Commands.BuildHandler"
 				_label = "Buil_d" 
 				shortcut = "F8"
+				description = "Build the selected project"
 				icon  = "Icons.16x16.BuildCurrentSelectedProject" />
 		<Command id = "MonoDevelop.Commands.ProjectCommands.Rebuild"
 				defaultHandler = "MonoDevelop.Commands.RebuildHandler"
@@ -216,6 +217,9 @@
 				icon = "Icons.16x16.RunProgramIcon"
 				shortcut = "Control|F5"
 				_label = "Debug" />
+		<Command id = "MonoDevelop.Commands.ProjectCommands.DebugApplication"
+				defaultHandler = "MonoDevelop.Commands.DebugApplicationHandler"
+				_label = "Debug Application..." />
 		<Command id = "MonoDevelop.Commands.ProjectCommands.IncludeInBuild"
 				type="check"
 				_label = "Build" />
@@ -326,7 +330,6 @@
 				defaultHandler = "MonoDevelop.Commands.FullScreenHandler"
 				_label = "_Full Screen" 
 				icon = "Icons.16x16.FullScreen" 
-				shortcut = "F11"
 				description = "${res:XML.MainMenu.ViewMenu.FullScreen.Description}" />
 		<Command id = "MonoDevelop.Commands.ViewCommands.Open"
 				_label = "Open" />
@@ -805,6 +808,7 @@
 			<SeparatorItem id = "Separator1" />
 			<CommandItem id = "MonoDevelop.Commands.ProjectCommands.Run" />
 			<CommandItem id = "MonoDevelop.Commands.ProjectCommands.Debug" />
+			<CommandItem id = "MonoDevelop.Commands.ProjectCommands.DebugApplication" />
 			<SeparatorItem id = "Separator2" />
 			<CommandItem id = "MonoDevelop.Commands.ProjectCommands.Stop" />
 		</ItemSet>

Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/DebuggerService/BreakpointEventHandler.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/DebuggerService/BreakpointEventHandler.cs	2005-04-27 14:17:03 UTC (rev 2483)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/DebuggerService/BreakpointEventHandler.cs	2005-04-27 18:03:14 UTC (rev 2484)
@@ -0,0 +1,48 @@
+//
+// BreakpointEventHandler.cs
+//
+// Author:
+//   Lluis Sanchez Gual
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Services
+{
+	public delegate void BreakpointEventHandler (object sender, BreakpointEventArgs args);
+	
+	public class BreakpointEventArgs: EventArgs
+	{
+		IBreakpoint breakpoint;
+		
+		public BreakpointEventArgs (IBreakpoint breakpoint)
+		{
+			this.breakpoint = breakpoint;
+		}
+		
+		public IBreakpoint Breakpoint {
+			get { return breakpoint; }
+		}
+	}
+}

Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/DebuggerService/IBreakpoint.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/DebuggerService/IBreakpoint.cs	2005-04-27 14:17:03 UTC (rev 2483)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/DebuggerService/IBreakpoint.cs	2005-04-27 18:03:14 UTC (rev 2484)
@@ -0,0 +1,40 @@
+//
+// IBreakpoint.cs
+//
+// Author:
+//   Lluis Sanchez Gual
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using System;
+
+namespace MonoDevelop.Services
+{
+	public interface IBreakpoint
+	{
+		string FileName { get; }
+		int Line { get; }
+		bool Enabled { get; set; }
+	}
+}

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/DebuggerService/IDebuggerService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/DebuggerService/IDebuggerService.cs	2005-04-27 14:17:03 UTC (rev 2483)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/DebuggerService/IDebuggerService.cs	2005-04-27 18:03:14 UTC (rev 2484)
@@ -25,6 +25,11 @@
 		event EventHandler ResumedEvent;
 		event EventHandler StartedEvent;
 		event EventHandler StoppedEvent;
+		
+		event BreakpointEventHandler BreakpointAdded;
+		event BreakpointEventHandler BreakpointRemoved;
+		event BreakpointEventHandler BreakpointChanged;
+		event EventHandler ExecutionLocationChanged;
 
 		void Pause ();
 		void Resume ();
@@ -40,5 +45,8 @@
 		int CurrentLineNumber { get; }
 
 		string LookupValue (string expr);
+		
+		IBreakpoint[] Breakpoints { get; }
+		IBreakpoint[] GetBreakpointsAtFile (string sourceFile);
 	}
 }

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/File/DefaultFileService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/File/DefaultFileService.cs	2005-04-27 14:17:03 UTC (rev 2483)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/File/DefaultFileService.cs	2005-04-27 18:03:14 UTC (rev 2484)
@@ -89,6 +89,14 @@
 		
 		public IAsyncOperation OpenFile (string fileName, bool bringToFront)
 		{
+			foreach (IViewContent content in WorkbenchSingleton.Workbench.ViewContentCollection) {
+				if (content.ContentName == fileName) {
+					if (bringToFront)
+						content.WorkbenchWindow.SelectWindow();
+					return NullAsyncOperation.Success;
+				}
+			}
+
 			IProgressMonitor pm = Runtime.TaskService.GetStatusProgressMonitor (string.Format (GettextCatalog.GetString ("Opening {0}"), fileName), Stock.OpenFileIcon, false);
 			FileInformation openFileInfo = new FileInformation();
 			openFileInfo.ProgressMonitor = pm;
@@ -144,9 +152,9 @@
 				}
 				
 				foreach (IViewContent content in WorkbenchSingleton.Workbench.ViewContentCollection) {
-					if (content.ContentName != null && 
-						content.ContentName == fileName) {
-						content.WorkbenchWindow.SelectWindow();
+					if (content.ContentName == fileName) {
+						if (oFileInfo.BringToFront)
+							content.WorkbenchWindow.SelectWindow();
 						return;
 					}
 				}

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Project/IProjectService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Project/IProjectService.cs	2005-04-27 14:17:03 UTC (rev 2483)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Project/IProjectService.cs	2005-04-27 18:03:14 UTC (rev 2484)
@@ -108,7 +108,8 @@
 		
 		IAsyncOperation Debug (CombineEntry entry);
 		IAsyncOperation DebugFile (string sourceFile);
-		
+		IAsyncOperation DebugApplication (string executableFile);
+
 		void Deploy (Project project);
 		
 		void ShowOptions (CombineEntry entry);

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Project/ProjectService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Project/ProjectService.cs	2005-04-27 14:17:03 UTC (rev 2483)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Project/ProjectService.cs	2005-04-27 18:03:14 UTC (rev 2484)
@@ -50,6 +50,8 @@
 		IFileFormat defaultCombineFormat = new MdsFileFormat ();
 		
 		ICompilerResult lastResult = new DefaultCompilerResult ();
+		
+		GuiHelper guiHelper = new GuiHelper ();
 			
 		public Project CurrentSelectedProject {
 			get {
@@ -363,7 +365,7 @@
 			if (openCombine == null) return NullAsyncOperation.Success;
 			if (currentRunOperation != null && !currentRunOperation.IsCompleted) return currentRunOperation;
 			
-			WorkbenchSingleton.Workbench.Context = WorkbenchContext.Debug;
+			guiHelper.SetWorkbenchContext (WorkbenchContext.Debug);
 
 			IProgressMonitor monitor = new NullProgressMonitor ();
 			Runtime.DispatchService.ThreadDispatch (new StatefulMessageHandler (DebugCombineEntryAsync), new object[] {entry, monitor});
@@ -383,14 +385,9 @@
 			} finally {
 				monitor.Dispose ();
 			}
-			Runtime.DispatchService.GuiDispatch (new MessageHandler (RestoreWorkbenchContext));
+			guiHelper.SetWorkbenchContext (WorkbenchContext.Edit);
 		}
 		
-		void RestoreWorkbenchContext ()
-		{
-			WorkbenchSingleton.Workbench.Context = WorkbenchContext.Edit;
-		}
-		
 		public IAsyncOperation DebugFile (string file)
 		{
 			Project tempProject = CreateSingleFileProject (file);
@@ -406,6 +403,30 @@
 			}
 		}
 		
+		public IAsyncOperation DebugApplication (string executableFile)
+		{
+			if (currentRunOperation != null && !currentRunOperation.IsCompleted) return currentRunOperation;
+			if (Runtime.DebuggingService == null) return NullAsyncOperation.Failure;
+			
+			guiHelper.SetWorkbenchContext (WorkbenchContext.Debug);
+
+			IProgressMonitor monitor = new NullProgressMonitor ();
+
+			Runtime.DebuggingService.Run (monitor, new string[] { executableFile });
+			
+			DebugApplicationStopper disposer = new DebugApplicationStopper ();
+			disposer.Monitor = monitor;
+			Runtime.DebuggingService.StoppedEvent += new EventHandler (disposer.Run);
+			
+			currentRunOperation = monitor.AsyncOperation;
+			return currentRunOperation;
+		}
+		
+		class DebugApplicationStopper {
+			public IProgressMonitor Monitor;
+			public void Run (object sender, EventArgs e) { Monitor.Dispose (); }
+		}
+		
 		class ProjectOperationHandler {
 			public Project Project;
 			public void Run (IAsyncOperation op) { Project.Dispose (); }
@@ -1128,6 +1149,16 @@
 				if (!IsDirectoryHierarchyEmpty (dir)) return false;
 			return true;
 		}
+		
+		// All methods inside this class are gui thread safe
+		
+		class GuiHelper: GuiSyncObject
+		{
+			public void SetWorkbenchContext (WorkbenchContext ctx)
+			{
+				WorkbenchSingleton.Workbench.Context = ctx;
+			}
+		}
 
 		void OnStartBuild()
 		{




More information about the Monodevelop-patches-list mailing list