[Monodevelop-patches-list] r1853 - in branches/MonoDevelop-0.5/src: AddIns/DisplayBindings/SourceEditor AddIns/DisplayBindings/SourceEditor/Gui Main/Base Main/Base/Gui Main/Base/Gui/Workbench/Layouts

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Mon Jun 28 14:59:40 EDT 2004


Author: tberman
Date: 2004-06-28 14:59:40 -0400 (Mon, 28 Jun 2004)
New Revision: 1853

Modified:
   branches/MonoDevelop-0.5/src/AddIns/DisplayBindings/SourceEditor/ChangeLog
   branches/MonoDevelop-0.5/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorDisplayBinding.cs
   branches/MonoDevelop-0.5/src/Main/Base/ChangeLog
   branches/MonoDevelop-0.5/src/Main/Base/Gui/AbstractViewContent.cs
   branches/MonoDevelop-0.5/src/Main/Base/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs
Log:
using a FSW to track potential external changes to a file from outside of the editor.


Modified: branches/MonoDevelop-0.5/src/AddIns/DisplayBindings/SourceEditor/ChangeLog
===================================================================
--- branches/MonoDevelop-0.5/src/AddIns/DisplayBindings/SourceEditor/ChangeLog	2004-06-28 06:25:39 UTC (rev 1852)
+++ branches/MonoDevelop-0.5/src/AddIns/DisplayBindings/SourceEditor/ChangeLog	2004-06-28 18:59:40 UTC (rev 1853)
@@ -1,3 +1,8 @@
+2004-06-28  Todd Berman  <tberman at off.net>
+
+	* Gui/SourceEditorDisplayBinding.cs: Add a FSW to monitor for external
+	changes to a loaded file.
+
 2004-06-26  Lluis Sanchez Gual  <lluis at ximian.com>
 
 	* Search/SearchReplaceManager.cs: Make sure the search starts at the current

