[Monodevelop-patches-list] r2479 - trunk/MonoDevelop/Extras/MonoDeveloperExtensions

Lluis Sanchez <lluis@ximian.com> lluis at mono-cvs.ximian.com
Mon Apr 25 16:37:24 EDT 2005


Author: lluis
Date: 2005-04-25 16:37:23 -0400 (Mon, 25 Apr 2005)
New Revision: 2479

Modified:
   trunk/MonoDevelop/Extras/MonoDeveloperExtensions/ChangeLog
   trunk/MonoDevelop/Extras/MonoDeveloperExtensions/Commands.cs
   trunk/MonoDevelop/Extras/MonoDeveloperExtensions/Makefile.am
   trunk/MonoDevelop/Extras/MonoDeveloperExtensions/MonoDeveloperExtensions.addin.xml
Log:
2005-04-25  Lluis Sanchez Gual  <lluis at novell.com>

	* MonoDeveloperExtensions.addin.xml:
	* Commands.cs: Use the new command service. Added hacky support for
	basic svn operations.



Modified: trunk/MonoDevelop/Extras/MonoDeveloperExtensions/ChangeLog
===================================================================
--- trunk/MonoDevelop/Extras/MonoDeveloperExtensions/ChangeLog	2005-04-25 20:37:04 UTC (rev 2478)
+++ trunk/MonoDevelop/Extras/MonoDeveloperExtensions/ChangeLog	2005-04-25 20:37:23 UTC (rev 2479)
@@ -1,3 +1,9 @@
+2005-04-25  Lluis Sanchez Gual  <lluis at novell.com>
+
+	* MonoDeveloperExtensions.addin.xml:
+	* Commands.cs: Use the new command service. Added hacky support for
+	basic svn operations.
+
 2005-04-17  John Luke  <john.luke at gmail.com>
 
 	* Makefile.am: fix distcheck

Modified: trunk/MonoDevelop/Extras/MonoDeveloperExtensions/Commands.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoDeveloperExtensions/Commands.cs	2005-04-25 20:37:04 UTC (rev 2478)
+++ trunk/MonoDevelop/Extras/MonoDeveloperExtensions/Commands.cs	2005-04-25 20:37:23 UTC (rev 2479)
@@ -27,22 +27,42 @@
 //
 
 using System;
+using System.IO;
 using MonoDevelop.Internal.Project;
 using MonoDevelop.Services;
 using MonoDevelop.Core.AddIns.Codons;
+using MonoDevelop.Gui.Pads;
+using MonoDevelop.Gui.Pads.ProjectPad;
+using MonoDevelop.Commands;
 
 namespace MonoDeveloper
 {	
-	class InstallCommand: AbstractMenuCommand
+	public enum Commands
 	{
-		public override void Run()
+		Install,
+		SvnDiff,
+		SvnUpdate,
+		SvnStat,
+		SvnInfo,
+		SvnAdd,
+		SvnRevert,
+		SvnCommit
+	}
+	
+	public class InstallHandler: CommandHandler
+	{
+		protected override void Run ()
 		{
 			MonoProject p = Runtime.ProjectService.CurrentSelectedProject as MonoProject;
-			if (p != null) {
+			if (p != null)
 				Runtime.DispatchService.BackgroundDispatch (new StatefulMessageHandler (Install), p);
-			}
 		}
 		
+		protected override void Update (CommandInfo info)
+		{
+			info.Visible = Runtime.ProjectService.CurrentSelectedProject is MonoProject;
+		}
+		
 		void Install (object prj)
 		{
 			MonoProject p = prj as MonoProject;
@@ -51,4 +71,128 @@
 			}
 		}
 	}
