Esempio n. 1
0
        private async Task SwitchToAvailablePackagesAsync()
        {
            _coreShell.AssertIsOnMainThread();
            await EnsureInstalledAndAvailablePackagesLoadedAsync();

            if (_availablePackages == null)
            {
                return;
            }
            _items.ReplaceWith(_availablePackages);
        }
Esempio n. 2
0
 private void ReplaceItems(IList <IRPackageViewModel> packages)
 {
     _coreShell.AssertIsOnMainThread();
     if (string.IsNullOrEmpty(_searchString))
     {
         _items.ReplaceWith(packages);
         UpdateSelectedPackage(packages);
     }
     else
     {
         Search(packages, _searchString, CancellationToken.None);
     }
 }
Esempio n. 3
0
        private async Task ReplaceItemsAsync(IList <IRPackageViewModel> packages)
        {
            await _coreShell.SwitchToMainThreadAsync();

            if (string.IsNullOrEmpty(_searchString))
            {
                _items.ReplaceWith(packages);
                UpdateSelectedPackage(packages);
            }
            else
            {
                Search(packages, _searchString, CancellationToken.None);
            }
        }
        private void UpdateConnections()
        {
            var selectedId = EditedConnection?.Id;

            _items.ReplaceWith(_connectionManager.RecentConnections.Select(c => new ConnectionViewModel(c)
            {
                IsActive    = c == _connectionManager.ActiveConnection,
                IsConnected = c == _connectionManager.ActiveConnection && IsConnected
            }).OrderBy(c => c.Name));

            var editedConnection = Items.FirstOrDefault(i => i.Id == selectedId);

            if (editedConnection != null)
            {
                EditedConnection = editedConnection;
            }
        }
Esempio n. 5
0
        public async Task RefreshEnvironmentsAsync(CancellationToken cancellationToken = default(CancellationToken))
        {
            using (_disposeToken.Link(ref cancellationToken)) {
                var session = _rSession;

                await TaskUtilities.SwitchToBackgroundThread();

                var  envs    = new List <REnvironment>();
                bool success = false;
                try {
                    var traceback = (await session.TracebackAsync(cancellationToken: cancellationToken))
                                    .Skip(1) // skip global - it's in the search path already
                                    .Select(frame => new REnvironment(frame))
                                    .Reverse();
                    if (traceback.Any())
                    {
                        envs.AddRange(traceback);
                        envs.Add(null);
                    }

                    var searchPath = (await session.EvaluateAsync <string[]>("as.list(search())", REvaluationKind.BaseEnv, cancellationToken))
                                     .Except(_hiddenEnvironments)
                                     .Select(name => new REnvironment(name));
                    envs.AddRange(searchPath);

                    success = true;
                } catch (RException) {
                } catch (OperationCanceledException) {
                }

                await _mainThread.SwitchToAsync(cancellationToken);

                var oldSelection = _selectedEnvironment;
                _environments.ReplaceWith(success ? envs : _errorEnvironments);

                IREnvironment newSelection = null;
                if (oldSelection != null)
                {
                    newSelection = _environments?.FirstOrDefault(env => env?.Name == oldSelection.Name);
                }
                SelectedEnvironment = newSelection ?? _environments.FirstOrDefault();
            }
        }
Esempio n. 6
0
        public async Task RefreshEnvironmentsAsync()
        {
            await TaskUtilities.SwitchToBackgroundThread();

            var  envs    = new List <REnvironment>();
            bool success = false;

            try {
                var traceback = (await _rSession.TracebackAsync())
                                .Skip(1) // skip global - it's in the search path already
                                .Select(frame => new REnvironment(frame))
                                .Reverse();
                if (traceback.Any())
                {
                    envs.AddRange(traceback);
                    envs.Add(null);
                }

                var searchPath = (await _rSession.EvaluateAsync <string[]>("as.list(search())", REvaluationKind.BaseEnv))
                                 .Except(_hiddenEnvironments)
                                 .Select(name => new REnvironment(name));
                envs.AddRange(searchPath);

                success = true;
            } catch (RException) {
            } catch (MessageTransportException) {
            } catch (OperationCanceledException) {
            }

            VsAppShell.Current.DispatchOnUIThread(() => {
                var oldSelection = _selectedEnvironment;
                _environments.ReplaceWith(success ? envs : _errorEnvironments);

                IREnvironment newSelection = null;
                if (oldSelection != null)
                {
                    newSelection = _environments?.FirstOrDefault(env => env?.Name == oldSelection.Name);
                }
                SelectedEnvironment = newSelection ?? _environments.FirstOrDefault();
            });
        }
Esempio n. 7
0
        private void UpdateConnections()
        {
            var selectedId = EditedConnection?.Id;

            _localConnections.ReplaceWith(_connectionManager.RecentConnections
                                          .Where(c => !c.IsRemote)
                                          .Select(CreateConnectionViewModel)
                                          .OrderBy(c => c.Name));

            _remoteConnections.ReplaceWith(_connectionManager.RecentConnections
                                           .Where(c => c.IsRemote)
                                           .Select(CreateConnectionViewModel)
                                           .OrderBy(c => c.Name));

            var editedConnection = RemoteConnections.FirstOrDefault(i => i.Id == selectedId);

            if (editedConnection != null)
            {
                EditedConnection = editedConnection;
            }

            HasLocalConnections = _localConnections.Count > 0;
        }