private void EnableShowInFindResults(LocateFileController controller, LifetimeDefinition definition)
 {
     var itemsToPresent = new List<PresentableGotoItem>();
     controller.FuncEtcItemExecute.Value = delegate
     {
         Shell.Instance.Locks.ExecuteOrQueueReadLock("ShowInFindResults", delegate
         {
             string filterString = controller.Model.FilterText.Value;
             if (string.IsNullOrEmpty(filterString))
             {
                 return;
             }
             filterString = filterString.Replace("*.", ".").Replace(".", "*.");
             definition.Terminate();
             GotoFileBrowserDescriptor descriptor = null;
             if (!Shell.Instance.GetComponent<UITaskExecutor>().FreeThreaded.ExecuteTask("Show Files In Find Results", TaskCancelable.Yes, delegate(IProgressIndicator indicator)
             {
                 indicator.TaskName = string.Format("Collecting symbols matching '{0}'", filterString);
                 indicator.Start(1);
                 ConsumeOccurences(controller, filterString, itemsToPresent);
                 if (itemsToPresent.Any() && !indicator.IsCanceled)
                 {
                     descriptor = CreateGotoFileBrowserDescriptor(controller.Solution, filterString,
                         from item in itemsToPresent
                         select item.Occurence, delegate
                         {
                             itemsToPresent.Clear();
                             ConsumeOccurences(controller, filterString, itemsToPresent);
                             return itemsToPresent.Select(item => item.Occurence);
                         });
                 }
                 indicator.Stop();
             }))
             {
                 if (descriptor != null)
                 {
                     descriptor.LifetimeDefinition.Terminate();
                 }
                 return;
             }
             if (descriptor != null)
             {
                 FindResultsBrowser.ShowResults(descriptor);
             }
         });
     };
 }
        public void Execute(IDataContext context, DelegateExecute nextExecute)
        {
            var solution = context.GetData(ProjectModelConstants.SOLUTION);
            if (solution == null)
            {
                MessageBox.ShowError("Cannot execute the Go To action because there's no solution open.");
                return;
            }

            var definition = Lifetimes.Define(solution.GetLifetime());

            var locks = Shell.Instance.GetComponent<IShellLocks>();
            var tasks = Shell.Instance.GetComponent<ITaskHost>();

            TipsManager.Instance.FeatureIsUsed("LocateFileInSolutionExplorer", (string)null);

            var controller = new LocateFileController(definition.Lifetime, solution, locks, tasks);
            EnableShowInFindResults(controller, definition);
            new GotoByNameMenu(context.GetComponent<GotoByNameMenuComponent>(),
                               definition,
                               controller.Model,
                               context.GetComponent<UIApplication>().MainWindow,
                               context.GetData(GotoByNameDataConstants.CurrentSearchText));
        }
 private static void ConsumeOccurences(LocateFileController controller, string filterString,
     List<PresentableGotoItem> pairsToPresent)
 {
     using (ReadLockCookie.Create())
         controller.ConsumePresentableItems(filterString, -1, (items, behavior) => pairsToPresent.AddRange(items));
 }