[Monodevelop-patches-list] r2501 - in trunk/MonoDevelop/Core/src/MonoDevelop.Base: . Commands Gui Gui/Pads Gui/Pads/FileScout Gui/Pads/SolutionPad Gui/Workbench Internal/Project/Project Services Services/ProcessService Services/Tasks

Lluis Sanchez <lluis@ximian.com> lluis at mono-cvs.ximian.com
Mon May 2 20:26:21 EDT 2005


Author: lluis
Date: 2005-05-02 20:26:20 -0400 (Mon, 02 May 2005)
New Revision: 2501

Added:
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ProcessService/IProcessHost.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ProcessService/IProcessHostController.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ProcessService/ProcessHostController.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ProcessService/RemoteProcessObject.cs
Modified:
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Commands/ProjectCommands.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/AbstractPadContent.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/IPadContent.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/IWorkbench.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/DefaultMonitorPad.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/FileScout/FileList.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/FileScout/FileScout.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/OpenTaskView.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/SolutionPad/TreeViewPad.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/TerminalPad.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/DefaultWorkbench.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Project/DotNetProjectBinding.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Makefile.am
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ProcessService/ProcessService.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/SystemAssemblyService.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Tasks/TaskService.cs
Log:
2005-05-03  Lluis Sanchez Gual  <lluis at novell.com> 

	* Commands/ProjectCommands.cs: The Build command should compile the
	current file before running.
	
	* Services/Tasks/TaskService.cs:
	* Gui/Workbench/DefaultWorkbench.cs:
	* Gui/Pads/SolutionPad/TreeViewPad.cs:
	* Gui/Pads/OpenTaskView.cs:
	* Gui/Pads/TerminalPad.cs:
	* Gui/Pads/DefaultMonitorPad.cs:
	* Gui/Pads/FileScout/FileScout.cs:
	* Gui/AbstractPadContent.cs:
	* Gui/IWorkbench.cs:
	* Gui/IPadContent.cs:
	Removed BringToFront from IPadContent, and moved to IWorkbench.
	
	* Services/SystemAssemblyService.cs: Lazy load system assembly
	information. This speeds up MD startup time.
	
	* Services/ProcessService/ProcessService.cs:
	* Services/ProcessService/IProcessHost.cs:
	* Services/ProcessService/IProcessHostController.cs:
	* Services/ProcessService/ProcessHostController.cs:
	* Services/ProcessService/RemoteProcessObject.cs:
	* Makefile.am:
	Added new api for creating out-of-process objects.
	
	* Gui/Pads/FileScout/FileList.cs: Fix warnings.
	
	* Internal/Project/Project/DotNetProjectBinding.cs: Set the correct
	paths for single file projects.



Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog	2005-05-02 23:48:49 UTC (rev 2500)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog	2005-05-03 00:26:20 UTC (rev 2501)
@@ -1,3 +1,36 @@
+2005-05-03  Lluis Sanchez Gual  <lluis at novell.com> 
+
+	* Commands/ProjectCommands.cs: The Build command should compile the
+	current file before running.
+	
+	* Services/Tasks/TaskService.cs:
+	* Gui/Workbench/DefaultWorkbench.cs:
+	* Gui/Pads/SolutionPad/TreeViewPad.cs:
+	* Gui/Pads/OpenTaskView.cs:
+	* Gui/Pads/TerminalPad.cs:
+	* Gui/Pads/DefaultMonitorPad.cs:
+	* Gui/Pads/FileScout/FileScout.cs:
+	* Gui/AbstractPadContent.cs:
+	* Gui/IWorkbench.cs:
+	* Gui/IPadContent.cs:
+	Removed BringToFront from IPadContent, and moved to IWorkbench.
+	
+	* Services/SystemAssemblyService.cs: Lazy load system assembly
+	information. This speeds up MD startup time.
+	
+	* Services/ProcessService/ProcessService.cs:
+	* Services/ProcessService/IProcessHost.cs:
+	* Services/ProcessService/IProcessHostController.cs:
+	* Services/ProcessService/ProcessHostController.cs:
+	* Services/ProcessService/RemoteProcessObject.cs:
+	* Makefile.am:
+	Added new api for creating out-of-process objects.
+	
+	* Gui/Pads/FileScout/FileList.cs: Fix warnings.
+	
+	* Internal/Project/Project/DotNetProjectBinding.cs: Set the correct
+	paths for single file projects.
+
 2005-04-30  Lluis Sanchez Gual  <lluis at novell.com> 
 
 	* Commands/ProjectCommands.cs: Added new build and run commands.

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Commands/ProjectCommands.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Commands/ProjectCommands.cs	2005-05-02 23:48:49 UTC (rev 2500)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Commands/ProjectCommands.cs	2005-05-03 00:26:20 UTC (rev 2501)
@@ -61,7 +61,7 @@
 			} else {
 				if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow != null) {
 					file = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.ContentName;
-					IAsyncOperation op = Runtime.ProjectService.ExecuteFile (file);
+					IAsyncOperation op = Runtime.ProjectService.BuildFile (file);
 					op.Completed += new OperationHandler (ExecuteFile);
 				}
 			}
