[Monodevelop-patches-list] r2565 - in trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets: . Commands

Lluis Sanchez <lluis@ximian.com> lluis at mono-cvs.ximian.com
Mon May 30 03:18:31 EDT 2005


Author: lluis
Date: 2005-05-30 03:18:31 -0400 (Mon, 30 May 2005)
New Revision: 2565

Added:
   trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/Commands/CommandErrorHandler.cs
Modified:
   trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/ChangeLog
   trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/Commands/CommandManager.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/Commands/CommandToolButton.cs
   trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/Makefile.am
Log:
2005-05-30  Lluis Sanchez Gual  <lluis at novell.com>

	* Commands/CommandToolButton.cs: Only update button properties if
	they have really changed.
	* Commands/CommandManager.cs: Report errors using a new CommandError
	event.
	* Commands/CommandErrorHandler.cs: New delegate and event args for the
	CommandError event.



Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/ChangeLog	2005-05-30 04:31:12 UTC (rev 2564)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/ChangeLog	2005-05-30 07:18:31 UTC (rev 2565)
@@ -1,3 +1,12 @@
+2005-05-30  Lluis Sanchez Gual  <lluis at novell.com>
+
+	* Commands/CommandToolButton.cs: Only update button properties if
+	they have really changed.
+	* Commands/CommandManager.cs: Report errors using a new CommandError
+	event.
+	* Commands/CommandErrorHandler.cs: New delegate and event args for the
+	CommandError event.
+
 2005-05-15  Lluis Sanchez Gual  <lluis at novell.com>
 
 	* FileBrowser/FileBrowser.cs: Catch UnauthorizedAccessException errors.

Added: trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/Commands/CommandErrorHandler.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/Commands/CommandErrorHandler.cs	2005-05-30 04:31:12 UTC (rev 2564)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/Commands/CommandErrorHandler.cs	2005-05-30 07:18:31 UTC (rev 2565)
@@ -0,0 +1,60 @@
+//
+// CommandErrorHandler.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.Commands
+{
+	public delegate void CommandErrorHandler (object sender, CommandErrorArgs args);
+	
+	public class CommandErrorArgs
+	{
+		object commandId;
+		string errorMessage;
+		Exception ex;
+		
+		public CommandErrorArgs (object commandId, string errorMessage, Exception ex)
+		{
+			this.errorMessage = errorMessage;
+			this.commandId = commandId;
+			this.ex = ex;
+		}
+		
+		public object CommandId {
+			get { return commandId; }
+		}
+		
+		public string ErrorMessage {
+			get { return errorMessage; }
+		}
+		
+		public Exception Exception {
+			get { return ex; }
+		}
+	}
+}

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/Commands/CommandManager.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/Commands/CommandManager.cs	2005-05-30 04:31:12 UTC (rev 2564)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/Commands/CommandManager.cs	2005-05-30 07:18:31 UTC (rev 2565)
@@ -174,7 +174,7 @@
 				return cmd.DispatchCommand (dataItem);
 			}
 			catch (Exception ex) {
-				ReportError ("Error while executing command: " + commandId, ex);
+				ReportError (commandId, "Error while executing command: " + commandId, ex);
 				return false;
 			}
 		}
@@ -219,7 +219,7 @@
 			catch (Exception ex) {
 				if (!commandUpdateErrors.Contains (commandId)) {
 					commandUpdateErrors.Add (commandId);
-					ReportError ("Error while updating status of command: " + commandId, ex);
+					ReportError (commandId, "Error while updating status of command: " + commandId, ex);
 				}
 				info.Enabled = false;
 				info.Visible = true;
@@ -361,18 +361,15 @@
 			}
 		}
 		
-		public void ReportError (string message, Exception ex)
+		public void ReportError (object commandId, string message, Exception ex)
 		{
-			string msg = ex.ToString();
-			msg = msg.Replace ("<","");
-			msg = msg.Replace (">","");
-			msg = "<b>" + message + "</b>\n\nException ocurred: " + msg;
-			
-			Gtk.MessageDialog md = new Gtk.MessageDialog (null, Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, msg);
-			md.Run ();
-			md.Destroy ();
-			md.Dispose ();
+			if (CommandError != null) {
+				CommandErrorArgs args = new CommandErrorArgs (commandId, message, ex);
+				CommandError (this, args);
+			}
 		}
+		
+		public event CommandErrorHandler CommandError;
 	}
 	
 	internal class HandlerTypeInfo

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/Commands/CommandToolButton.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/Commands/CommandToolButton.cs	2005-05-30 04:31:12 UTC (rev 2564)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/Commands/CommandToolButton.cs	2005-05-30 07:18:31 UTC (rev 2565)
@@ -41,6 +41,7 @@
 		{
 			this.commandId = commandId;
 			this.commandManager = commandManager;
+			UseUnderline = true;
 		}
 		
 		protected override void OnParentSet (Gtk.Widget parent)
@@ -75,11 +76,14 @@
 				SetTooltip (tips, cmdInfo.Description, cmdInfo.Description);
 				lastDesc = cmdInfo.Description;
 			}
-			UseUnderline = true;
-			Label = cmdInfo.Text;
-			StockId = cmdInfo.Icon;
-			Sensitive = cmdInfo.Enabled;
-			Visible = cmdInfo.Visible;
+			if (Label != cmdInfo.Text)
+				Label = cmdInfo.Text;
+			if (cmdInfo.Icon != StockId)
+				StockId = cmdInfo.Icon;
+			if (cmdInfo.Enabled != Sensitive)
+				Sensitive = cmdInfo.Enabled;
+			if (cmdInfo.Visible != Visible)
+				Visible = cmdInfo.Visible;
 		}
 	}
 }

Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/Makefile.am
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/Makefile.am	2005-05-30 04:31:12 UTC (rev 2564)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/Makefile.am	2005-05-30 07:18:31 UTC (rev 2565)
@@ -35,6 +35,7 @@
 Commands/Command.cs \
 Commands/CommandEntry.cs \
 Commands/CommandEntrySet.cs \
+Commands/CommandErrorHandler.cs \
 Commands/CommandHandlerAttribute.cs \
 Commands/CommandHandler.cs \
 Commands/CommandInfo.cs \




More information about the Monodevelop-patches-list mailing list