Browse Source

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
shortcuts
Daniel Grunwald 18 years ago
parent
commit
5fa0f7e1fa
  1. 80
      src/AddIns/Misc/StartPage/Project/Src/ICSharpCodePage.cs
  2. 43
      src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserControl.cs
  3. 5
      src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionFolderNode.cs

80
src/AddIns/Misc/StartPage/Project/Src/ICSharpCodePage.cs

@ -517,53 +517,49 @@ namespace ICSharpCode.StartPage @@ -517,53 +517,49 @@ namespace ICSharpCode.StartPage
builder.Append("</td>");
builder.Append("</tr></table></td></tr></table></td>");
}
public string[] projectFiles;
StringBuilder projectSection = null;
internal string[] projectFiles;
public void RenderSectionStartBody(StringBuilder builder)
{
StringBuilder projectSection = builder;
projectSection.Append("<DIV class='tablediv'><TABLE CLASS='dtTABLE' CELLSPACING='0'>\n");
projectSection.Append(String.Format("<TR><TH>{0}</TH><TH>{1}</TH><TH>{2}</TH></TR>\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("<DIV class='tablediv'><TABLE CLASS='dtTABLE' CELLSPACING='0'>\n");
projectSection.Append(String.Format("<TR><TH>{0}</TH><TH>{1}</TH><TH>{2}</TH></TR>\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("<TR><TD>");
projectSection.Append("<a href=\"startpage://project/" + i + "\">");
projectSection.Append(Path.GetFileNameWithoutExtension(fileName));
projectSection.Append("</A>");
projectSection.Append("</TD><TD>");
System.IO.FileInfo fInfo = new System.IO.FileInfo(fileName);
projectSection.Append(fInfo.LastWriteTime.ToShortDateString());
projectSection.Append("</TD><TD>");
projectSection.Append(fileName);
projectSection.Append("</TD></TR>\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("</TABLE></DIV><BR/><BR/>");
projectSection.Append(String.Format("<button id=\"opencombine\">{0}</button>\n",
StringParser.Parse("${res:StartPage.StartMenu.OpenCombineButton}")
));
projectSection.Append(String.Format("<button id=\"newcombine\">{0}</button>\n",
StringParser.Parse("${res:StartPage.StartMenu.NewCombineButton}")
));
projectSection.Append("<BR/><BR/><BR/>");
}
builder.Append(projectSection.ToString());
projectFiles[i] = fileName;
projectSection.Append("<TR><TD>");
projectSection.Append("<a href=\"startpage://project/" + i + "\">");
projectSection.Append(Path.GetFileNameWithoutExtension(fileName));
projectSection.Append("</A>");
projectSection.Append("</TD><TD>");
System.IO.FileInfo fInfo = new System.IO.FileInfo(fileName);
projectSection.Append(fInfo.LastWriteTime.ToShortDateString());
projectSection.Append("</TD><TD>");
projectSection.Append(fileName);
projectSection.Append("</TD></TR>\n");
}
} catch {}
projectSection.Append("</TABLE></DIV><BR/><BR/>");
projectSection.Append(String.Format("<button id=\"opencombine\">{0}</button>\n",
StringParser.Parse("${res:StartPage.StartMenu.OpenCombineButton}")
));
projectSection.Append(String.Format("<button id=\"newcombine\">{0}</button>\n",
StringParser.Parse("${res:StartPage.StartMenu.NewCombineButton}")
));
projectSection.Append("<BR/><BR/><BR/>");
}
public void RenderSectionAuthorBody(StringBuilder builder)

43
src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserControl.cs

@ -176,28 +176,35 @@ namespace ICSharpCode.SharpDevelop.Project @@ -176,28 +176,35 @@ namespace ICSharpCode.SharpDevelop.Project
// that we can select it again on opening a folder
string lastSelectionTarget;
bool inSelectFile;
/// <summary>
/// Selects the deepest node open on the path to a particular file.
/// </summary>
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 @@ -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;
}

5
src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionFolderNode.cs

@ -67,11 +67,10 @@ namespace ICSharpCode.SharpDevelop.Project @@ -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)

Loading…
Cancel
Save