+
+	public class MonoProjectBuilder: NodeBuilderExtension
+	{
+		public override bool CanBuildNode (Type dataType)
+		{
+			return typeof(MonoProject).IsAssignableFrom (dataType) ||
+					typeof(ProjectFolder).IsAssignableFrom (dataType) ||
+					typeof(ProjectFile).IsAssignableFrom (dataType);
+		}
+		
+		public override Type CommandHandlerType {
+			get { return typeof(MonoProjectCommandHandler); }
+		}
+	}
+	
+	public class MonoProjectCommandHandler: NodeCommandHandler
+	{
+		[CommandHandler (Commands.SvnDiff)]
+		public void SvnDiff ()
+		{
+			string path = GetPath ();
+			if (path == null) return;
+			Runtime.DispatchService.BackgroundDispatch (new StatefulMessageHandler (RunDiffAsync), path);
+		}
+		
+		public void RunDiffAsync (object pa)
+		{
+			string path = (string) pa;
+			using (IProgressMonitor monitor = Runtime.TaskService.GetOutputProgressMonitor ("Subversion Output", "", true, true)) {
+				monitor.Log.WriteLine ("Running: svn diff " + path + " ...");
+				StreamWriter w = new StreamWriter ("/tmp/tmp.diff");
+				ProcessWrapper p = Runtime.ProcessService.StartProcess ("svn", "diff " + path, null, w, monitor.Log, null);
+				p.WaitForOutput ();
+				w.Close ();
+				Runtime.FileService.OpenFile ("/tmp/tmp.diff");
+				monitor.Log.WriteLine ();
+				monitor.Log.WriteLine ("Done.");
+			}
+		}
+		
+		[CommandHandler (Commands.SvnUpdate)]
+		public void SvnUpdate ()
+		{
+			SvnRun ("up {0}");
+		}
+		
+		[CommandHandler (Commands.SvnStat)]
+		public void SvnStat ()
+		{
+			SvnRun ("stat {0}");
+		}
+		
+		[CommandHandler (Commands.SvnInfo)]
+		public void SvnInfo ()
+		{
+			SvnRun ("info {0}");
+		}
+		
+		[CommandHandler (Commands.SvnAdd)]
+		public void SvnAdd ()
+		{
+			SvnRun ("add {0}");
+		}
+		
+		[CommandHandler (Commands.SvnRevert)]
+		public void SvnRevert ()
+		{
+			if (Runtime.MessageService.AskQuestion ("Do you really want to revert " + GetPath() + "?"))
+				SvnRun ("revert {0}");
+		}
+		
+		[CommandHandler (Commands.SvnCommit)]
+		public void SvnCommit ()
+		{
+			Runtime.ProcessService.StartConsoleProcess ("svnci", GetPath(), null, true, true, null);
+		}
+		
+		public string GetPath ()
+		{
+			string path;
+			if (CurrentNode.DataItem is ProjectFolder)
+				path = ((ProjectFolder)CurrentNode.DataItem).Path;
+			else if (CurrentNode.DataItem is Project)
+				path = ((Project)CurrentNode.DataItem).BaseDirectory;
+			else if (CurrentNode.DataItem is ProjectFile)
+				path = ((ProjectFile)CurrentNode.DataItem).Name;
+			else
+				return null;
+			return path;
+		}
+		
+		public void SvnRun (string cmd)
+		{
+			string path = GetPath ();
+			if (path == null) return;
+			Runtime.DispatchService.BackgroundDispatch (new StatefulMessageHandler (RunAsync), new SvnCommand (cmd, path));
+		}
+		
+		public virtual void RunAsync (object pa)
+		{
+			SvnCommand c = (SvnCommand) pa;
+			string cmd = string.Format (c.Command, c.Path);
+			using (IProgressMonitor monitor = Runtime.TaskService.GetOutputProgressMonitor ("Subversion Output", "", true, true)) {
+				monitor.Log.WriteLine ("Running: svn " + cmd + " ...");
+				ProcessWrapper p = Runtime.ProcessService.StartProcess ("svn", cmd, null, monitor.Log, monitor.Log, null);
+				p.WaitForOutput ();
+				monitor.Log.WriteLine ();
+				monitor.Log.WriteLine ("Done.");
+			}
+		}
+		
+	}
+	
+	class SvnCommand
+	{
+		public SvnCommand (string cmd, string path)
+		{
+			Command = cmd;
+			Path = path;
+		}
+		
+		public string Path;
+		public string Command;
+	}
 }

