Exemplo n.º 1
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;
        }
Exemplo n.º 2
0
 internal void SetViewModel(IRSessionDataObject dataObject, string caption)
 {
     if (!string.IsNullOrWhiteSpace(dataObject.Expression))
     {
         Caption = Invariant($"{Resources.VariableGrid_Caption}: {caption}");
     }
     _gridHost.SetEvaluation(dataObject);
 }
Exemplo n.º 3
0
 public static void AssertEvaluationWrapper_ValueStartWith(IRSessionDataObject rdo, VariableExpectation expectation) {
     var v = (VariableViewModel)rdo;
     v.Name.ShouldBeEquivalentTo(expectation.Name);
     v.Value.Should().StartWith(expectation.Value);
     v.Class.ShouldBeEquivalentTo(expectation.Class);
     v.TypeName.ShouldBeEquivalentTo(expectation.TypeName);
     v.HasChildren.ShouldBeEquivalentTo(expectation.HasChildren);
 }
Exemplo n.º 4
0
        public static void AssertEvaluationWrapper_ValueStartWith(IRSessionDataObject rdo, VariableExpectation expectation)
        {
            var v = (VariableViewModel)rdo;

            v.Name.ShouldBeEquivalentTo(expectation.Name);
            v.Value.Should().StartWith(expectation.Value);
            v.Class.ShouldBeEquivalentTo(expectation.Class);
            v.TypeName.ShouldBeEquivalentTo(expectation.TypeName);
            v.HasChildren.ShouldBeEquivalentTo(expectation.HasChildren);
        }
Exemplo n.º 5
0
 public VariableInfo(IRSessionDataObject e)
 {
     this.Name = e.Name;
     if (e.TypeName == "closure")
     {
         ItemType = NamedItemType.Function;
     }
     else
     {
         ItemType = NamedItemType.Variable;
     }
 }
Exemplo n.º 6
0
 private void DeleteCachedVariable()
 {
     if (_evaluation != null && _evaluation.Expression.StartsWithOrdinal(ViewEnvName))
     {
         if (_rSession.IsHostRunning)
         {
             var varName = _evaluation.Expression.Substring(ViewEnvName.Length + 1);
             try {
                 _rSession.ExecuteAsync(Invariant($"rm('{varName}', envir = {ViewEnvName})")).DoNotWait();
             } catch (Exception ex) when(!ex.IsCriticalException())
             {
             }
         }
     }
     _evaluation = null;
 }
Exemplo n.º 7
0
        public GridDataProvider(IRSession session, IRSessionDataObject dataObject)
        {
            _dataObject = dataObject;
            _dataSource = new GridDataSource(session);

            RowCount    = dataObject.Dimensions[0];
            ColumnCount = dataObject.Dimensions.Count >= 2 ? dataObject.Dimensions[1] : 1;
            CanSort     = true;

            // Lists cannot be sorted, except when the list is a dataframe.
            if (dataObject.TypeName == "list")
            {
                var er = dataObject.DebugEvaluation as IRValueInfo;
                CanSort = er?.Classes.Contains("data.frame") == true;
            }
        }
Exemplo n.º 8
0
 public VariableInfo(IRSessionDataObject e) :
     this(e.Name, e.TypeName)
 {
 }
Exemplo n.º 9
0
 public static void AssertEvaluationWrapper(IRSessionDataObject rdo, VariableExpectation expectation) {
     var v = (EvaluationWrapper)rdo;
     v.ShouldBeEquivalentTo(expectation, o => o.ExcludingMissingMembers());
 }
Exemplo n.º 10
0
        public static void AssertEvaluationWrapper(IRSessionDataObject rdo, VariableExpectation expectation)
        {
            var v = (VariableViewModel)rdo;

            v.ShouldBeEquivalentTo(expectation, o => o.ExcludingMissingMembers());
        }
Exemplo n.º 11
0
 public VariableInfo(IRSessionDataObject e) :
     this(e.Name, e.TypeName) { }
 public VariableInfo(IRSessionDataObject e) {
     this.Name = e.Name;
     if (e.TypeName == "closure") {
         ItemType = NamedItemType.Function;
     } else {
         ItemType = NamedItemType.Variable;
     }
 }