@@ -132,7 +132,7 @@
 			} else {
 				if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow != null) {
 					file = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.ContentName;
-					IAsyncOperation op = Runtime.ProjectService.ExecuteFile (file);
+					IAsyncOperation op = Runtime.ProjectService.BuildFile (file);
 					op.Completed += new OperationHandler (ExecuteFile);
 				}
 			}
@@ -234,7 +234,7 @@
 				if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow != null) {
 					info.Enabled = Runtime.ProjectService.CurrentBuildOperation.IsCompleted;
 					string file = Path.GetFileName (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.ContentName);
-					info.Text = string.Format (GettextCatalog.GetString ("Build {0}"), file);
+					info.Text = info.Description = string.Format (GettextCatalog.GetString ("Build {0}"), file);
 				} else {
 					info.Enabled = false;
 				}

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/AbstractPadContent.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/AbstractPadContent.cs	2005-05-02 23:48:49 UTC (rev 2500)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/AbstractPadContent.cs	2005-05-03 00:26:20 UTC (rev 2501)
@@ -81,14 +81,5 @@
 		
 		public event EventHandler TitleChanged;
 		public event EventHandler IconChanged;
-		
-		public void BringToFront()
-		{
-			if (!WorkbenchSingleton.Workbench.WorkbenchLayout.IsVisible(this)) {
-				WorkbenchSingleton.Workbench.WorkbenchLayout.ShowPad(this);
-			}
-			WorkbenchSingleton.Workbench.WorkbenchLayout.ActivatePad(this);
-		}
-
 	}
 }

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/IPadContent.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/IPadContent.cs	2005-05-02 23:48:49 UTC (rev 2500)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/IPadContent.cs	2005-05-03 00:26:20 UTC (rev 2501)
@@ -73,10 +73,5 @@
 		/// Is called when the icon of this pad has changed.
 		/// </summary>
 		event EventHandler IconChanged;
-		
-		/// <summary>
-		/// Tries to make the pad visible to the user.
-		/// </summary>
-		void BringToFront();
 	}
 }

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/IWorkbench.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/IWorkbench.cs	2005-05-02 23:48:49 UTC (rev 2500)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/IWorkbench.cs	2005-05-03 00:26:20 UTC (rev 2501)
@@ -98,6 +98,11 @@
 		IPadContent GetPad(Type type);
 		
 		/// <summary>
+		/// Tries to make the pad visible to the user.
+		/// </summary>
+		void BringToFront (IPadContent content);
+		
+		/// <summary>
 		/// Closes the IViewContent content when content is open.
 		/// </summary>
 		void CloseContent(IViewContent content);

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/DefaultMonitorPad.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/DefaultMonitorPad.cs	2005-05-02 23:48:49 UTC (rev 2500)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/DefaultMonitorPad.cs	2005-05-03 00:26:20 UTC (rev 2501)
@@ -230,14 +230,5 @@
 
 		public event EventHandler TitleChanged;
 		public event EventHandler IconChanged;
-
-		public void BringToFront()
-		{
-			if (!WorkbenchSingleton.Workbench.WorkbenchLayout.IsVisible(this)) {
-				WorkbenchSingleton.Workbench.WorkbenchLayout.ShowPad(this);
-			}
-			WorkbenchSingleton.Workbench.WorkbenchLayout.ActivatePad(this);
-		}
-
 	}
 }

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/FileScout/FileList.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/FileScout/FileList.cs	2005-05-02 23:48:49 UTC (rev 2500)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/FileScout/FileList.cs	2005-05-03 00:26:20 UTC (rev 2501)
@@ -22,7 +22,6 @@
 		private FileSystemWatcher watcher;
 		private ArrayList Items;
 		private Gtk.ListStore store;
