Browse Source

Fix progress bar when running a search in the background.

pull/33/head
Daniel Grunwald 13 years ago
parent
commit
5bacb5f5dd
  1. 44
      src/AddIns/Misc/SearchAndReplace/Project/Gui/SearchAndReplacePanel.cs

44
src/AddIns/Misc/SearchAndReplace/Project/Gui/SearchAndReplacePanel.cs

@ -100,33 +100,37 @@ namespace SearchAndReplace @@ -100,33 +100,37 @@ namespace SearchAndReplace
void FindAllButtonClicked(object sender, EventArgs e)
{
WritebackOptions();
using (var monitor = WorkbenchSingleton.StatusBar.CreateProgressMonitor()) {
monitor.TaskName = StringParser.Parse("${res:AddIns.SearchReplace.SearchProgressTitle}");
try {
var location = new SearchLocation(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, SearchOptions.SearchTarget == SearchTarget.CurrentSelection ? SearchManager.GetActiveSelection(false) : null);
var strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode);
var results = SearchManager.FindAllParallel(strategy, location, monitor);
SearchManager.ShowSearchResults(SearchOptions.FindPattern, results);
} catch (SearchPatternException ex) {
MessageService.ShowError(ex.Message);
} catch (OperationCanceledException) {}
var location = new SearchLocation(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, SearchOptions.SearchTarget == SearchTarget.CurrentSelection ? SearchManager.GetActiveSelection(false) : null);
ISearchStrategy strategy;
try {
strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode);
} catch (SearchPatternException ex) {
MessageService.ShowError(ex.Message);
return;
}
// No using block for the monitor; it is disposed when the asynchronous search finishes
var monitor = WorkbenchSingleton.StatusBar.CreateProgressMonitor();
monitor.TaskName = StringParser.Parse("${res:AddIns.SearchReplace.SearchProgressTitle}");
var results = SearchManager.FindAllParallel(strategy, location, monitor);
SearchManager.ShowSearchResults(SearchOptions.FindPattern, results);
}
void BookmarkAllButtonClicked(object sender, EventArgs e)
{
WritebackOptions();
using (var monitor = WorkbenchSingleton.StatusBar.CreateProgressMonitor()) {
monitor.TaskName = StringParser.Parse("${res:AddIns.SearchReplace.SearchProgressTitle}");
try {
var location = new SearchLocation(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, SearchOptions.SearchTarget == SearchTarget.CurrentSelection ? SearchManager.GetActiveSelection(false) : null);
var strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode);
var results = SearchManager.FindAllParallel(strategy, location, monitor);
SearchManager.MarkAll(results);
} catch (SearchPatternException ex) {
MessageService.ShowError(ex.Message);
} catch (OperationCanceledException) {}
var location = new SearchLocation(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, SearchOptions.SearchTarget == SearchTarget.CurrentSelection ? SearchManager.GetActiveSelection(false) : null);
ISearchStrategy strategy;
try {
strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode);
} catch (SearchPatternException ex) {
MessageService.ShowError(ex.Message);
return;
}
// No using block for the monitor; it is disposed when the asynchronous search finishes
var monitor = WorkbenchSingleton.StatusBar.CreateProgressMonitor();
monitor.TaskName = StringParser.Parse("${res:AddIns.SearchReplace.SearchProgressTitle}");
var results = SearchManager.FindAllParallel(strategy, location, monitor);
SearchManager.MarkAll(results);
}
void ReplaceAllButtonClicked(object sender, EventArgs e)

Loading…
Cancel
Save