Browse Source

Added a search box for adding project references. It is important for big projects

pull/499/head
Ciprian Khlud 11 years ago
parent
commit
fffcd64ee9
  1. 38
      src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ProjectReferencePanel.cs

38
src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ProjectReferencePanel.cs

@ -27,6 +27,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -27,6 +27,7 @@ namespace ICSharpCode.SharpDevelop.Gui
public class ProjectReferencePanel : ListView, IReferencePanel
{
ISelectReferenceDialog selectDialog;
TextBox filterTextBox;
public ProjectReferencePanel(ISelectReferenceDialog selectDialog)
{
@ -48,6 +49,15 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -48,6 +49,15 @@ namespace ICSharpCode.SharpDevelop.Gui
ItemActivate += delegate { AddReference(); };
PopulateListView();
Panel upperPanel = new Panel { Dock = DockStyle.Top, Height = 20 };
filterTextBox = new TextBox { Width = 150, Dock = DockStyle.Right };
filterTextBox.TextChanged += delegate { Search(); };
upperPanel.Controls.Add(filterTextBox);
this.Controls.Add(upperPanel);
}
public void AddReference()
@ -60,6 +70,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -60,6 +70,7 @@ namespace ICSharpCode.SharpDevelop.Gui
new ProjectReferenceProjectItem(selectDialog.ConfigureProject, project)
);
}
filterTextBox.Text = "";
}
void PopulateListView()
@ -74,5 +85,32 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -74,5 +85,32 @@ namespace ICSharpCode.SharpDevelop.Gui
Items.Add(newItem);
}
}
static bool ContainsAnyOfTokens(string bigText, string[] tokens)
{
if(tokens.Length==0)
return true;
foreach(var token in tokens)
{
if(bigText.Contains(token))
return true;
}
return false;
}
void Search()
{
Items.Clear();
var tokens = filterTextBox.Text.Split(new []{' '}, StringSplitOptions.RemoveEmptyEntries);
foreach (IProject project in ProjectService.OpenSolution.Projects.
Where(pr=>ContainsAnyOfTokens(pr.Name, tokens))
.OrderBy(p => p.Name, StringComparer.OrdinalIgnoreCase)
) {
ListViewItem newItem = new ListViewItem(new string[] { project.Name, project.Directory });
newItem.Tag = project;
Items.Add(newItem);
}
}
}
}

Loading…
Cancel
Save