-		private Gtk.Menu popmenu = null;
 		FileListItem selectedItem = null;
 		Gtk.TreeIter selectedIter;
 		

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/FileScout/FileScout.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/FileScout/FileScout.cs	2005-05-02 23:48:49 UTC (rev 2500)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/FileScout/FileScout.cs	2005-05-03 00:26:20 UTC (rev 2501)
@@ -22,10 +22,6 @@
 			}
 		}
 		
-		public void BringToFront() {
-			// TODO
-		}
-		
 		public string Title {
 			get {
 				return GettextCatalog.GetString ("Files");

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/OpenTaskView.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/OpenTaskView.cs	2005-05-02 23:48:49 UTC (rev 2500)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/OpenTaskView.cs	2005-05-03 00:26:20 UTC (rev 2501)
@@ -138,10 +138,6 @@
 			clipboard.SetText (task.ToString ());
 		}
 		
-		void MarkupCol (Gtk.TreeViewColumn col)
-		{
-		}
-		
 		void AddColumns ()
 		{
 			Gtk.CellRendererPixbuf iconRender = new Gtk.CellRendererPixbuf ();
@@ -283,14 +279,6 @@
 		
 		public event EventHandler TitleChanged, IconChanged;
 		
-		public void BringToFront ()
-		{
-			if (!WorkbenchSingleton.Workbench.WorkbenchLayout.IsVisible (this))
-				WorkbenchSingleton.Workbench.WorkbenchLayout.ShowPad (this);
-			
-			WorkbenchSingleton.Workbench.WorkbenchLayout.ActivatePad (this);
-		}
-		
 		private void ItemToggled (object o, ToggledArgs args)
 		{
 			Gtk.TreeIter iter;

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/SolutionPad/TreeViewPad.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/SolutionPad/TreeViewPad.cs	2005-05-02 23:48:49 UTC (rev 2500)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/SolutionPad/TreeViewPad.cs	2005-05-03 00:26:20 UTC (rev 2501)
@@ -114,10 +114,6 @@
 			}
 		}
 
-		public void BringToFront() {
-			// TODO FIXME
-		}
-		
 		public string Title {
 			get { return title; }
 			set { title = value; }

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/TerminalPad.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/TerminalPad.cs	2005-05-02 23:48:49 UTC (rev 2500)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/TerminalPad.cs	2005-05-03 00:26:20 UTC (rev 2501)
@@ -176,15 +176,6 @@
 
 		public event EventHandler IconChanged;
 		public event EventHandler TitleChanged;
-
-		public void BringToFront()
-		{
-			if (!WorkbenchSingleton.Workbench.WorkbenchLayout.IsVisible (this)) {
-				WorkbenchSingleton.Workbench.WorkbenchLayout.ShowPad (this);
-			}
-
-			WorkbenchSingleton.Workbench.WorkbenchLayout.ActivatePad (this);
-		}
 	}
 }
 

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/DefaultWorkbench.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/DefaultWorkbench.cs	2005-05-02 23:48:49 UTC (rev 2500)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/DefaultWorkbench.cs	2005-05-03 00:26:20 UTC (rev 2501)
@@ -266,6 +266,14 @@
 				layout.ShowPad (content);
 		}
 		
