From 5fa0f7e1faf0a5ab561d2aca3ddf09c5d7d99c74 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sun, 28 Oct 2007 12:51:12 +0000 Subject: [PATCH] Fixed tracking of current project: Improved finding of the first visible parent node of a project by not using lazy initialization for solution folder nodes. Do not set ProjectService.CurrentProject in SelectFile requests - when changing the active file, ProjectService.ActiveViewContentChanged already takes care of changing the current project. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2736 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../StartPage/Project/Src/ICSharpCodePage.cs | 80 +++++++++---------- .../ProjectBrowser/ProjectBrowserControl.cs | 43 ++++++---- .../TreeNodes/SolutionFolderNode.cs | 5 +- 3 files changed, 66 insertions(+), 62 deletions(-) diff --git a/src/AddIns/Misc/StartPage/Project/Src/ICSharpCodePage.cs b/src/AddIns/Misc/StartPage/Project/Src/ICSharpCodePage.cs index e505612e8b..629be722e0 100644 --- a/src/AddIns/Misc/StartPage/Project/Src/ICSharpCodePage.cs +++ b/src/AddIns/Misc/StartPage/Project/Src/ICSharpCodePage.cs @@ -517,53 +517,49 @@ namespace ICSharpCode.StartPage builder.Append(""); builder.Append(""); } - public string[] projectFiles; - StringBuilder projectSection = null; + internal string[] projectFiles; + public void RenderSectionStartBody(StringBuilder builder) { + StringBuilder projectSection = builder; + projectSection.Append("
\n"); + projectSection.Append(String.Format("\n", + StringParser.Parse("${res:Global.Name}"), + StringParser.Parse("${res:StartPage.StartMenu.ModifiedTable}"), + StringParser.Parse("${res:StartPage.StartMenu.LocationTable}") + )); - if (projectSection == null) { - projectSection = new StringBuilder(); - projectSection.Append("
{0}{1}{2}
\n"); - projectSection.Append(String.Format("\n", - StringParser.Parse("${res:Global.Name}"), - StringParser.Parse("${res:StartPage.StartMenu.ModifiedTable}"), - StringParser.Parse("${res:StartPage.StartMenu.LocationTable}") - )); - - try { - // Get the recent projects - projectFiles = new string[FileService.RecentOpen.RecentProject.Count]; - for (int i = 0; i < FileService.RecentOpen.RecentProject.Count; ++i) { - string fileName = FileService.RecentOpen.RecentProject[i].ToString(); - // if the file does not exist, goto next one - if (!System.IO.File.Exists(fileName)) { - continue; - } - projectFiles[i] = fileName; - projectSection.Append("\n"); + try { + // Get the recent projects + projectFiles = new string[FileService.RecentOpen.RecentProject.Count]; + for (int i = 0; i < FileService.RecentOpen.RecentProject.Count; ++i) { + string fileName = FileService.RecentOpen.RecentProject[i].ToString(); + // if the file does not exist, goto next one + if (!System.IO.File.Exists(fileName)) { + continue; } - } catch {} - projectSection.Append("
{0}{1}{2}
"); - projectSection.Append(""); - projectSection.Append(Path.GetFileNameWithoutExtension(fileName)); - projectSection.Append(""); - projectSection.Append(""); - System.IO.FileInfo fInfo = new System.IO.FileInfo(fileName); - projectSection.Append(fInfo.LastWriteTime.ToShortDateString()); - projectSection.Append(""); - projectSection.Append(fileName); - projectSection.Append("


"); - projectSection.Append(String.Format("\n", - StringParser.Parse("${res:StartPage.StartMenu.OpenCombineButton}") - )); - projectSection.Append(String.Format("\n", - StringParser.Parse("${res:StartPage.StartMenu.NewCombineButton}") - )); - projectSection.Append("


"); - } - builder.Append(projectSection.ToString()); + projectFiles[i] = fileName; + projectSection.Append(""); + projectSection.Append(""); + projectSection.Append(Path.GetFileNameWithoutExtension(fileName)); + projectSection.Append(""); + projectSection.Append(""); + System.IO.FileInfo fInfo = new System.IO.FileInfo(fileName); + projectSection.Append(fInfo.LastWriteTime.ToShortDateString()); + projectSection.Append(""); + projectSection.Append(fileName); + projectSection.Append("\n"); + } + } catch {} + projectSection.Append("

"); + projectSection.Append(String.Format("\n", + StringParser.Parse("${res:StartPage.StartMenu.OpenCombineButton}") + )); + projectSection.Append(String.Format("\n", + StringParser.Parse("${res:StartPage.StartMenu.NewCombineButton}") + )); + projectSection.Append("


"); } public void RenderSectionAuthorBody(StringBuilder builder) diff --git a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserControl.cs b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserControl.cs index abd820cff7..3092d2cd53 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserControl.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserControl.cs @@ -176,28 +176,35 @@ namespace ICSharpCode.SharpDevelop.Project // that we can select it again on opening a folder string lastSelectionTarget; + bool inSelectFile; + /// /// Selects the deepest node open on the path to a particular file. /// public void SelectFile(string fileName) { - lastSelectionTarget = fileName; - TreeNode node = FindFileNode(fileName); - - if (node != null) { - // select first parent that is not collapsed - TreeNode nodeToSelect = node; - TreeNode p = node.Parent; - while (p != null) { - if (!p.IsExpanded) - nodeToSelect = p; - p = p.Parent; - } - if (nodeToSelect != null) { - treeView.SelectedNode = nodeToSelect; + try { + inSelectFile = true; + lastSelectionTarget = fileName; + TreeNode node = FindFileNode(fileName); + + if (node != null) { + // select first parent that is not collapsed + TreeNode nodeToSelect = node; + TreeNode p = node.Parent; + while (p != null) { + if (!p.IsExpanded) + nodeToSelect = p; + p = p.Parent; + } + if (nodeToSelect != null) { + treeView.SelectedNode = nodeToSelect; + } + } else { + SelectDeepestOpenNodeForPath(fileName); } - } else { - SelectDeepestOpenNodeForPath(fileName); + } finally { + inSelectFile = false; } } @@ -400,7 +407,9 @@ namespace ICSharpCode.SharpDevelop.Project if (node == null) { return; } - ProjectService.CurrentProject = node.Project; + if (!inSelectFile) { + ProjectService.CurrentProject = node.Project; + } propertyContainer.SelectedObject = node.Tag; } diff --git a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionFolderNode.cs b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionFolderNode.cs index 62d24af431..ec7a8b53dc 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionFolderNode.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionFolderNode.cs @@ -67,11 +67,10 @@ namespace ICSharpCode.SharpDevelop.Project this.Tag = folder; Text = folder.Name; autoClearNodes = false; - if (!folder.IsEmpty) { - Nodes.Add(new CustomNode()); - } + OpenedImage = "ProjectBrowser.SolutionFolder.Open"; ClosedImage = "ProjectBrowser.SolutionFolder.Closed"; + Initialize(); } public override void AfterLabelEdit(string newName)