[Monodevelop-patches-list] r1223 - in trunk/MonoDevelop: . src/Main/Base/Gui src/Main/Base/Gui/Pads/ProjectBrowser/BrowserNode src/Main/Base/Services/File src/Main/Base/Services/Project
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Sun Mar 21 18:38:01 EST 2004
Author: illan
Date: 2004-03-21 18:38:01 -0500 (Sun, 21 Mar 2004)
New Revision: 1223
Modified:
trunk/MonoDevelop/ChangeLog
trunk/MonoDevelop/src/Main/Base/Gui/AbstractViewContent.cs
trunk/MonoDevelop/src/Main/Base/Gui/IViewContent.cs
trunk/MonoDevelop/src/Main/Base/Gui/Pads/ProjectBrowser/BrowserNode/FileNode.cs
trunk/MonoDevelop/src/Main/Base/Services/File/DefaultFileService.cs
trunk/MonoDevelop/src/Main/Base/Services/File/IFileService.cs
trunk/MonoDevelop/src/Main/Base/Services/Project/DefaultProjectService.cs
Log:
Modified: trunk/MonoDevelop/ChangeLog
===================================================================
--- trunk/MonoDevelop/ChangeLog 2004-03-21 23:10:50 UTC (rev 1222)
+++ trunk/MonoDevelop/ChangeLog 2004-03-21 23:38:01 UTC (rev 1223)
@@ -1,3 +1,27 @@
+2004-03-22 Iñigo Illán <kodeport AT terra.es>
+
+ * Base/Gui/Pads/ProjectBrowser/BrowserNode/FileNode.cs:
+ Make ActivateItem call OpenFileFromProject instead OpenFile
+
+ * Base/Services/File/IFileService.cs:
+ Add OpenFileProject specification
+
+ * Base/Services/File/DefaultFileService.cs:
+ LoadFileWrapper can manage files from projects.
+ Implement OpenFile to manage project files and rename it to
+ OpenFileProject OpenFile now calls OpenFileProject
+
+ * Base/Gui/IViewContent.cs:
+ Add HasProject, ProjectName and PathRelativeToProject
+ properties
+
+ * Base/Gui/AbstractViewContent.cs:
+ Implement HasProject, ProjectName, PathRelativeToProject properties
+
+ * Base/Services/Project/DefaultProjectService.cs:
+ Call OpenFileFromProject instead OpenFile when restoring
+ the combine state
+
2004-03-21 John Luke <jluke at cfl.rr.com>
* docs/WritingAddins.html: initial addin quick guide
Modified: trunk/MonoDevelop/src/Main/Base/Gui/AbstractViewContent.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/AbstractViewContent.cs 2004-03-21 23:10:50 UTC (rev 1222)
+++ trunk/MonoDevelop/src/Main/Base/Gui/AbstractViewContent.cs 2004-03-21 23:38:01 UTC (rev 1223)
@@ -13,9 +13,12 @@
{
string untitledName = "";
string contentName = null;
+ string projectname = null;
+ string pathrelativetoproject = null;
bool isDirty = false;
bool isViewOnly = false;
+ bool hasproject = false;
public override string TabPageLabel {
get { return "Change me"; }
@@ -71,6 +74,18 @@
}
}
+ public bool HasProject
+ {
+ get
+ {
+ return hasproject;
+ }
+ set
+ {
+ hasproject = value;
+ }
+ }
+
public virtual void Save()
{
OnBeforeSave(EventArgs.Empty);
@@ -83,7 +98,46 @@
}
public abstract void Load(string fileName);
-
+
+ public string ProjectName
+ {
+ get
+ {
+ return projectname;
+ }
+ set
+ {
+ if (!HasProject && value != null && value != "")
+ {
+ HasProject = true;
+ }
+ projectname = value;
+ }
+ }
+
+ public string PathRelativeToProject
+ {
+ get
+ {
+ return pathrelativetoproject;
+ }
+ set
+ {
+ if (value != null && value != "")
+ {
+ if (!HasProject)
+ {
+ HasProject = true;
+ }
+ if (ProjectName == null)
+ {
+ ProjectName = "";
+ }
+ }
+ pathrelativetoproject = value;
+ }
+ }
+
protected virtual void OnDirtyChanged(EventArgs e)
{
if (DirtyChanged != null) {
Modified: trunk/MonoDevelop/src/Main/Base/Gui/IViewContent.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/IViewContent.cs 2004-03-21 23:10:50 UTC (rev 1222)
+++ trunk/MonoDevelop/src/Main/Base/Gui/IViewContent.cs 2004-03-21 23:38:01 UTC (rev 1223)
@@ -65,6 +65,14 @@
}
/// <summary>
+ /// If this property return true the content has been opened from a project
+ /// </summary>
+ bool HasProject {
+ get;
+ set;
+ }
+
+ /// <summary>
/// Saves this content to the last load/save location.
/// </summary>
void Save();
@@ -82,7 +90,24 @@
string TabPageLabel {
get;
}
+
/// <summary>
+ /// The name of the project the content is attached to
+ /// </summary>
+ string ProjectName {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// The path relative to the project
+ /// </summary>
+ string PathRelativeToProject {
+ get;
+ set;
+ }
+
+ /// <summary>
/// Is called each time the name for the content has changed.
/// </summary>
event EventHandler ContentNameChanged;
Modified: trunk/MonoDevelop/src/Main/Base/Gui/Pads/ProjectBrowser/BrowserNode/FileNode.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/Pads/ProjectBrowser/BrowserNode/FileNode.cs 2004-03-21 23:10:50 UTC (rev 1222)
+++ trunk/MonoDevelop/src/Main/Base/Gui/Pads/ProjectBrowser/BrowserNode/FileNode.cs 2004-03-21 23:38:01 UTC (rev 1223)
@@ -89,9 +89,26 @@
public override void ActivateItem()
{
+ string relativepath;
+ int index;
+
if (userData != null && userData is ProjectFile) {
IFileService fileService = (IFileService)MonoDevelop.Core.Services.ServiceManager.Services.GetService(typeof(IFileService));
- fileService.OpenFile(((ProjectFile)userData).Name);
+
+ if ((index = ((ProjectFile) userData).Name.IndexOf (this.Project.BaseDirectory)) == 0)
+ {
+ relativepath = ((ProjectFile) userData).Name.Substring(this.Project.BaseDirectory.Length);
+ if (relativepath.StartsWith(Path.DirectorySeparatorChar.ToString()))
+ {
+ relativepath = relativepath.Substring(1);
+ }
+ }
+ else
+ {
+ relativepath = System.IO.Path.GetFileName(((ProjectFile)userData).Name);
+ }
+
+ fileService.OpenFileFromProject(((ProjectFile)userData).Name, this.Combine.Name, relativepath); // System.IO.Path.GetFileName(((ProjectFile)userData).Name));
}
}
Modified: trunk/MonoDevelop/src/Main/Base/Services/File/DefaultFileService.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Services/File/DefaultFileService.cs 2004-03-21 23:10:50 UTC (rev 1222)
+++ trunk/MonoDevelop/src/Main/Base/Services/File/DefaultFileService.cs 2004-03-21 23:38:01 UTC (rev 1223)
@@ -48,22 +48,36 @@
class LoadFileWrapper
{
IDisplayBinding binding;
+ string projectname, pathrelativetoproject;
public LoadFileWrapper(IDisplayBinding binding)
{
this.binding = binding;
}
+ public LoadFileWrapper(IDisplayBinding binding, string projectname, string pathrelativetoproject)
+ {
+ this.binding = binding;
+ this.projectname = projectname;
+ this.pathrelativetoproject = pathrelativetoproject;
+ }
+
public void Invoke(string fileName)
{
IViewContent newContent = binding.CreateContentForFile(fileName);
+ if (projectname != null && projectname != "" && pathrelativetoproject != null && pathrelativetoproject != "")
+ {
+ newContent.HasProject = true;
+ newContent.ProjectName = projectname;
+ newContent.PathRelativeToProject = pathrelativetoproject;
+ }
WorkbenchSingleton.Workbench.ShowView(newContent);
DisplayBindingService displayBindingService = (DisplayBindingService)MonoDevelop.Core.Services.ServiceManager.Services.GetService(typeof(DisplayBindingService));
displayBindingService.AttachSubWindows(newContent.WorkbenchWindow);
}
}
- public void OpenFile(string fileName)
+ public void OpenFileFromProject (string fileName, string projectname, string pathrelativetoproject)
{
if (fileName == null)
return;
@@ -102,20 +116,25 @@
IDisplayBinding binding = displayBindingService.GetBindingPerFileName(fileName);
if (binding != null) {
- if (fileUtilityService.ObservedLoad(new NamedFileOperationDelegate(new LoadFileWrapper(binding).Invoke), fileName) == FileOperationResult.OK) {
+ if (fileUtilityService.ObservedLoad(new NamedFileOperationDelegate(new LoadFileWrapper(binding, projectname, pathrelativetoproject).Invoke), fileName) == FileOperationResult.OK) {
fileService.RecentOpen.AddLastFile(fileName);
}
} else {
try {
Gnome.Url.Show ("file://" + fileName);
} catch {
- if (fileUtilityService.ObservedLoad(new NamedFileOperationDelegate (new LoadFileWrapper (displayBindingService.LastBinding).Invoke), fileName) == FileOperationResult.OK) {
+ if (fileUtilityService.ObservedLoad(new NamedFileOperationDelegate (new LoadFileWrapper (displayBindingService.LastBinding, null, null).Invoke), fileName) == FileOperationResult.OK) {
fileService.RecentOpen.AddLastFile (fileName);
}
}
}
}
+ public void OpenFile (string filename)
+ {
+ this.OpenFileFromProject (filename, null, null);
+ }
+
public void NewFile(string defaultName, string language, string content)
{
DisplayBindingService displayBindingService = (DisplayBindingService)MonoDevelop.Core.Services.ServiceManager.Services.GetService(typeof(DisplayBindingService));
Modified: trunk/MonoDevelop/src/Main/Base/Services/File/IFileService.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Services/File/IFileService.cs 2004-03-21 23:10:50 UTC (rev 1222)
+++ trunk/MonoDevelop/src/Main/Base/Services/File/IFileService.cs 2004-03-21 23:38:01 UTC (rev 1223)
@@ -36,6 +36,10 @@
void OpenFile(string fileName);
/// <remarks>
+ /// Opens the file filename in MonoDevelop atached to projectname
+ void OpenFileFromProject (string filename, string projectname, string pathrelativetoproject);
+
+ /// <remarks>
/// Opens a new file with a given name, language and file content
/// in the workbench window.
/// </remarks>
Modified: trunk/MonoDevelop/src/Main/Base/Services/Project/DefaultProjectService.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Services/Project/DefaultProjectService.cs 2004-03-21 23:10:50 UTC (rev 1222)
+++ trunk/MonoDevelop/src/Main/Base/Services/Project/DefaultProjectService.cs 2004-03-21 23:38:01 UTC (rev 1223)
@@ -495,7 +495,24 @@
foreach (XmlElement el in root["Files"].ChildNodes) {
string fileName = fileUtilityService.RelativeToAbsolutePath(combinepath, el.Attributes["filename"].InnerText);
if (File.Exists(fileName)) {
- fileService.OpenFile(fileName);
+ string relativepath;
+
+ if (!Path.IsPathRooted(el.Attributes["filename"].InnerText) && !el.Attributes["filename"].InnerText.StartsWith (".."))
+ {
+ if (el.Attributes["filename"].InnerText.IndexOf ("." + Path.DirectorySeparatorChar.ToString()) == 0)
+ {
+ relativepath = el.Attributes["filename"].InnerText.Substring(2);
+ }
+ else
+ {
+ relativepath = el.Attributes["filename"].InnerText;
+ }
+ }
+ else
+ {
+ relativepath = System.IO.Path.GetFileName (fileName);
+ }
+ fileService.OpenFileFromProject (fileName, combine.Name, relativepath);
}
}
}
More information about the Monodevelop-patches-list
mailing list