Modified: trunk/MonoDevelop/Extras/MonoDeveloperExtensions/Makefile.am
===================================================================
--- trunk/MonoDevelop/Extras/MonoDeveloperExtensions/Makefile.am	2005-04-25 20:37:04 UTC (rev 2478)
+++ trunk/MonoDevelop/Extras/MonoDeveloperExtensions/Makefile.am	2005-04-25 20:37:23 UTC (rev 2479)
@@ -8,6 +8,7 @@
 MonoProjectConfiguration.cs
 
 REFS = /r:$(top_builddir)/build/bin/MonoDevelop.Core.dll \
+       /r:$(top_builddir)/build/bin/MonoDevelop.Gui.Widgets.dll \
        /r:$(top_builddir)/build/bin/MonoDevelop.Base.dll \
        $(GTK_SHARP_LIBS) \
        $(GLADE_SHARP_LIBS) \

Modified: trunk/MonoDevelop/Extras/MonoDeveloperExtensions/MonoDeveloperExtensions.addin.xml
===================================================================
--- trunk/MonoDevelop/Extras/MonoDeveloperExtensions/MonoDeveloperExtensions.addin.xml	2005-04-25 20:37:04 UTC (rev 2478)
+++ trunk/MonoDevelop/Extras/MonoDeveloperExtensions/MonoDeveloperExtensions.addin.xml	2005-04-25 20:37:23 UTC (rev 2479)
@@ -22,14 +22,105 @@
     </Conditional>
   </Extension>
   
+	<Extension path = "/SharpDevelop/Commands">
+		<Command id = "MonoDeveloper.Commands.Install"
+				defaultHandler = "MonoDeveloper.InstallHandler"
+				icon = "Icons.16x16.RedoIcon"
+				_label = "Install" />
+		<Command id = "MonoDeveloper.Commands.SvnUpdate"
+				  _label = "Update" />
+		<Command id = "MonoDeveloper.Commands.SvnAdd"
+				  _label = "Add" />
+		<Command id = "MonoDeveloper.Commands.SvnCommit"
+				  _label = "Commit" />
+		<Command id = "MonoDeveloper.Commands.SvnDiff"
+				  _label = "Diff" />
+		<Command id = "MonoDeveloper.Commands.SvnStat"
+				  _label = "Stat" />
+		<Command id = "MonoDeveloper.Commands.SvnInfo"
+				  _label = "Info" />
+		<Command id = "MonoDeveloper.Commands.SvnRevert"
+				  _label = "Revert" />
+	</Extension>
+			
+	<Extension path = "/SharpDevelop/Workbench/ToolBar/Standard">
+		<CommandItem id = "MonoDeveloper.Commands.Install" insertafter="MonoDevelop.Commands.ProjectCommands.Run"/>
+	</Extension>
+	
 	<Extension path = "/SharpDevelop/Views/ProjectBrowser/ContextMenu/ProjectBrowserNode">
 		<Conditional activeproject="MonoMakefile" action="Exclude">
-			<MenuItem id = "Install"
-					  insertafter = "RebuildProject"
-					  insertbefore = "BuildGroupSeparator"
-					  _label = "Install" 
-					  class = "MonoDeveloper.InstallCommand"/>
+			<CommandItem id = "MonoDeveloper.Commands.Install"
+					  insertafter = "BuildGroupSeparator"
+					  insertbefore = "Add" />
+			<ItemSet id = "Svn" _label="Subversion">
+				<CommandItem id = "MonoDeveloper.Commands.SvnUpdate"/>
+				<CommandItem id = "MonoDeveloper.Commands.SvnAdd"/>
+				<CommandItem id = "MonoDeveloper.Commands.SvnCommit"/>
+				<SeparatorItem id = "s1" />
+				<CommandItem id = "MonoDeveloper.Commands.SvnDiff"/>
+				<CommandItem id = "MonoDeveloper.Commands.SvnStat"/>
+				<CommandItem id = "MonoDeveloper.Commands.SvnInfo"/>
+				<SeparatorItem id = "s2" />
+				<CommandItem id = "MonoDeveloper.Commands.SvnRevert"/>
+			</ItemSet>
+			<SeparatorItem id = "svnSep" />
 		</Conditional>
 	</Extension>
