Error() public static method

public static Error ( string text ) : VariableViewModel
text string
return VariableViewModel
Esempio n. 1
0
        private async Task SetRootModelAsync(REnvironment env)
        {
            _shell.AssertIsOnMainThread();

            if (env.Kind != REnvironmentKind.Error)
            {
                try {
                    var result = await EvaluateAndDescribeAsync(env);

                    var wrapper = new VariableViewModel(result, _aggregator);
                    _rootNode.Model = new VariableNode(_settings, wrapper);
                } catch (RException ex) {
                    SetRootNode(VariableViewModel.Error(ex.Message));
                } catch (RHostDisconnectedException ex) {
                    SetRootNode(VariableViewModel.Error(ex.Message));
                }
            }
            else
            {
                SetRootNode(VariableViewModel.Error(env.Name));
            }

            // Some of the Variable Explorer tool bar buttons are depend on the R Environment (e.g., Delete all Variables button).
            // This will give those UI elements a chance to update state.
            _shell.UpdateCommandStatus();
        }
Esempio n. 2
0
 private void EnvironmentComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if ((EnvironmentComboBox.ItemsSource != _defaultEnvironments) && (e.AddedItems.Count > 0))
     {
         var env = e.AddedItems[0] as REnvironment;
         if (env != null)
         {
             if (env.Kind == REnvironmentKind.Error)
             {
                 SetRootNode(VariableViewModel.Error(env.Name));
             }
             else
             {
                 SetRootModelAsync(env).DoNotWait();
             }
         }
     }
 }
Esempio n. 3
0
        private async Task SetRootModelAsync(REnvironment env)
        {
            await TaskUtilities.SwitchToBackgroundThread();

            const REvaluationResultProperties properties = ClassesProperty | ExpressionProperty | TypeNameProperty | DimProperty | LengthProperty;

            IRValueInfo result;

            try {
                result = await _session.EvaluateAndDescribeAsync(env.EnvironmentExpression, properties, null);
            } catch (RException ex) {
                VsAppShell.Current.DispatchOnUIThread(() => SetRootNode(VariableViewModel.Error(ex.Message)));
                return;
            }

            var wrapper       = new VariableViewModel(result, _aggregator);
            var rootNodeModel = new VariableNode(_settings, wrapper);

            VsAppShell.Current.DispatchOnUIThread(() => _rootNode.Model = rootNodeModel);
        }