[MonoDevelop] patch to add pads to context automatically

John Luke john.luke@gmail.com
Sun, 13 Mar 2005 01:02:40 -0500


--=-DhtJaCUsQSEagm8zd4eY
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hey,
	Patch to use a IPadContent.Context to add pads to the layout instead of
hardcoding them in SdiWorkspaceLayout.cs.  This allows addins to add
pads (by context) without having to edit that file and I think just a
better way of doing it.

It is possible adding a WorkbenchContext.None is wrong as I haven't
looked for code that depended on there being only Debug and Edit values.
(I didn't really test the debugger changes ...)

Anyone object to this?

--=-DhtJaCUsQSEagm8zd4eY
Content-Disposition: attachment; filename=workbench_context.patch
Content-Type: text/x-patch; name=workbench_context.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit

Index: Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs
===================================================================
--- Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs	(revision 2328)
+++ Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs	(working copy)
@@ -255,59 +255,26 @@
 		
 		void CreateDefaultLayout()
 		{
-			string[] commonPads = new string[] {
-				"MonoDevelop.Gui.Pads.ProjectBrowser.ProjectBrowserView",
-				"MonoDevelop.Gui.Pads.ClassScout",
-				"MonoDevelop.Gui.Pads.FileScout",
-				"MonoDevelop.Gui.Pads.SideBarView",
-				"MonoDevelop.Gui.Pads.PropertyPad",
-				"MonoDevelop.Gui.Pads.OpenTaskView",
-				"MonoDevelop.Gui.Pads.HelpTree",
-//				"MonoDevelop.EditorBindings.Gui.Pads.CompilerMessageView",
-				//"MonoDevelop.Gui.Pads.TerminalPad",
-				"MonoDevelop.Gui.Pads.HelpBrowser",
-				"MonoQuery.Pads.MonoQueryView"
-			};
+			PadContentCollection collection = new PadContentCollection ();
+			PadContentCollection editCollection = (PadContentCollection) padCollections [WorkbenchContext.Edit];
+			PadContentCollection debugCollection = (PadContentCollection) padCollections [WorkbenchContext.Debug];
 
-			string[] debugPads = new string[] {
-				"MonoDevelop.SourceEditor.Gui.DebuggerLocalsPad",
-				"MonoDevelop.SourceEditor.Gui.DebuggerStackTracePad",
-				"MonoDevelop.SourceEditor.Gui.DebuggerThreadPad"
-			};
-
-			string[] editPads = new string[] {
-			};
-
-			PadContentCollection collection;
-			
-			foreach (WorkbenchContext ctxt in Enum.GetValues (typeof (WorkbenchContext)))
+			foreach (IPadContent pad in workbench.PadContentCollection)
 			{
-				collection = new PadContentCollection ();
-				padCollections [ctxt] = collection;
-				foreach (string padTypeName in commonPads)
-				{
-					IPadContent pad = workbench.PadContentCollection [padTypeName];
-					if (pad != null)
+				switch (pad.Context) {
+					case WorkbenchContext.Edit:
+						editCollection.Add (pad);
+						break;
+					case WorkbenchContext.Debug:
+						debugCollection.Add (pad);
+						break;
+					case WorkbenchContext.None:
+					default:
 						collection.Add (pad);
+						break;
 				}
 			}
-			
-			collection = (PadContentCollection) padCollections [WorkbenchContext.Edit];
-			foreach (string padTypeName in editPads)
-			{
-				IPadContent pad = workbench.PadContentCollection [padTypeName];
-				if (pad != null)
-					collection.Add (pad);
-			}
-				
-			collection = (PadContentCollection) padCollections [WorkbenchContext.Debug];
-			foreach (string padTypeName in debugPads)
-			{
-				IPadContent pad = workbench.PadContentCollection [padTypeName];
-				if (pad != null)
-					collection.Add (pad);
-			}
-				
+
 			//Console.WriteLine(" Default Layout created.");
 			dockLayout = new DockLayout (dock);
 			if (System.IO.File.Exists (configFile)) {
Index: Core/src/MonoDevelop.Base/Gui/AbstractPadContent.cs
===================================================================
--- Core/src/MonoDevelop.Base/Gui/AbstractPadContent.cs	(revision 2328)
+++ Core/src/MonoDevelop.Base/Gui/AbstractPadContent.cs	(working copy)
@@ -16,6 +16,10 @@
 	{
 		string title;
 		string icon;
+
+		public virtual WorkbenchContext Context {
+			get { return WorkbenchContext.None; }
+		}
 		
 		public abstract Gtk.Widget Control {
 			get;
Index: Core/src/MonoDevelop.Base/Gui/Pads/ClassScout/ClassScout.cs
===================================================================
--- Core/src/MonoDevelop.Base/Gui/Pads/ClassScout/ClassScout.cs	(revision 2328)
+++ Core/src/MonoDevelop.Base/Gui/Pads/ClassScout/ClassScout.cs	(working copy)
@@ -73,6 +73,10 @@
 			new DefaultDotNetClassScoutNodeBuilder()
 		};
 
+		public WorkbenchContext Context {
+			get { return WorkbenchContext.None; }
+		}
+
 		public string Title {
 			get {
 				return GettextCatalog.GetString("Classes");
Index: Core/src/MonoDevelop.Base/Gui/Pads/OpenTaskView.cs
===================================================================
--- Core/src/MonoDevelop.Base/Gui/Pads/OpenTaskView.cs	(revision 2328)
+++ Core/src/MonoDevelop.Base/Gui/Pads/OpenTaskView.cs	(working copy)
@@ -28,6 +28,10 @@
 		ListStore store;
 		Clipboard clipboard;
 		Hashtable tasks = new Hashtable ();
+
+		public WorkbenchContext Context {
+			get { return WorkbenchContext.None; }
+		}
 		
 		public Gtk.Widget Control {
 			get {
Index: Core/src/MonoDevelop.Base/Gui/Pads/DefaultMonitorPad.cs
===================================================================
--- Core/src/MonoDevelop.Base/Gui/Pads/DefaultMonitorPad.cs	(revision 2328)
+++ Core/src/MonoDevelop.Base/Gui/Pads/DefaultMonitorPad.cs	(working copy)
@@ -86,6 +86,10 @@
 			this.markupTitle = title;
 		}
 
+		public WorkbenchContext Context {
+			get { return WorkbenchContext.None; }
+		}
+
 		public IAsyncOperation AsyncOperation {
 			get {
 				return asyncOperation;
Index: Core/src/MonoDevelop.Base/Gui/Pads/ProjectBrowser/ProjectBrowserView.cs
===================================================================
--- Core/src/MonoDevelop.Base/Gui/Pads/ProjectBrowser/ProjectBrowserView.cs	(revision 2328)
+++ Core/src/MonoDevelop.Base/Gui/Pads/ProjectBrowser/ProjectBrowserView.cs	(working copy)
@@ -40,6 +40,10 @@
 		Font               boldFont  = null;
 		Gtk.Frame contentPanel = new Gtk.Frame();
 
+		public WorkbenchContext Context {
+			get { return WorkbenchContext.None; }
+		}
+
 		public Gtk.Widget Control {
 			get {
 				return contentPanel;
Index: Core/src/MonoDevelop.Base/Gui/Pads/FileScout/FileScout.cs
===================================================================
--- Core/src/MonoDevelop.Base/Gui/Pads/FileScout/FileScout.cs	(revision 2328)
+++ Core/src/MonoDevelop.Base/Gui/Pads/FileScout/FileScout.cs	(working copy)
@@ -8,6 +8,10 @@
 {
 	public class FileScout : Gtk.VPaned, IPadContent
 	{
+		public WorkbenchContext Context {
+			get { return WorkbenchContext.None; }
+		}
+
 		public Gtk.Widget Control {
 			get {
 				return this;
Index: Core/src/MonoDevelop.Base/Gui/IWorkbench.cs
===================================================================
--- Core/src/MonoDevelop.Base/Gui/IWorkbench.cs	(revision 2328)
+++ Core/src/MonoDevelop.Base/Gui/IWorkbench.cs	(working copy)
@@ -13,7 +13,8 @@
 	public enum WorkbenchContext
 	{
 		Edit,
-		Debug
+		Debug,
+		None
 	}
 	
 	/// <summary>
Index: Core/src/MonoDevelop.Base/Gui/IPadContent.cs
===================================================================
--- Core/src/MonoDevelop.Base/Gui/IPadContent.cs	(revision 2328)
+++ Core/src/MonoDevelop.Base/Gui/IPadContent.cs	(working copy)
@@ -16,6 +16,11 @@
 	/// </summary>
 	public interface IPadContent : IDisposable
 	{
+		// returns the WorkbenchContext of the pad
+		WorkbenchContext Context {
+			get;
+		}
+
 		/// <summary>
 		/// Returns the title of the pad.
 		/// </summary>
Index: Core/src/MonoDevelop.Base/ChangeLog
===================================================================
--- Core/src/MonoDevelop.Base/ChangeLog	(revision 2328)
+++ Core/src/MonoDevelop.Base/ChangeLog	(working copy)
@@ -1,3 +1,20 @@
+2005-03-09  John Luke  <john.luke@gmail.com>
+
+	* Gui/Workbench/Layouts/SdiWorkspaceLayout.cs:
+	use IPadContent.Context to load the pads in the correct
+	context instead of hardcoding them in this file, allows
+	addins to add pads to the layout easier
+	* Gui/AbstractPadContent.cs:
+	* Gui/Pads/ClassScout/ClassScout.cs:
+	* Gui/Pads/OpenTaskView.cs:
+	* Gui/Pads/DefaultMonitorPad.cs:
+	* Gui/Pads/ProjectBrowser/ProjectBrowserView.cs:
+	* Gui/Pads/FileScout/FileScout.cs:
+	add Context property to these
+	* Gui/IWorkbench.cs: add WorkbenchContext.None to represent the
+	always added Pads
+	* Gui/IPadContent.cs: add required Context get property for pads
+
 2005-03-11  Lluis Sanchez Gual  <lluis@novell.com>
 
 	* Services/Project/ProjectService.cs: Search for new files after the
Index: Core/src/AddIns/DebuggerAddIn/Gui/DebuggerStackTracePad.cs
===================================================================
--- Core/src/AddIns/DebuggerAddIn/Gui/DebuggerStackTracePad.cs	(revision 2328)
+++ Core/src/AddIns/DebuggerAddIn/Gui/DebuggerStackTracePad.cs	(working copy)
@@ -96,8 +96,10 @@
 			UpdateDisplay ();
 		}
 
+		public WorkbenchContext Context {
+			get { return WorkbenchContext.Debug; }
+		}
 
-
 		public Gtk.Widget Control {
 			get {
 				return this;
Index: Core/src/AddIns/DebuggerAddIn/Gui/DebuggerVariablePad.cs
===================================================================
--- Core/src/AddIns/DebuggerAddIn/Gui/DebuggerVariablePad.cs	(revision 2328)
+++ Core/src/AddIns/DebuggerAddIn/Gui/DebuggerVariablePad.cs	(working copy)
@@ -519,6 +519,10 @@
 			}
 		}
 
+		public WorkbenchContext Context {
+			get { return WorkbenchContext.Debug; }
+		}
+
 		Hashtable iters = null;
 
 		public void CleanDisplay ()
Index: Core/src/AddIns/DebuggerAddIn/Gui/DebuggerThreadPad.cs
===================================================================
--- Core/src/AddIns/DebuggerAddIn/Gui/DebuggerThreadPad.cs	(revision 2328)
+++ Core/src/AddIns/DebuggerAddIn/Gui/DebuggerThreadPad.cs	(working copy)
@@ -117,6 +117,10 @@
 			UpdateDisplay ();
 		}
 
+		public WorkbenchContext Context {
+			get { return WorkbenchContext.Debug; }
+		}
+
 		public Gtk.Widget Control {
 			get {
 				return this;
Index: Core/src/AddIns/DebuggerAddIn/Gui/DebuggerLocalsPad.cs
===================================================================
--- Core/src/AddIns/DebuggerAddIn/Gui/DebuggerLocalsPad.cs	(revision 2328)
+++ Core/src/AddIns/DebuggerAddIn/Gui/DebuggerLocalsPad.cs	(working copy)
@@ -10,6 +10,10 @@
 		{
 		}
 
+		public WorkbenchContext Context {
+			get { return WorkbenchContext.Debug; }
+		}
+
 		public Gtk.Widget Control {
 			get {
 				return this;
Index: Core/src/AddIns/DebuggerAddIn/ChangeLog
===================================================================
--- Core/src/AddIns/DebuggerAddIn/ChangeLog	(revision 2328)
+++ Core/src/AddIns/DebuggerAddIn/ChangeLog	(working copy)
@@ -1,3 +1,11 @@
+2005-03-13  John Luke  <john.luke@gmail.com>
+
+	* Gui/DebuggerVariablePad.cs:
+	* Gui/DebuggerLocalsPad.cs:
+	* Gui/DebuggerThreadPad.cs:
+	* Gui/DebuggerStackTracePad.cs: add Context property to work with
+	new api in MD
+
 2005-03-02  Chris Toshok  <toshok@ximian.com>
 
 	* Gui/DebuggerVariablePad.cs (DebuggerVariablePad.ctor): add a

--=-DhtJaCUsQSEagm8zd4eY--