private async Task AddPackageDetailsAsync(IRPackageViewModel package) { _coreShell.AssertIsOnMainThread(); var details = await GetAdditionalPackageInfoAsync(package); package.AddDetails(details, false); }
public async Task InstallAsync(IRPackageViewModel package) { await _coreShell.SwitchToMainThreadAsync(); if (package.IsInstalled || package.IsChanging) { return; } package.IsChanging = true; if (_selectedTab == SelectedTab.InstalledPackages) { IsLoading = true; } try { var libPath = await GetLibPath(); await _packageManager.InstallPackageAsync(package.Name, libPath); } catch (RPackageManagerException ex) { AddErrorMessage(ex.Message); } await ReloadInstalledAndLoadedPackagesAsync(); if (_selectedTab == SelectedTab.InstalledPackages) { IsLoading = false; ReplaceItems(_installedPackages); } package.IsChanging = false; }
public async Task InstallAsync(IRPackageViewModel package) { await _coreShell.SwitchToMainThreadAsync(); if (package.IsInstalled || package.IsChanging) { return; } BeforeLoadUnload(package); var startingTab = _selectedTab; try { var libPath = await _packageManager.GetLibraryPathAsync(); await _packageManager.InstallPackageAsync(package.Name, libPath); } catch (RHostDisconnectedException) { _errorMessages.Add(Resources.PackageManager_CantInstallPackageNoRSession.FormatCurrent(package.Name), ErrorMessageType.PackageOperations); } catch (RPackageManagerException ex) { _errorMessages.Add(ex.Message, ErrorMessageType.PackageOperations); } await EnsureInstalledAndLoadedPackagesAsync(true); await AfterLoadUnloadAsync(package, startingTab); }
public async Task UpdateAsync(IRPackageViewModel package, CancellationToken cancellationToken = default(CancellationToken)) { await _mainThread.SwitchToAsync(cancellationToken); if (!package.IsInstalled || package.IsChanging) { return; } var message = Resources.PackageManager_PackageUpdateWarning.FormatCurrent(package.Name); var confirmUpdate = _services.ShowMessage(message, MessageButtons.YesNo); if (confirmUpdate != MessageButtons.Yes) { return; } var startingTab = _selectedTab; BeforeLoadUnload(package); await UpdateImplAsync(package, cancellationToken); AfterLoadUnload(package, startingTab); }
private void BeforeLoadUnload(IRPackageViewModel package) { if (_selectedTab == Tab.InstalledPackages || _selectedTab == Tab.LoadedPackages) { IsLoading = true; } package.IsChanging = true; }
public async Task UninstallAsync(IRPackageViewModel package, CancellationToken cancellationToken = default(CancellationToken)) { await _mainThread.SwitchToAsync(cancellationToken); if (!package.IsInstalled || package.IsChanging) { return; } var confirmUninstall = _services.ShowMessage( Resources.PackageManager_PackageUninstallWarning.FormatCurrent(package.Name, package.LibraryPath), MessageButtons.YesNo); if (confirmUninstall != MessageButtons.Yes) { return; } BeforeLoadUnload(package); var startingTab = _selectedTab; if (package.IsLoaded) { try { await _packageManager.UnloadPackageAsync(package.Name, cancellationToken); } catch (RHostDisconnectedException) { _errorMessages.Add( Resources.PackageManager_CantUnloadPackageNoRSession.FormatCurrent(package.Name), ErrorMessageType.PackageOperations); } catch (RPackageManagerException ex) { _errorMessages.Add(ex.Message, ErrorMessageType.PackageOperations); } await ReloadLoadedPackagesAsync(cancellationToken); } if (!package.IsLoaded) { try { var libPath = package.LibraryPath.ToRPath(); var packageLockState = await _packageManager.UninstallPackageAsync(package.Name, libPath, cancellationToken); if (packageLockState != PackageLockState.Unlocked) { ShowPackageLockedMessage(packageLockState, package.Name); } } catch (RHostDisconnectedException) { _errorMessages.Add(Resources.PackageManager_CantUninstallPackageNoRSession.FormatCurrent(package.Name), ErrorMessageType.PackageOperations); } catch (RPackageManagerException ex) { _errorMessages.Add(ex.Message, ErrorMessageType.PackageOperations); } await EnsureInstalledAndLoadedPackagesAsync(true, cancellationToken); } AfterLoadUnload(package, startingTab); }
public void SelectPackage(IRPackageViewModel package) { _mainThread.Assert(); if (package == _selectedPackage) { return; } SelectedPackage = package; }
public void SelectPackage(IRPackageViewModel package) { _coreShell.AssertIsOnMainThread(); if (package == _selectedPackage) { return; } SelectedPackage = package; }
public async Task UninstallAsync(IRPackageViewModel package) { await _coreShell.SwitchToMainThreadAsync(); if (!package.IsInstalled || package.IsChanging) { return; } var confirmUninstall = _coreShell.ShowMessage(string.Format(CultureInfo.CurrentCulture, Resources.PackageManager_PackageUninstallWarning, package.Name, package.LibraryPath), MessageButtons.YesNo); if (confirmUninstall != MessageButtons.Yes) { return; } BeforeLoadUnload(package); var startingTab = _selectedTab; if (package.IsLoaded) { try { await _packageManager.UnloadPackageAsync(package.Name); } catch (RHostDisconnectedException) { AddErrorMessage(string.Format(CultureInfo.CurrentCulture, Resources.PackageManager_CantUnloadPackageNoRSession, package.Name)); } catch (RPackageManagerException ex) { AddErrorMessage(ex.Message); } await ReloadLoadedPackagesAsync(); } if (!package.IsLoaded) { try { var libPath = package.LibraryPath.ToRPath(); var packageLockState = await _packageManager.UninstallPackageAsync(package.Name, libPath); if (packageLockState != PackageLockState.Unlocked) { ShowPackageLockedMessage(packageLockState, package.Name); } } catch (RHostDisconnectedException) { AddErrorMessage(string.Format(CultureInfo.CurrentCulture, Resources.PackageManager_CantUninstallPackageNoRSession, package.Name)); } catch (RPackageManagerException ex) { AddErrorMessage(ex.Message); } await ReloadInstalledAndLoadedPackagesAsync(); } await AfterLoadUnloadAsync(package, startingTab); }
private void AfterLoadUnload(IRPackageViewModel package) { package.IsChanging = false; if (_selectedTab == SelectedTab.LoadedPackages) { IsLoading = false; ReplaceItems(_loadedPackages); } else if (_selectedTab == SelectedTab.InstalledPackages) { IsLoading = false; ReplaceItems(_installedPackages); } }
public void SelectPackage(IRPackageViewModel package) { _coreShell.AssertIsOnMainThread(); if (package == _selectedPackage) { return; } SelectedPackage = package; if (package == null) { return; } if (!package.HasDetails) { DispatchOnMainThreadAsync(() => AddPackageDetailsAsync(package)); } }
public async Task UnloadAsync(IRPackageViewModel package) { await _coreShell.SwitchToMainThreadAsync(); if (!package.IsLoaded) { return; } package.IsChanging = true; BeforeLoadUnload(); try { await _packageManager.UnloadPackageAsync(package.Name); } catch (RPackageManagerException ex) { AddErrorMessage(ex.Message); } await ReloadLoadedPackagesAsync(); AfterLoadUnload(package); }
public async Task LoadAsync(IRPackageViewModel package, CancellationToken cancellationToken = default(CancellationToken)) { await _coreShell.SwitchToMainThreadAsync(cancellationToken); if (package.IsLoaded) { return; } BeforeLoadUnload(package); var startingTab = _selectedTab; try { await _packageManager.LoadPackageAsync(package.Name, package.LibraryPath.ToRPath(), cancellationToken); } catch (RHostDisconnectedException) { _errorMessages.Add(Resources.PackageManager_CantLoadPackageNoRSession.FormatCurrent(package.Name), ErrorMessageType.PackageOperations); } catch (RPackageManagerException ex) { _errorMessages.Add(ex.Message, ErrorMessageType.PackageOperations); } await ReloadLoadedPackagesAsync(cancellationToken); await AfterLoadUnloadAsync(package, startingTab, cancellationToken); }
public async Task UnloadAsync(IRPackageViewModel package) { await _coreShell.SwitchToMainThreadAsync(); if (!package.IsLoaded) { return; } BeforeLoadUnload(package); var startingTab = _selectedTab; try { await _packageManager.UnloadPackageAsync(package.Name); } catch (RHostDisconnectedException) { _errorMessages.Add(Resources.PackageManager_CantUnloadPackageNoRSession.FormatCurrent(package.Name), ErrorMessageType.PackageOperations); } catch (RPackageManagerException ex) { _errorMessages.Add(ex.Message, ErrorMessageType.PackageOperations); } await ReloadLoadedPackagesAsync(); await AfterLoadUnloadAsync(package, startingTab); }
public async Task LoadAsync(IRPackageViewModel package) { await _coreShell.SwitchToMainThreadAsync(); if (package.IsLoaded) { return; } BeforeLoadUnload(package); var startingTab = _selectedTab; try { await _packageManager.LoadPackageAsync(package.Name, package.LibraryPath.ToRPath()); } catch (RHostDisconnectedException) { AddErrorMessage(string.Format(CultureInfo.CurrentCulture, Resources.PackageManager_CantLoadPackageNoRSession, package.Name)); } catch (RPackageManagerException ex) { AddErrorMessage(ex.Message); } await ReloadLoadedPackagesAsync(); await AfterLoadUnloadAsync(package, startingTab); }
public async Task UpdateAsync(IRPackageViewModel package) { await _coreShell.SwitchToMainThreadAsync(); if (!package.IsInstalled || package.IsChanging) { return; } var confirmUpdate = _coreShell.ShowMessage(string.Format(CultureInfo.CurrentCulture, Resources.PackageManager_PackageUpdateWarning, package.Name), MessageButtons.YesNo); if (confirmUpdate != MessageButtons.Yes) { return; } var startingTab = _selectedTab; BeforeLoadUnload(package); await UpdateImplAsync(package); await AfterLoadUnloadAsync(package, startingTab); }
private async Task UpdateImplAsync(IRPackageViewModel package) { await _coreShell.SwitchToMainThreadAsync(); if (package.IsLoaded) { try { await _packageManager.UnloadPackageAsync(package.Name); } catch (RHostDisconnectedException) { _errorMessages.Add(Resources.PackageManager_CantUnloadPackageNoRSession.FormatCurrent(package.Name), ErrorMessageType.PackageOperations); } catch (RPackageManagerException ex) { _errorMessages.Add(ex.Message, ErrorMessageType.PackageOperations); } await ReloadLoadedPackagesAsync(); } if (!package.IsLoaded) { try { var libPath = package.LibraryPath.ToRPath(); try { var packageLockState = await _packageManager.UpdatePackageAsync(package.Name, libPath); if (packageLockState != PackageLockState.Unlocked) { ShowPackageLockedMessage(packageLockState, package.Name); } } catch (RHostDisconnectedException) { _errorMessages.Add(Resources.PackageManager_CantUpdatePackageNoRSession.FormatCurrent(package.Name), ErrorMessageType.PackageOperations); } } catch (RPackageManagerException ex) { _errorMessages.Add(ex.Message, ErrorMessageType.PackageOperations); } } await EnsureInstalledAndLoadedPackagesAsync(true); }
public async Task UpdateAsync(IRPackageViewModel package, CancellationToken cancellationToken = default(CancellationToken)) { await _coreShell.SwitchToMainThreadAsync(cancellationToken); if (!package.IsInstalled || package.IsChanging) { return; } var confirmUpdate = _coreShell.ShowMessage(string.Format(CultureInfo.CurrentCulture, Resources.PackageManager_PackageUpdateWarning, package.Name), MessageButtons.YesNo); if (confirmUpdate != MessageButtons.Yes) { return; } var startingTab = _selectedTab; BeforeLoadUnload(package); await UpdateImplAsync(package, cancellationToken); await AfterLoadUnloadAsync(package, startingTab, cancellationToken); }
private async Task UpdateImplAsync(IRPackageViewModel package, CancellationToken cancellationToken) { await _coreShell.SwitchToMainThreadAsync(cancellationToken); if (package.IsLoaded) { try { await _packageManager.UnloadPackageAsync(package.Name, cancellationToken); } catch (RHostDisconnectedException) { _errorMessages.Add(Resources.PackageManager_CantUnloadPackageNoRSession.FormatCurrent(package.Name), ErrorMessageType.PackageOperations); } catch (RPackageManagerException ex) { _errorMessages.Add(ex.Message, ErrorMessageType.PackageOperations); } await ReloadLoadedPackagesAsync(cancellationToken); } if (!package.IsLoaded) { try { var libPath = package.LibraryPath.ToRPath(); try { var packageLockState = await _packageManager.UpdatePackageAsync(package.Name, libPath, cancellationToken); if (packageLockState != PackageLockState.Unlocked) { ShowPackageLockedMessage(packageLockState, package.Name); } } catch (RHostDisconnectedException) { _errorMessages.Add(Resources.PackageManager_CantUpdatePackageNoRSession.FormatCurrent(package.Name), ErrorMessageType.PackageOperations); } } catch (RPackageManagerException ex) { _errorMessages.Add(ex.Message, ErrorMessageType.PackageOperations); } } await EnsureInstalledAndLoadedPackagesAsync(true, cancellationToken); }
private void AfterLoadUnload(IRPackageViewModel package, Tab startingTab) { _mainThread.Assert(); ReplaceItems(startingTab); package.IsChanging = false; }
public async Task UninstallAsync(IRPackageViewModel package, CancellationToken cancellationToken = default(CancellationToken)) { await _coreShell.SwitchToMainThreadAsync(cancellationToken); if (!package.IsInstalled || package.IsChanging) { return; } var confirmUninstall = _coreShell.ShowMessage(string.Format(CultureInfo.CurrentCulture, Resources.PackageManager_PackageUninstallWarning, package.Name, package.LibraryPath), MessageButtons.YesNo); if (confirmUninstall != MessageButtons.Yes) { return; } BeforeLoadUnload(package); var startingTab = _selectedTab; if (package.IsLoaded) { try { await _packageManager.UnloadPackageAsync(package.Name, cancellationToken); } catch (RHostDisconnectedException) { _errorMessages.Add(Resources.PackageManager_CantUnloadPackageNoRSession.FormatCurrent(package.Name), ErrorMessageType.PackageOperations); } catch (RPackageManagerException ex) { _errorMessages.Add(ex.Message, ErrorMessageType.PackageOperations); } await ReloadLoadedPackagesAsync(cancellationToken); } if (!package.IsLoaded) { try { var libPath = package.LibraryPath.ToRPath(); var packageLockState = await _packageManager.UninstallPackageAsync(package.Name, libPath, cancellationToken); if (packageLockState != PackageLockState.Unlocked) { ShowPackageLockedMessage(packageLockState, package.Name); } } catch (RHostDisconnectedException) { _errorMessages.Add(Resources.PackageManager_CantUninstallPackageNoRSession.FormatCurrent(package.Name), ErrorMessageType.PackageOperations); } catch (RPackageManagerException ex) { _errorMessages.Add(ex.Message, ErrorMessageType.PackageOperations); } await EnsureInstalledAndLoadedPackagesAsync(true, cancellationToken); } await AfterLoadUnloadAsync(package, startingTab, cancellationToken); }
public Task UnloadAsync(IRPackageViewModel package, CancellationToken cancellationToken) => Task.CompletedTask;
public Task UnloadAsync(IRPackageViewModel package) => Task.CompletedTask;
public Task UninstallAsync(IRPackageViewModel package) => Task.CompletedTask;
public Task UpdateAsync(IRPackageViewModel package) => Task.CompletedTask;
public async Task UninstallAsync(IRPackageViewModel package) { await _coreShell.SwitchToMainThreadAsync(); if (!package.IsInstalled || package.IsChanging) { return; } var confirmUninstall = _coreShell.ShowMessage(string.Format(CultureInfo.CurrentCulture, Resources.PackageManager_PackageUninstallWarning, package.Name, package.LibraryPath), MessageButtons.YesNo); if (confirmUninstall != MessageButtons.Yes) { return; } package.IsChanging = true; if (_selectedTab == SelectedTab.InstalledPackages || _selectedTab == SelectedTab.LoadedPackages) { IsLoading = true; } if (package.IsLoaded) { try { await _packageManager.UnloadPackageAsync(package.Name); } catch (RPackageManagerException ex) { AddErrorMessage(ex.Message); } await ReloadLoadedPackagesAsync(); } if (!package.IsLoaded) { try { var libPath = package.LibraryPath.ToRPath(); var packageLockState = _packageManager.GetPackageLockState(package.Name, libPath); if (packageLockState == PackageLockState.Unlocked) { await _packageManager.UninstallPackageAsync(package.Name, libPath); } else { ShowPackageLockedMessage(packageLockState, package.Name); } } catch (RPackageManagerException ex) { AddErrorMessage(ex.Message); } await ReloadInstalledAndLoadedPackagesAsync(); } if (_selectedTab == SelectedTab.InstalledPackages) { ReplaceItems(_installedPackages); IsLoading = false; } else if (_selectedTab == SelectedTab.LoadedPackages) { ReplaceItems(_loadedPackages); IsLoading = false; } package.IsChanging = false; }
private async Task AfterLoadUnloadAsync(IRPackageViewModel package, Tab startingTab, CancellationToken cancellationToken) { await ReplaceItemsAsync(startingTab, cancellationToken); package.IsChanging = false; }
public async Task InstallAsync(IRPackageViewModel package, CancellationToken cancellationToken = default(CancellationToken)) { await _coreShell.SwitchToMainThreadAsync(cancellationToken); if (package.IsInstalled || package.IsChanging) { return; } BeforeLoadUnload(package); var startingTab = _selectedTab; try { var libPath = await _packageManager.GetLibraryPathAsync(cancellationToken); await _packageManager.InstallPackageAsync(package.Name, libPath, cancellationToken); } catch (RHostDisconnectedException) { _errorMessages.Add(Resources.PackageManager_CantInstallPackageNoRSession.FormatCurrent(package.Name), ErrorMessageType.PackageOperations); } catch (RPackageManagerException ex) { _errorMessages.Add(ex.Message, ErrorMessageType.PackageOperations); } await EnsureInstalledAndLoadedPackagesAsync(true, cancellationToken); await AfterLoadUnloadAsync(package, startingTab, cancellationToken); }
public async Task UnloadAsync(IRPackageViewModel package, CancellationToken cancellationToken = default(CancellationToken)) { await _coreShell.SwitchToMainThreadAsync(cancellationToken); if (!package.IsLoaded) { return; } BeforeLoadUnload(package); var startingTab = _selectedTab; try { await _packageManager.UnloadPackageAsync(package.Name, cancellationToken); } catch (RHostDisconnectedException) { _errorMessages.Add(Resources.PackageManager_CantUnloadPackageNoRSession.FormatCurrent(package.Name), ErrorMessageType.PackageOperations); } catch (RPackageManagerException ex) { _errorMessages.Add(ex.Message, ErrorMessageType.PackageOperations); } await ReloadLoadedPackagesAsync(cancellationToken); await AfterLoadUnloadAsync(package, startingTab, cancellationToken); }
public void SelectPackage(IRPackageViewModel package) { }
private async Task AfterLoadUnloadAsync(IRPackageViewModel package, Tab startingTab) { await ReplaceItemsAsync(startingTab); package.IsChanging = false; }
private async Task <RPackage> GetAdditionalPackageInfoAsync(IRPackageViewModel package) { await TaskUtilities.SwitchToBackgroundThread(); return(await _packageManager.GetAdditionalPackageInfoAsync(package.Name, package.Repository)); }