[Monodevelop-patches-list] r1851 - in branches/MonoDevelop-0.5/src/Main/Base: . Internal/Project/Combine Internal/Project/Project Services/Project
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Mon Jun 28 02:23:18 EDT 2004
Author: tberman
Date: 2004-06-28 02:23:18 -0400 (Mon, 28 Jun 2004)
New Revision: 1851
Modified:
branches/MonoDevelop-0.5/src/Main/Base/ChangeLog
branches/MonoDevelop-0.5/src/Main/Base/Internal/Project/Combine/Combine.cs
branches/MonoDevelop-0.5/src/Main/Base/Internal/Project/Project/AbstractProject.cs
branches/MonoDevelop-0.5/src/Main/Base/Internal/Project/Project/IProject.cs
branches/MonoDevelop-0.5/src/Main/Base/Internal/Project/Project/ProjectFile.cs
branches/MonoDevelop-0.5/src/Main/Base/Services/Project/DefaultProjectService.cs
branches/MonoDevelop-0.5/src/Main/Base/Services/Project/IProjectService.cs
Log:
patch from ray to add FSW watching on files in a project to properly emit a file changed event.
Modified: branches/MonoDevelop-0.5/src/Main/Base/ChangeLog
===================================================================
--- branches/MonoDevelop-0.5/src/Main/Base/ChangeLog 2004-06-28 04:12:16 UTC (rev 1850)
+++ branches/MonoDevelop-0.5/src/Main/Base/ChangeLog 2004-06-28 06:23:18 UTC (rev 1851)
@@ -1,3 +1,15 @@
+2004-06-28 Todd Berman <tberman at off.net>
+
+ * Services/Project/DefaultProjectService.cs:
+ * Services/Project/IProjectService.cs:
+ * Internal/Project/Project/IProject.cs:
+ * Internal/Project/Project/AbstractProject.cs:
+ * Internal/Project/Project/ProjectFile.cs:
+ * Internal/Project/Combine/Combine.cs:
+ Patch from Ray Molenkamp <ray at yarvje.dyndns.org> to add a FSW that
+ monitors for external changes to any file in a project and emits an
+ event on the project service for it.
+
2004-06-26 Todd Berman <tberman at off.net>
* Gui/Dialogs/DirtyFilesDialog.cs: small layout fixes.
Modified: branches/MonoDevelop-0.5/src/Main/Base/Internal/Project/Combine/Combine.cs
===================================================================
--- branches/MonoDevelop-0.5/src/Main/Base/Internal/Project/Combine/Combine.cs 2004-06-28 04:12:16 UTC (rev 1850)
+++ branches/MonoDevelop-0.5/src/Main/Base/Internal/Project/Combine/Combine.cs 2004-06-28 06:23:18 UTC (rev 1851)
@@ -45,6 +45,8 @@
ProjectFileEventHandler fileAddedToProjectHandler;
ProjectFileEventHandler fileRemovedFromProjectHandler;
+ ProjectFileEventHandler fileChangedInProjectHandler;
+
ProjectReferenceEventHandler referenceAddedToProjectHandler;
ProjectReferenceEventHandler referenceRemovedFromProjectHandler;
@@ -180,6 +182,7 @@
public Combine()
{
fileAddedToProjectHandler = new ProjectFileEventHandler (NotifyFileAddedToProject);
+ fileChangedInProjectHandler = new ProjectFileEventHandler (NotifyFileChangedInProject);
fileRemovedFromProjectHandler = new ProjectFileEventHandler (NotifyFileRemovedFromProject);
referenceAddedToProjectHandler = new ProjectReferenceEventHandler (NotifyReferenceAddedToProject);
referenceRemovedFromProjectHandler = new ProjectReferenceEventHandler (NotifyReferenceRemovedFromProject);
@@ -411,9 +414,10 @@
newEntry.Project.FileRemovedFromProject += fileAddedToProjectHandler;
newEntry.Project.FileAddedToProject += fileRemovedFromProjectHandler;
+ newEntry.Project.FileChangedInProject += fileChangedInProjectHandler;
newEntry.Project.ReferenceRemovedFromProject += referenceAddedToProjectHandler;
newEntry.Project.ReferenceAddedToProject += referenceRemovedFromProjectHandler;
-
+
return project;
} else {
Combine combine = new Combine(filename);
@@ -441,6 +445,7 @@
newEntry.Combine.FileRemovedFromProject += fileAddedToProjectHandler;
newEntry.Combine.FileAddedToProject += fileRemovedFromProjectHandler;
+ newEntry.Combine.FileChangedInProject += fileChangedInProjectHandler;
newEntry.Combine.ReferenceRemovedFromProject += referenceAddedToProjectHandler;
newEntry.Combine.ReferenceAddedToProject += referenceRemovedFromProjectHandler;
@@ -454,6 +459,7 @@
if (pce != null) {
pce.Project.FileRemovedFromProject -= fileAddedToProjectHandler;
pce.Project.FileAddedToProject -= fileRemovedFromProjectHandler;
+ pce.Project.FileChangedInProject -= fileChangedInProjectHandler;
pce.Project.ReferenceRemovedFromProject -= referenceAddedToProjectHandler;
pce.Project.ReferenceAddedToProject -= referenceRemovedFromProjectHandler;
}
@@ -462,6 +468,7 @@
if (cce != null) {
cce.Combine.FileRemovedFromProject -= fileAddedToProjectHandler;
cce.Combine.FileAddedToProject -= fileRemovedFromProjectHandler;
+ cce.Combine.FileChangedInProject -= fileChangedInProjectHandler;
cce.Combine.ReferenceRemovedFromProject -= referenceAddedToProjectHandler;
cce.Combine.ReferenceAddedToProject -= referenceRemovedFromProjectHandler;
}
@@ -718,6 +725,11 @@
{
OnFileAddedToProject (e);
}
+
+ internal void NotifyFileChangedInProject (object sender, ProjectFileEventArgs e)
+ {
+ OnFileChangedInProject (e);
+ }
internal void NotifyReferenceRemovedFromProject (object sender, ProjectReferenceEventArgs e)
{
@@ -764,6 +776,13 @@
FileRemovedFromProject (this, e);
}
}
+
+ protected virtual void OnFileChangedInProject (ProjectFileEventArgs e)
+ {
+ if (FileChangedInProject != null) {
+ FileChangedInProject (this, e);
+ }
+ }
protected virtual void OnFileAddedToProject (ProjectFileEventArgs e)
{
@@ -792,6 +811,7 @@
public event CombineEntryEventHandler EntryRemoved;
public event ProjectFileEventHandler FileAddedToProject;
public event ProjectFileEventHandler FileRemovedFromProject;
+ public event ProjectFileEventHandler FileChangedInProject;
public event ProjectReferenceEventHandler ReferenceAddedToProject;
public event ProjectReferenceEventHandler ReferenceRemovedFromProject;
}
Modified: branches/MonoDevelop-0.5/src/Main/Base/Internal/Project/Project/AbstractProject.cs
===================================================================
--- branches/MonoDevelop-0.5/src/Main/Base/Internal/Project/Project/AbstractProject.cs 2004-06-28 04:12:16 UTC (rev 1850)
+++ branches/MonoDevelop-0.5/src/Main/Base/Internal/Project/Project/AbstractProject.cs 2004-06-28 06:23:18 UTC (rev 1851)
@@ -562,6 +562,9 @@
public virtual void Dispose()
{
+ foreach (ProjectFile file in ProjectFiles) {
+ file.Dispose ();
+ }
}
public abstract IConfiguration CreateConfiguration();
@@ -574,6 +577,11 @@
return config;
}
+ internal void NotifyFileChangedInProject (ProjectFile file)
+ {
+ OnFileChangedInProject (new ProjectFileEventArgs (this, file));
+ }
+
internal void NotifyFileRemovedFromProject (ProjectFile file)
{
OnFileRemovedFromProject (new ProjectFileEventArgs (this, file));
@@ -628,10 +636,19 @@
ReferenceAddedToProject (this, e);
}
}
+
+ protected virtual void OnFileChangedInProject (ProjectFileEventArgs e)
+ {
+ if (FileChangedInProject != null) {
+ FileChangedInProject (this, e);
+ }
+ }
+
public event EventHandler NameChanged;
public event ProjectFileEventHandler FileRemovedFromProject;
public event ProjectFileEventHandler FileAddedToProject;
+ public event ProjectFileEventHandler FileChangedInProject;
public event ProjectReferenceEventHandler ReferenceRemovedFromProject;
public event ProjectReferenceEventHandler ReferenceAddedToProject;
}
Modified: branches/MonoDevelop-0.5/src/Main/Base/Internal/Project/Project/IProject.cs
===================================================================
--- branches/MonoDevelop-0.5/src/Main/Base/Internal/Project/Project/IProject.cs 2004-06-28 04:12:16 UTC (rev 1850)
+++ branches/MonoDevelop-0.5/src/Main/Base/Internal/Project/Project/IProject.cs 2004-06-28 06:23:18 UTC (rev 1851)
@@ -158,6 +158,7 @@
event EventHandler NameChanged;
event ProjectFileEventHandler FileRemovedFromProject;
event ProjectFileEventHandler FileAddedToProject;
+ event ProjectFileEventHandler FileChangedInProject;
event ProjectReferenceEventHandler ReferenceRemovedFromProject;
event ProjectReferenceEventHandler ReferenceAddedToProject;
}
Modified: branches/MonoDevelop-0.5/src/Main/Base/Internal/Project/Project/ProjectFile.cs
===================================================================
--- branches/MonoDevelop-0.5/src/Main/Base/Internal/Project/Project/ProjectFile.cs 2004-06-28 04:12:16 UTC (rev 1850)
+++ branches/MonoDevelop-0.5/src/Main/Base/Internal/Project/Project/ProjectFile.cs 2004-06-28 06:23:18 UTC (rev 1851)
@@ -1,3 +1,4 @@
+
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
@@ -6,6 +7,7 @@
// </file>
using System;
+using System.IO;
using System.ComponentModel;
using System.Diagnostics;
using System.Xml;
@@ -58,9 +60,41 @@
[XmlAttribute(null)]
AbstractProject project;
+ private FileSystemWatcher ProjectFileWatcher;
+
+ private void AddFileWatch()
+ {
+ ProjectFileWatcher = new FileSystemWatcher();
+
+ ProjectFileWatcher.Changed += new FileSystemEventHandler(OnChanged);
+
+ if (this.filename != null)
+ UpdateFileWatch();
+
+ }
+
+ private void UpdateFileWatch()
+ {
+
+ if ((this.filename == null) || (this.filename.Length == 0))
+ return;
+
+ ProjectFileWatcher.EnableRaisingEvents = false;
+ ProjectFileWatcher.Path = Path.GetDirectoryName(filename);
+ ProjectFileWatcher.Filter = Path.GetFileName(filename);
+ ProjectFileWatcher.EnableRaisingEvents = true;
+
+ }
+
+ private void OnChanged(object source, FileSystemEventArgs e)
+ {
+ project.NotifyFileChangedInProject(this);
+ }
+
internal void SetProject (AbstractProject prj)
{
project = prj;
+ UpdateFileWatch();
}
[LocalizedProperty("${res:MonoDevelop.Internal.Project.ProjectFile.Name}",
@@ -73,6 +107,7 @@
set {
project.NotifyFileRemovedFromProject (this);
filename = value;
+ UpdateFileWatch();
Debug.Assert(filename != null && filename.Length > 0, "name == null || name.Length == 0");
project.NotifyFileAddedToProject (this);
}
@@ -121,6 +156,7 @@
public ProjectFile()
{
+ AddFileWatch();
}
public ProjectFile(string filename)
@@ -128,6 +164,7 @@
this.filename = filename;
subtype = Subtype.Code;
buildaction = BuildAction.Compile;
+ AddFileWatch();
}
public ProjectFile(string filename, BuildAction buildAction)
@@ -135,6 +172,7 @@
this.filename = filename;
subtype = Subtype.Code;
buildaction = buildAction;
+ AddFileWatch();
}
public object Clone()
@@ -147,6 +185,9 @@
return "[ProjectFile: FileName=" + filename + ", Subtype=" + subtype + ", BuildAction=" + BuildAction + "]";
}
-
+ public virtual void Dispose ()
+ {
+ ProjectFileWatcher.Dispose ();
+ }
}
}
Modified: branches/MonoDevelop-0.5/src/Main/Base/Services/Project/DefaultProjectService.cs
===================================================================
--- branches/MonoDevelop-0.5/src/Main/Base/Services/Project/DefaultProjectService.cs 2004-06-28 04:12:16 UTC (rev 1850)
+++ branches/MonoDevelop-0.5/src/Main/Base/Services/Project/DefaultProjectService.cs 2004-06-28 06:23:18 UTC (rev 1851)
@@ -179,9 +179,10 @@
OnCombineOpened(new CombineEventArgs(openCombine));
openCombine.FileAddedToProject += new ProjectFileEventHandler (NotifyFileAddedToProject);
openCombine.FileRemovedFromProject += new ProjectFileEventHandler (NotifyFileRemovedFromProject);
+ openCombine.FileChangedInProject += new ProjectFileEventHandler (NotifyFileChangedInProject);
openCombine.ReferenceAddedToProject += new ProjectReferenceEventHandler (NotifyReferenceAddedToProject);
openCombine.ReferenceRemovedFromProject += new ProjectReferenceEventHandler (NotifyReferenceRemovedFromProject);
-
+
RestoreCombinePreferences(CurrentOpenCombine, openCombineFileName);
}
@@ -715,6 +716,11 @@
{
OnFileAddedToProject (e);
}
+
+ internal void NotifyFileChangedInProject (object sender, ProjectFileEventArgs e)
+ {
+ OnFileChangedInProject (e);
+ }
internal void NotifyReferenceAddedToProject (object sender, ProjectReferenceEventArgs e)
{
@@ -741,6 +747,13 @@
FileAddedToProject (this, e);
}
}
+
+ protected virtual void OnFileChangedInProject (ProjectFileEventArgs e)
+ {
+ if (FileChangedInProject != null) {
+ FileChangedInProject (this, e);
+ }
+ }
protected virtual void OnReferenceRemovedFromProject (ProjectReferenceEventArgs e)
{
@@ -805,6 +818,8 @@
public event ProjectFileEventHandler FileRemovedFromProject;
public event ProjectFileEventHandler FileAddedToProject;
+ public event ProjectFileEventHandler FileChangedInProject;
+
public event EventHandler StartBuild;
public event EventHandler EndBuild;
public event EventHandler BeforeStartProject;
Modified: branches/MonoDevelop-0.5/src/Main/Base/Services/Project/IProjectService.cs
===================================================================
--- branches/MonoDevelop-0.5/src/Main/Base/Services/Project/IProjectService.cs 2004-06-28 04:12:16 UTC (rev 1850)
+++ branches/MonoDevelop-0.5/src/Main/Base/Services/Project/IProjectService.cs 2004-06-28 06:23:18 UTC (rev 1851)
@@ -189,6 +189,11 @@
/// </remarks>
event ProjectFileEventHandler FileRemovedFromProject;
event ProjectFileEventHandler FileAddedToProject;
+
+ /// <remarks>
+ /// Is called, when a file in the project is changed on disk.
+ /// </remarks>
+ event ProjectFileEventHandler FileChangedInProject;
/// <remarks>
/// Is called, when a reference is removed from and added to a project.
More information about the Monodevelop-patches-list
mailing list