+		public virtual void BringToFront (IPadContent content)
+		{
+			if (!layout.IsVisible (content))
+				layout.ShowPad (content);
+
+			layout.ActivatePad (content);
+		}
+		
 		public void RedrawAllComponents()
 		{
 			foreach (IViewContent content in workbenchContentCollection) {

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Project/DotNetProjectBinding.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Project/DotNetProjectBinding.cs	2005-05-02 23:48:49 UTC (rev 2500)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Project/DotNetProjectBinding.cs	2005-05-03 00:26:20 UTC (rev 2501)
@@ -27,6 +27,7 @@
 //
 
 using System;
+using System.IO;
 using System.Xml;
 using MonoDevelop.Internal.Serialization;
 using MonoDevelop.Internal.Templates;
@@ -57,7 +58,10 @@
 		{
 			ILanguageBinding binding = Runtime.Languages.GetBindingPerFileName (file);
 			if (binding != null) {
-				Project project = CreateProject (binding.Language, null, null);
+				ProjectCreateInformation info = new ProjectCreateInformation ();
+				info.ProjectName = Path.GetFileNameWithoutExtension (file);
+				info.CombinePath = Path.GetDirectoryName (file);
+				Project project = CreateProject (binding.Language, info, null);
 				project.ProjectFiles.Add (new ProjectFile (file));
 				return project;
 			}

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Makefile.am
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Makefile.am	2005-05-02 23:48:49 UTC (rev 2500)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Makefile.am	2005-05-03 00:26:20 UTC (rev 2501)
@@ -8,6 +8,7 @@
 	/r:System.Data.dll /r:System.Web.Services.dll \
 	/r:$(top_builddir)/build/bin/MonoDevelop.Dock.dll \
 	/r:Mono.Posix.dll \
+	/r:System.Runtime.Remoting \
 	/r:$(top_builddir)/build/bin/log4net.dll \
 	$(GTK_SHARP_LIBS) \
 	$(GNOME_SHARP_LIBS) \
@@ -199,6 +200,10 @@
 Services/AmbienceService/IAmbience.cs \
 Services/ProcessService/ProcessService.cs \
 Services/ProcessService/ProcessWrapper.cs \
+Services/ProcessService/IProcessHost.cs \
+Services/ProcessService/IProcessHostController.cs \
+Services/ProcessService/ProcessHostController.cs \
+Services/ProcessService/RemoteProcessObject.cs \
 Services/Project/ProjectEventArgs.cs \
 Services/Project/IProjectService.cs \
 Services/Project/ProjectRenameEventArgs.cs \

Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ProcessService/IProcessHost.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ProcessService/IProcessHost.cs	2005-05-02 23:48:49 UTC (rev 2500)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ProcessService/IProcessHost.cs	2005-05-03 00:26:20 UTC (rev 2501)
@@ -0,0 +1,39 @@
+//
+// IProcessHost.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 IProcessHost
+	{
+		RemoteProcessObject CreateInstance (Type type);
+		RemoteProcessObject CreateInstance (string fullTypeName);
+		RemoteProcessObject CreateInstance (string assemblyPath, string typeName);
+	}
+}

Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ProcessService/IProcessHostController.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ProcessService/IProcessHostController.cs	2005-05-02 23:48:49 UTC (rev 2500)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ProcessService/IProcessHostController.cs	2005-05-03 00:26:20 UTC (rev 2501)
@@ -0,0 +1,37 @@
+//
+// IProcessHostController.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.
+//
+
+namespace MonoDevelop.Services
+{
+	public interface IProcessHostController
+	{
+		void RegisterHost (IProcessHost processHost);
+		void WaitForExit ();
+		void ReleaseInstance (RemoteProcessObject proc);
+	}
+}

Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ProcessService/ProcessHostController.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ProcessService/ProcessHostController.cs	2005-05-02 23:48:49 UTC (rev 2500)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ProcessService/ProcessHostController.cs	2005-05-03 00:26:20 UTC (rev 2501)
@@ -0,0 +1,210 @@
+//
+// ProcessHostController.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;
+using System.IO;
+using System.Diagnostics;
+using System.Runtime.Remoting;
+using System.Runtime.Remoting.Channels.Tcp;
+using System.Runtime.Remoting.Channels;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Threading;
+
+namespace MonoDevelop.Services
+{
+	internal class ProcessHostController: MarshalByRefObject, IProcessHostController
+	{
+		int references;
+		uint stopDelay;
+		DateTime lastReleaseTime;
+		bool starting;
+		bool stopping;
+		Process process;
+
+		IProcessHost processHost;
+		ManualResetEvent runningEvent = new ManualResetEvent (false);
+		ManualResetEvent exitRequestEvent = new ManualResetEvent (false);
+		ManualResetEvent exitedEvent = new ManualResetEvent (false);
+		
+		public ProcessHostController (uint stopDelay)
+		{
+			this.stopDelay = stopDelay;
+		}
+		
+		public void Start ()
+		{
+			lock (this)
+			{
+				if (starting) return;
+				starting = true;
+				exitRequestEvent.Reset ();
+				
+				IChannel ch = ChannelServices.GetChannel ("tcp");
+				if (ch == null)
+					ChannelServices.RegisterChannel (new TcpChannel (0));
+				
+				BinaryFormatter bf = new BinaryFormatter ();
+				ObjRef oref = RemotingServices.Marshal (this);
+				MemoryStream ms = new MemoryStream ();
+				bf.Serialize (ms, oref);
+				string sref = Convert.ToBase64String (ms.ToArray ());
+
+				try {
+					process = new Process ();
+					process.Exited += new EventHandler (ProcessExited);
+					process.StartInfo = new ProcessStartInfo ("sh", "-c \"mono mdhost.exe " + sref + "\"");
+					process.StartInfo.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory;
+					process.StartInfo.UseShellExecute = false;
+					process.EnableRaisingEvents = true;
+					process.Start ();
+				} catch (Exception ex) {
+					Console.WriteLine (ex);
+					throw;
+				}
+			}
+		}
+		
+		void ProcessExited (object sender, EventArgs args)
+		{
+			lock (this) {
+				exitedEvent.Set ();
+				Process p = (Process) sender;
+				if (p != process) return;
+
+				// The process suddently died
+				runningEvent.Reset ();
+				processHost = null;
+				process = null;
+				
+				if (references > 0)
+					Start ();
+			}
+		}
+		
+		public RemoteProcessObject CreateInstance (Type type)
+		{
+			lock (this) {
+				references++;
+				if (processHost == null)
+					Start ();
+			}
+			
+			if (!runningEvent.WaitOne (15000, false)) {
+				references--;
+				throw new ApplicationException ("Couldn't create a remote process.");
+			}
+			
+			return processHost.CreateInstance (type);
+		}
+		
+		public RemoteProcessObject CreateInstance (string assemblyPath, string typeName)
+		{
+			lock (this) {
+				references++;
+				if (processHost == null)
+					Start ();
+			}
+			
+			if (!runningEvent.WaitOne (15000, false)) {
+				references--;
+				throw new ApplicationException ("Couldn't create a remote process.");
+			}
+			
+			return processHost.CreateInstance (assemblyPath, typeName);
+		}
+		
+		public void ReleaseInstance (RemoteProcessObject proc)
+		{
+			if (processHost == null) return;
+			
+			lock (this) {
+				references--;
+				if (references == 0) {
+					lastReleaseTime = DateTime.Now;
+					if (!stopping) {
+						stopping = true;
+						GLib.Timeout.Add (stopDelay, new GLib.TimeoutHandler (WaitTimeout));
+					}
+				}
+			}
+		}
+		
+		bool WaitTimeout ()
+		{
+			try {
+				Process oldProcess;
+				
+				lock (this) {
+					if (references > 0) {
+						stopping = false;
+						return false;
+					}
+	
+					uint waited = (uint) (DateTime.Now - lastReleaseTime).TotalMilliseconds;
+					if (waited < stopDelay) {
+						GLib.Timeout.Add (stopDelay - waited, new GLib.TimeoutHandler (WaitTimeout));
+						return false;
+					}
+				
+					runningEvent.Reset ();
+					exitedEvent.Reset ();
+					exitRequestEvent.Set ();
+					oldProcess = process;
+					processHost = null;
+					process = null;
+					stopping = false;
+				}
+	
+				if (!exitedEvent.WaitOne (2000, false)) {
+					try {
+						oldProcess.Kill ();
+					} catch {
+					}
+				}
+			} catch (Exception ex) {
+				Console.WriteLine (ex);
+			}
+			return false;
+		}
+		
+		public void RegisterHost (IProcessHost processHost)
+		{
+			lock (this)
+			{
+				this.processHost = processHost;
+				runningEvent.Set ();
+				starting = false;
+			}
+		}
+		
+		public void WaitForExit ()
+		{
+			exitRequestEvent.WaitOne ();
+		}
+	}
+}

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ProcessService/ProcessService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ProcessService/ProcessService.cs	2005-05-02 23:48:49 UTC (rev 2500)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ProcessService/ProcessService.cs	2005-05-03 00:26:20 UTC (rev 2501)
@@ -11,6 +11,8 @@
 {
 	public class ProcessService : AbstractService
 	{
+		ProcessHostController externalProcess;
+		
 		public ProcessWrapper StartProcess (string command, string arguments, string workingDirectory, EventHandler exited) 
 		{
 			return StartProcess (command, arguments, workingDirectory, (ProcessEventHandler)null, (ProcessEventHandler)null, exited);	
@@ -106,6 +108,34 @@
 				return pw;
 			}
 		}
+		
+		ProcessHostController GetHost (bool shared)
+		{
+			if (!shared)
+				return new ProcessHostController (0);
+			
+			lock (this) {
+				if (externalProcess == null)
+					externalProcess = new ProcessHostController (10000);
+	
+				return externalProcess;
+			}
+		}
+		
+		public RemoteProcessObject CreateExternalProcessObject (Type type)
+		{
+			return CreateExternalProcessObject (type, true);
+		}
+		
+		public RemoteProcessObject CreateExternalProcessObject (Type type, bool shared)
+		{
+			return GetHost (shared).CreateInstance (type);
+		}
+		
+		public RemoteProcessObject CreateExternalProcessObject (string assemblyPath, string typeName, bool shared)
+		{
+			return GetHost (shared).CreateInstance (assemblyPath, typeName);
+		}
 	}
 	
 	class ProcessMonitor

Added: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ProcessService/RemoteProcessObject.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ProcessService/RemoteProcessObject.cs	2005-05-02 23:48:49 UTC (rev 2500)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ProcessService/RemoteProcessObject.cs	2005-05-03 00:26:20 UTC (rev 2501)
@@ -0,0 +1,55 @@
+//
+// RemoteProcessObject.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 class RemoteProcessObject: MarshalByRefObject, IDisposable
+	{
+		IProcessHostController controller;
+		
+		public void Attach (IProcessHostController controller)
+		{
+			this.controller = controller;
+		}
+		
+		public void Dispose ()
+		{
+			if (controller != null) {
+				controller.ReleaseInstance (this);
+				controller = null;
+			}
+		}
+		
+		~RemoteProcessObject ()
+		{
+			Dispose ();
+		}
+	}
+}

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/SystemAssemblyService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/SystemAssemblyService.cs	2005-05-02 23:48:49 UTC (rev 2500)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/SystemAssemblyService.cs	2005-05-03 00:26:20 UTC (rev 2501)
@@ -10,16 +10,23 @@
 	{
 		Hashtable assemblyPathToPackage = new Hashtable ();
 		Hashtable assemblyFullNameToPath = new Hashtable ();
+		bool initialized;
 
 		public ICollection AssemblyPaths
 		{
 			get {
+				if (!initialized)
+					Initialize ();
+					
 				return assemblyPathToPackage.Keys;
 			}
 		}
 
 		public string GetPackageFromFullName (string fullname)
 		{
+			if (!initialized)
+				Initialize ();
+					
 			if (!assemblyFullNameToPath.Contains (fullname))
 				return String.Empty;
 			
@@ -30,9 +37,10 @@
 			return (string)assemblyPathToPackage[path];
 		}
 	
-		public override void InitializeService ()
+		new void Initialize ()
 		{
-			base.InitializeService ();
+			initialized = true;
+
 			//Pull up assemblies from the installed mono system.
 			string prefix = Path.GetDirectoryName (typeof (int).Assembly.Location);
 			if (prefix.IndexOf ("mono/1.0") == -1) {

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Tasks/TaskService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Tasks/TaskService.cs	2005-05-02 23:48:49 UTC (rev 2500)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Tasks/TaskService.cs	2005-05-03 00:26:20 UTC (rev 2501)
@@ -80,7 +80,7 @@
 					}
 				}
 				if (pad != null) {
-					if (bringToFront) pad.BringToFront ();
+					if (bringToFront) Runtime.Gui.Workbench.BringToFront (pad);
 					return new OutputProgressMonitor (pad, title, icon);
 				}
 			}
@@ -88,7 +88,7 @@
 			DefaultMonitorPad monitorPad = new DefaultMonitorPad (title, icon);
 			monitorPad.Id = "OutputPad" + (monitorId++);
 			Runtime.Gui.Workbench.ShowPad (monitorPad);
-			if (bringToFront) monitorPad.BringToFront ();
+			if (bringToFront) Runtime.Gui.Workbench.BringToFront (monitorPad);
 
 			return new OutputProgressMonitor (monitorPad, title, icon);
 		}
@@ -179,7 +179,7 @@
 		void ShowTasksCallback ()
 		{
 			OpenTaskView taskView = Runtime.Gui.Workbench.GetPad(typeof(OpenTaskView)) as OpenTaskView;
-			if (taskView != null) taskView.BringToFront();
+			if (taskView != null) Runtime.Gui.Workbench.BringToFront (taskView);
 		}
 		
 		protected virtual void OnCompilerOutputChanged(EventArgs e)




More information about the Monodevelop-patches-list mailing list