Modified: branches/MonoDevelop-0.5/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorDisplayBinding.cs
===================================================================
--- branches/MonoDevelop-0.5/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorDisplayBinding.cs	2004-06-28 06:25:39 UTC (rev 1852)
+++ branches/MonoDevelop-0.5/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorDisplayBinding.cs	2004-06-28 18:59:40 UTC (rev 1853)
@@ -91,8 +91,45 @@
 	public class SourceEditorDisplayBindingWrapper : AbstractViewContent,
 		IEditable, IPositionable, IBookmarkOperations, IDebuggableEditor
 	{
+
+		internal FileSystemWatcher fsw;
+	
 		internal SourceEditor se;
-	
+
+		void UpdateFSW (object o, EventArgs e)
+		{
+			if (ContentName == null || ContentName.Length == 0)
+				return;
+
+			fsw.EnableRaisingEvents = false;
+			fsw.Path = Path.GetDirectoryName (ContentName);
+			fsw.Filter = Path.GetFileName (ContentName);
+			fsw.EnableRaisingEvents = true;
+		}
+
+		private void OnFileChanged (object o, FileSystemEventArgs e)
+		{
+			DispatchService dispatcher = (DispatchService)ServiceManager.GetService (typeof (DispatchService));
+			dispatcher.GuiDispatch (new StatefulMessageHandler (realFileChanged), e);
+		}
+
+		void realFileChanged (object evnt)
+		{
+			FileSystemEventArgs e = (FileSystemEventArgs)evnt;
+			if (e.ChangeType == WatcherChangeTypes.Changed) {
+				MessageDialog msg = new MessageDialog ((Gtk.Window)WorkbenchSingleton.Workbench, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo, String.Format (GettextCatalog.GetString ("The file {0} has been changed outside of MonoDevelop. Would you like to reload the file?"), ContentName));
+				msg.Response += new Gtk.ResponseHandler (Responded);
+				msg.ShowAll ();
+			}
+		}
+
+		void Responded (object o, ResponseArgs e)
+		{
+			if (e.ResponseId == ResponseType.Yes)
+				Load (ContentName);
+			((Gtk.Window)o).Hide ();
+		}
+
 		public void ExecutingAt (int line)
 		{
 			se.ExecutingAt (line);
@@ -122,6 +159,7 @@
 			se.Buffer.MarkSet += new MarkSetHandler (OnMarkSet);
 			se.Buffer.Changed += new EventHandler (OnChanged);
 			se.View.ToggleOverwrite += new EventHandler (CaretModeChanged);
+			ContentNameChanged += new EventHandler (UpdateFSW);
 			
 			CaretModeChanged (null, null);
 			PropertiesChanged (null, null);
@@ -129,8 +167,11 @@
 			PropertyService propertyService = (PropertyService) ServiceManager.GetService (typeof (PropertyService));
 			IProperties properties2 = ((IProperties) propertyService.GetProperty("MonoDevelop.TextEditor.Document.Document.DefaultDocumentAggregatorProperties", new DefaultProperties()));
 			properties2.PropertyChanged += new PropertyEventHandler (PropertiesChanged);
+			fsw = new FileSystemWatcher ();
+			fsw.Changed += new FileSystemEventHandler (OnFileChanged);
+			UpdateFSW (null, null);
 		}
-		
+
 		public void JumpTo (int line, int column)
 		{
 			// NOTE: 0 based!			
@@ -169,6 +210,7 @@
 		
 		public override void Dispose()
 		{
+			fsw.Dispose ();
 		}
 		
 		void OnModifiedChanged (object o, EventArgs e)

Modified: branches/MonoDevelop-0.5/src/Main/Base/ChangeLog
===================================================================
--- branches/MonoDevelop-0.5/src/Main/Base/ChangeLog	2004-06-28 06:25:39 UTC (rev 1852)
+++ branches/MonoDevelop-0.5/src/Main/Base/ChangeLog	2004-06-28 18:59:40 UTC (rev 1853)
@@ -1,5 +1,12 @@
 2004-06-28  Todd Berman  <tberman at off.net>
 
+	* Gui/Workbench/Layouts/SdiWorkspaceWindow.cs: make sure everything is
+	being disposed on close.
+	* Gui/AbstractViewContent.cs: work around small virtual bug, will file
+	this when i can replicate in a smaller test case.
+
+2004-06-28  Todd Berman  <tberman at off.net>
+
 	* Services/Project/DefaultProjectService.cs:
 	* Services/Project/IProjectService.cs:
 	* Internal/Project/Project/IProject.cs:

Modified: branches/MonoDevelop-0.5/src/Main/Base/Gui/AbstractViewContent.cs
===================================================================
--- branches/MonoDevelop-0.5/src/Main/Base/Gui/AbstractViewContent.cs	2004-06-28 06:25:39 UTC (rev 1852)
+++ branches/MonoDevelop-0.5/src/Main/Base/Gui/AbstractViewContent.cs	2004-06-28 18:59:40 UTC (rev 1853)
@@ -18,7 +18,6 @@
 		string untitledName = "";
 		string contentName  = null;
 		IProject project = null;
-		string pathrelativetoproject = null;
 		
 		bool   isDirty  = false;
 		bool   isViewOnly = false;
@@ -103,6 +102,10 @@
 		
 		public abstract void Load(string fileName);
 
+		public override void Dispose ()
+		{
+		}
+
 		public IProject Project
 		{
 			get

Modified: branches/MonoDevelop-0.5/src/Main/Base/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs
===================================================================
--- branches/MonoDevelop-0.5/src/Main/Base/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs	2004-06-28 06:25:39 UTC (rev 1852)
+++ branches/MonoDevelop-0.5/src/Main/Base/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs	2004-06-28 18:59:40 UTC (rev 1853)
@@ -253,6 +253,7 @@
 				WorkbenchSingleton.Workbench.WorkbenchLayout.RemoveTab (pageNum);
 			}
 			OnWindowDeselected(EventArgs.Empty);
+			content.Dispose ();
 			OnCloseEvent(null);
 		}
 		




More information about the Monodevelop-patches-list mailing list