internal void SetEvaluation(VariableViewModel wrapper)
        {
            VsAppShell.Current.AssertIsOnMainThread();

            // Is the variable gone?
            if (wrapper.TypeName == null)
            {
                SetError(string.Format(CultureInfo.InvariantCulture, Package.Resources.VariableGrid_Missing, wrapper.Expression));
                _evaluation = null;
                return;
            }

            ClearError();

            // Does it have the same size and shape? If so, can update in-place (without losing scrolling etc).
            if (_evaluation?.Dimensions.SequenceEqual(wrapper.Dimensions) == true)
            {
                VariableGrid.Refresh();
                return;
            }

            // Otherwise, need to refresh the whole thing from scratch.
            VariableGrid.Initialize(new GridDataProvider(wrapper));
            _evaluation = wrapper;
        }
Exemple #2
0
        internal void SetEvaluation(IRSessionDataObject dataObject)
        {
            _services.MainThread().Assert();

            // Is the variable gone?
            if (dataObject.TypeName == null)
            {
                SetError(string.Format(CultureInfo.InvariantCulture, Package.Resources.VariableGrid_Missing, dataObject.Expression));
                _evaluation = null;
                return;
            }

            ClearError();

            // Does it have the same size and shape? If so, can update in-place (without losing scrolling etc).
            if (_evaluation?.Dimensions.SequenceEqual(dataObject.Dimensions) == true)
            {
                VariableGrid.Refresh();
                return;
            }

            // Otherwise, need to refresh the whole thing from scratch.
            var session = _services.GetService <IRInteractiveWorkflowProvider>().GetOrCreate().RSession;

            VariableGrid.Initialize(new GridDataProvider(session, dataObject));
            _evaluation = dataObject;
        }
        private void SubscribeAction(DebugEvaluationResult evaluation)
        {
            VsAppShell.Current.DispatchOnUIThread(
                () => {
                if (evaluation is DebugErrorEvaluationResult)
                {
                    // evaluation error, this could happen if R object is removed
                    var error = (DebugErrorEvaluationResult)evaluation;
                    SetError(error.ErrorText);
                    return;
                }

                var wrapper = new EvaluationWrapper(evaluation);

                if (wrapper.TypeName == "NULL" && wrapper.Value == "NULL")
                {
                    // the variable should have been removed
                    SetError(
                        string.Format(
                            CultureInfo.InvariantCulture,
                            Package.Resources.VariableGrid_Missing,
                            evaluation.Expression));
                }
                else if (wrapper.Dimensions.Count != 2)
                {
                    // the same evaluation changed to non-matrix
                    SetError(
                        string.Format(
                            CultureInfo.InvariantCulture,
                            Package.Resources.VariableGrid_NotTwoDimension,
                            evaluation.Expression));
                }
                else if (wrapper.Dimensions[0] != _evaluation.Dimensions[0] ||
                         wrapper.Dimensions[1] != _evaluation.Dimensions[1])
                {
                    ClearError();

                    // matrix size changed. Reset the evaluation
                    SetEvaluation(wrapper);
                }
                else
                {
                    ClearError();

                    // size stays same. Refresh
                    VariableGrid.Refresh();
                }
            });
        }
        internal void SetEvaluation(EvaluationWrapper wrapper)
        {
            if (wrapper.TypeName == "NULL" && wrapper.Value == "NULL")
            {
                // the variable should have been removed
                SetError(
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Package.Resources.VariableGrid_Missing,
                        wrapper.Expression));
            }
            else if (wrapper.Dimensions.Count != 2)
            {
                // the same evaluation changed to non-matrix
                SetError(
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Package.Resources.VariableGrid_NotTwoDimension,
                        wrapper.Expression));
            }
            else if (_evaluation == null ||
                     (wrapper.Dimensions[0] != _evaluation.Dimensions[0] || wrapper.Dimensions[1] != _evaluation.Dimensions[1]))
            {
                // matrix size changed. Reset the evaluation
                ClearError();

                VariableGrid.Initialize(new GridDataProvider(wrapper));

                _evaluation = wrapper;
            }
            else
            {
                ClearError();

                // size stays same. Refresh
                VariableGrid.Refresh();
            }
        }
        internal void SetEvaluation(VariableViewModel wrapper)
        {
            VsAppShell.Current.AssertIsOnMainThread();

            if (wrapper.TypeName == "NULL" && wrapper.Value == "NULL")
            {
                // the variable should have been removed
                SetError(string.Format(CultureInfo.InvariantCulture, Package.Resources.VariableGrid_Missing, wrapper.Expression));
            }
            else if (_evaluation == null ||
                     (wrapper.Dimensions.Count == 2 && (wrapper.Dimensions[0] != _evaluation.Dimensions[0] || wrapper.Dimensions[1] != _evaluation.Dimensions[1])))
            {
                // matrix size changed. Reset the evaluation
                ClearError();
                VariableGrid.Initialize(new GridDataProvider(wrapper));
                _evaluation = wrapper;
            }
            else
            {
                ClearError();
                // size stays same. Refresh
                VariableGrid.Refresh();
            }
        }