+	
+	<Extension path = "/SharpDevelop/Views/ProjectBrowser/ContextMenu/DefaultFileNode">
+		<Conditional activeproject="MonoMakefile" action="Exclude">
+			<ItemSet id = "Svn" _label="Subversion">
+				<CommandItem id = "MonoDeveloper.Commands.SvnUpdate"/>
+				<CommandItem id = "MonoDeveloper.Commands.SvnAdd"/>
+				<CommandItem id = "MonoDeveloper.Commands.SvnCommit"/>
+				<SeparatorItem id = "s1" />
+				<CommandItem id = "MonoDeveloper.Commands.SvnDiff"/>
+				<CommandItem id = "MonoDeveloper.Commands.SvnStat"/>
+				<CommandItem id = "MonoDeveloper.Commands.SvnInfo"/>
+				<SeparatorItem id = "s2" />
+				<CommandItem id = "MonoDeveloper.Commands.SvnRevert"/>
+			</ItemSet>
+			<SeparatorItem id = "svnSep" />
+		</Conditional>
+	</Extension>
+	
+	<Extension path = "/SharpDevelop/Views/ProjectBrowser/ContextMenu/ProjectFileNode">
+		<Conditional activeproject="MonoMakefile" action="Exclude">
+			<ItemSet id = "Svn" _label="Subversion" insertafter = "OpenSeparator" insertbefore = "Add">
+				<CommandItem id = "MonoDeveloper.Commands.SvnUpdate"/>
+				<CommandItem id = "MonoDeveloper.Commands.SvnAdd"/>
+				<CommandItem id = "MonoDeveloper.Commands.SvnCommit"/>
+				<SeparatorItem id = "s1" />
+				<CommandItem id = "MonoDeveloper.Commands.SvnDiff"/>
+				<CommandItem id = "MonoDeveloper.Commands.SvnStat"/>
+				<CommandItem id = "MonoDeveloper.Commands.SvnInfo"/>
+				<SeparatorItem id = "s2" />
+				<CommandItem id = "MonoDeveloper.Commands.SvnRevert"/>
+			</ItemSet>
+			<SeparatorItem id = "svnSep" />
+		</Conditional>
+	</Extension>
+	
+	<Extension path = "/SharpDevelop/Views/ProjectBrowser/ContextMenu/DefaultDirectoryNode">
+		<Conditional activeproject="MonoMakefile" action="Exclude">
+			<ItemSet id = "Svn" _label="Subversion" insertbefore = "Add">
+				<CommandItem id = "MonoDeveloper.Commands.SvnUpdate"/>
+				<CommandItem id = "MonoDeveloper.Commands.SvnAdd"/>
+				<CommandItem id = "MonoDeveloper.Commands.SvnCommit"/>
+				<SeparatorItem id = "s1" />
+				<CommandItem id = "MonoDeveloper.Commands.SvnDiff"/>
+				<CommandItem id = "MonoDeveloper.Commands.SvnStat"/>
+				<CommandItem id = "MonoDeveloper.Commands.SvnInfo"/>
+				<SeparatorItem id = "s2" />
+				<CommandItem id = "MonoDeveloper.Commands.SvnRevert"/>
+			</ItemSet>
+			<SeparatorItem id = "svnSep" />
+		</Conditional>
+	</Extension>
+	
+	<Extension path = "/SharpDevelop/Workbench/Pads/MonoDevelop.Gui.Pads.ProjectPad">
+		<NodeBuilder id = "MonoProjectBuilder" class = "MonoDeveloper.MonoProjectBuilder"/>
+	</Extension>
+	
 </AddIn>
 




More information about the Monodevelop-patches-list mailing list