Beispiel #1
0
 private async Task UninstallPackage_ExecutedAsync(object sender, ExecutedRoutedEventArgs e)
 {
     try
     {
         PipPackageView view = (PipPackageView)e.Parameter;
         await _provider.UninstallPackage(view.Package);
     }
     catch (OperationCanceledException)
     {
     }
     catch (Exception ex) when(!ex.IsCriticalException())
     {
         ToolWindow.SendUnhandledException(this, ExceptionDispatchInfo.Capture(ex));
     }
 }
Beispiel #2
0
        private async void Create_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            var cev = (CondaEnvironmentView)e.Parameter;

            try {
                e.Handled = true;
                await _provider.CreateEnvironmentAsync(cev);
            } catch (OperationCanceledException) {
            } catch (Exception ex) when(!ex.IsCriticalException())
            {
                ToolWindow.SendUnhandledException(this, ExceptionDispatchInfo.Capture(ex));
            }

            CommandManager.InvalidateRequerySuggested();
        }
Beispiel #3
0
 private async void UpgradePackage_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     try {
         var view = (PipPackageView)e.Parameter;
         // Provide Name, not PackageSpec, or we'll upgrade to our
         // current version.
         await _provider.InstallPackage(view.Name, true);
     } catch (OperationCanceledException) {
     } catch (Exception ex) {
         if (ErrorHandler.IsCriticalException(ex))
         {
             throw;
         }
         ToolWindow.SendUnhandledException(this, ExceptionDispatchInfo.Capture(ex));
     }
 }
Beispiel #4
0
 private async Task UpgradePackage_ExecutedAsync(object sender, ExecutedRoutedEventArgs e)
 {
     try
     {
         PipPackageView view = (PipPackageView)e.Parameter;
         // Construct a PackageSpec with the upgraded version.
         await _provider.InstallPackage(new PackageSpec(view.Package.Name, view.UpgradeVersion));
     }
     catch (OperationCanceledException)
     {
     }
     catch (Exception ex) when(!ex.IsCriticalException())
     {
         ToolWindow.SendUnhandledException(this, ExceptionDispatchInfo.Capture(ex));
     }
 }
Beispiel #5
0
        private async Task InstallablePackages_RefreshAsync(object state)
        {
            string query = null;

            try {
                query = await Dispatcher.InvokeAsync(() => SearchQuery);
            } catch (OperationCanceledException) {
                return;
            } catch (Exception ex) when(!ex.IsCriticalException())
            {
                ToolWindow.SendUnhandledException(_provider.WpfObject, ExceptionDispatchInfo.Capture(ex));
            }

            PackageResultView[] installable = null;

            lock (_installable) {
                if (_installable.Any() && !string.IsNullOrEmpty(query))
                {
                    installable = _installable
                                  .Select(p => Tuple.Create(_matcher.GetSortKey(p.Package.PackageSpec, query), p))
                                  .Where(t => _matcher.IsCandidateMatch(t.Item2.Package.PackageSpec, query, t.Item1))
                                  .OrderByDescending(t => t.Item1)
                                  .Select(t => t.Item2)
                                  .Take(20)
                                  .ToArray();
                }
            }

            try {
                await Dispatcher.InvokeAsync(() => {
                    if (installable != null && installable.Any())
                    {
                        _installableFiltered.Merge(installable, PackageViewComparer.Instance, PackageViewComparer.Instance);
                    }
                    else
                    {
                        _installableFiltered.Clear();
                    }
                    _installableView.View.Refresh();
                });
            } catch (OperationCanceledException) {
            } catch (Exception ex) when(!ex.IsCriticalException())
            {
                ToolWindow.SendUnhandledException(_provider.WpfObject, ExceptionDispatchInfo.Capture(ex));
            }
        }
Beispiel #6
0
        private async void InstallablePackages_Refresh(object state)
        {
            string query = null;

            try {
                query = await Dispatcher.InvokeAsync(() => SearchQuery);
            } catch (OperationCanceledException) {
                return;
            } catch (Exception ex) {
                if (ex.IsCriticalException())
                {
                    throw;
                }
                ToolWindow.SendUnhandledException(_provider.WpfObject, ExceptionDispatchInfo.Capture(ex));
            }

            lock (_installable) {
                _installableFiltered.Clear();
                if (_installable.Any() && !string.IsNullOrEmpty(query))
                {
                    _installableFiltered.AddRange(
                        _installable
                        .Select(p => Tuple.Create(_matcher.GetSortKey(p.Package.PackageSpec, query), p))
                        .Where(t => _matcher.IsCandidateMatch(t.Item2.Package.PackageSpec, query, t.Item1))
                        .OrderByDescending(t => t.Item1)
                        .Select(t => t.Item2)
                        .Take(20)
                        );
                }
            }

            try {
                await Dispatcher.InvokeAsync(() => {
                    _installableView.View.Refresh();
                });
            } catch (OperationCanceledException) {
            } catch (Exception ex) {
                if (ex.IsCriticalException())
                {
                    throw;
                }
                ToolWindow.SendUnhandledException(_provider.WpfObject, ExceptionDispatchInfo.Capture(ex));
            }
        }