示例#1
0
        private async Task AddPackageDetailsAsync(IRPackageViewModel package)
        {
            _coreShell.AssertIsOnMainThread();
            var details = await GetAdditionalPackageInfoAsync(package);

            package.AddDetails(details, false);
        }
示例#2
0
        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;
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
 private void BeforeLoadUnload(IRPackageViewModel package)
 {
     if (_selectedTab == Tab.InstalledPackages || _selectedTab == Tab.LoadedPackages)
     {
         IsLoading = true;
     }
     package.IsChanging = true;
 }
示例#6
0
        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);
        }
示例#7
0
        public void SelectPackage(IRPackageViewModel package)
        {
            _mainThread.Assert();
            if (package == _selectedPackage)
            {
                return;
            }

            SelectedPackage = package;
        }
示例#8
0
        public void SelectPackage(IRPackageViewModel package)
        {
            _coreShell.AssertIsOnMainThread();
            if (package == _selectedPackage)
            {
                return;
            }

            SelectedPackage = package;
        }
示例#9
0
        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);
        }
示例#10
0
 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);
     }
 }
示例#11
0
        public void SelectPackage(IRPackageViewModel package)
        {
            _coreShell.AssertIsOnMainThread();
            if (package == _selectedPackage)
            {
                return;
            }

            SelectedPackage = package;
            if (package == null)
            {
                return;
            }

            if (!package.HasDetails)
            {
                DispatchOnMainThreadAsync(() => AddPackageDetailsAsync(package));
            }
        }
示例#12
0
        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);
        }
示例#13
0
        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);
        }
示例#14
0
        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);
        }
示例#15
0
        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);
        }
示例#16
0
        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);
        }
示例#17
0
        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);
        }
示例#18
0
        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);
        }
示例#19
0
        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);
        }
示例#20
0
 private void AfterLoadUnload(IRPackageViewModel package, Tab startingTab)
 {
     _mainThread.Assert();
     ReplaceItems(startingTab);
     package.IsChanging = false;
 }
示例#21
0
        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;
示例#26
0
        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;
        }
示例#27
0
 private async Task AfterLoadUnloadAsync(IRPackageViewModel package, Tab startingTab, CancellationToken cancellationToken) {
     await ReplaceItemsAsync(startingTab, cancellationToken);
     package.IsChanging = false;
 }
示例#28
0
        public void SelectPackage(IRPackageViewModel package) {
            _coreShell.AssertIsOnMainThread();
            if (package == _selectedPackage) {
                return;
            }

            SelectedPackage = package;
        }
示例#29
0
        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);
        }
示例#30
0
 private void BeforeLoadUnload(IRPackageViewModel package) {
     if (_selectedTab == Tab.InstalledPackages || _selectedTab == Tab.LoadedPackages) {
         IsLoading = true;
     }
     package.IsChanging = true;
 }
示例#31
0
        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) { }
示例#33
0
        private async Task AfterLoadUnloadAsync(IRPackageViewModel package, Tab startingTab, CancellationToken cancellationToken)
        {
            await ReplaceItemsAsync(startingTab, cancellationToken);

            package.IsChanging = false;
        }
示例#34
0
        private async Task AfterLoadUnloadAsync(IRPackageViewModel package, Tab startingTab)
        {
            await ReplaceItemsAsync(startingTab);

            package.IsChanging = false;
        }
示例#35
0
        private async Task <RPackage> GetAdditionalPackageInfoAsync(IRPackageViewModel package)
        {
            await TaskUtilities.SwitchToBackgroundThread();

            return(await _packageManager.GetAdditionalPackageInfoAsync(package.Name, package.Repository));
        }
 public Task UnloadAsync(IRPackageViewModel package, CancellationToken cancellationToken) => Task.CompletedTask;
 public void SelectPackage(IRPackageViewModel package)
 {
 }