Exemple #1
0
        private void Initalize(IRValueInfo valueInfo)
        {
            Value    = GetValue(valueInfo)?.Trim();
            TypeName = valueInfo.TypeName;

            if (valueInfo.Classes != null)
            {
                var escaped = valueInfo.Classes.Select((x) => x.IndexOf(' ') >= 0 ? "'" + x + "'" : x);
                Class = string.Join(", ", escaped); // TODO: escape ',' in class names
            }

            HasChildren = valueInfo.HasChildren;

            if (valueInfo.Dim != null)
            {
                Dimensions = valueInfo.Dim;
            }
            else if (valueInfo.Length.HasValue)
            {
                Dimensions = new List <long>()
                {
                    valueInfo.Length.Value, 1
                };
            }
            else
            {
                Dimensions = new List <long>();
            }
        }
Exemple #2
0
        public override bool CanView(IRValueInfo value)
        {
            // We can only view collections that have elements.
            var length = value?.Length ?? 0;

            if (length == 0)
            {
                return(false);
            }

            // We can only view atomic vectors or lists.
            // Note that data.frame is always a list, and matrix and array can be either vector or list.
            if (!value.IsAtomic() && value.TypeName != "list")
            {
                return(false);
            }

            // We can only view dimensionless (treated as 1D), 1D, or 2D collections.
            // For 1D collections, only view if there's more than one element (for 2D, we still want
            // to enable grid in that case to expose row & column names).
            var dimCount = value.Dim?.Count ?? 1;

            if (dimCount > 2 || (dimCount == 1 && length == 1))
            {
                return(false);
            }

            return(true);
        }
Exemple #3
0
 public override bool CanView(IRValueInfo evaluation)
 {
     if (evaluation != null && evaluation.Classes.Any(t => _tableClasses.Contains(t)))
     {
         return(evaluation.Dim != null && evaluation.Dim.Count == 2);
     }
     return(false);
 }
Exemple #4
0
        internal RActiveBindingInfo(IRSession session, string environmentExpression, string expression, string name, JObject json)
            : this(session, environmentExpression, expression, name, (IRValueInfo)null) {

            JObject bindingResultJson = json.Value<JObject>(FieldNames.ComputedValue);
            if (bindingResultJson != null) {
                ComputedValue = new RValueInfo(session, environmentExpression, expression, name, bindingResultJson);
            }
        }
Exemple #5
0
 public override bool CanView(IRValueInfo evaluation)
 {
     if (evaluation != null && evaluation.Classes.Any(t => _classes.Contains(t)))
     {
         return(evaluation.Length.HasValue && evaluation.Length > 1 && (evaluation.Dim == null || evaluation.Dim.Count == 1));
     }
     return(false);
 }
Exemple #6
0
 public override bool CanView(IRValueInfo evaluation)
 {
     if (evaluation != null && !evaluation.Classes.Any(t => _excludedClasses.Contains(t)))
     {
         return(evaluation.Dim == null && evaluation.Length > 1);
     }
     return(false);
 }
Exemple #7
0
        internal RActiveBindingInfo(IRSession session, string environmentExpression, string expression, string name, JObject json)
            : this(session, environmentExpression, expression, name, (IRValueInfo)null)
        {
            JObject bindingResultJson = json.Value <JObject>(FieldNames.ComputedValue);

            if (bindingResultJson != null)
            {
                ComputedValue = new RValueInfo(session, environmentExpression, expression, name, bindingResultJson);
            }
        }
Exemple #8
0
        private string GetValue(IRValueInfo v)
        {
            var value = v.Representation;

            if (value != null)
            {
                var match = Regex.Match(value, DataFramePrefix);
                if (match.Success)
                {
                    return(match.Groups[1].Value.Trim());
                }
            }
            return(value?.ConvertCharacterCodes());
        }
        internal RActiveBindingInfo(IRSession session, string environmentExpression, string expression, string name, JObject json)
            : base(session, environmentExpression, expression, name)
        {
            JObject bindingResultJson = json.Value <JObject>("computed_value");

            if (bindingResultJson == null)
            {
                ComputedValue = null;
            }
            else
            {
                ComputedValue = new RValueInfo(session, environmentExpression, expression, name, bindingResultJson);
            }
        }
Exemple #10
0
        private void SetViewButtonStatus(IRValueInfo result) {
            _detailsViewer = _aggregator.GetViewer(result);
            _title = result.Name;

            CanShowDetail = _detailsViewer != null;
            if (CanShowDetail) {
                ShowDetailCommand = new DelegateCommand(o => _detailsViewer.ViewAsync(result.Expression, _title).DoNotWait(), o => CanShowDetail);
                ShowDetailCommandTooltip = Resources.ShowDetailCommandTooltip;
            }

            CanShowOpenCsv = result.CanCoerceToDataFrame && (result.Length > 1 || result.TypeName == "S4");
            if (CanShowOpenCsv) {
                OpenInCsvAppCommand = new DelegateCommand(OpenInCsvApp, o => CanShowOpenCsv);
                OpenInCsvAppCommandTooltip = Resources.OpenCsvAppCommandTooltip;
            }
        }
Exemple #11
0
        private void Initalize(IRValueInfo valueInfo) {
            Value = GetValue(valueInfo)?.Trim();
            TypeName = valueInfo.TypeName;

            if (valueInfo.Classes != null) {
                var escaped = valueInfo.Classes.Select((x) => x.IndexOf(' ') >= 0 ? "'" + x + "'" : x);
                Class = string.Join(", ", escaped); // TODO: escape ',' in class names
            }

            HasChildren = valueInfo.HasChildren;

            if (valueInfo.Dim != null) {
                Dimensions = valueInfo.Dim;
            } else if (valueInfo.Length.HasValue) {
                Dimensions = new List<int>() { valueInfo.Length.Value, 1 };
            } else {
                Dimensions = new List<int>();
            }
        }
Exemple #12
0
        private void SetViewButtonStatus(IRValueInfo result)
        {
            _detailsViewer = _aggregator.GetViewer(result);
            _title         = result.Name;

            CanShowDetail = _detailsViewer != null;
            if (CanShowDetail)
            {
                ShowDetailCommand        = new DelegateCommand(o => _detailsViewer.ViewAsync(result.Expression, _title).DoNotWait(), o => CanShowDetail);
                ShowDetailCommandTooltip = Resources.ShowDetailCommandTooltip;
            }

            CanShowOpenCsv = result.CanCoerceToDataFrame && (result.Length > 1 || result.TypeName == "S4");
            if (CanShowOpenCsv)
            {
                OpenInCsvAppCommand        = new DelegateCommand(OpenInCsvApp, o => CanShowOpenCsv);
                OpenInCsvAppCommandTooltip = Resources.OpenCsvAppCommandTooltip;
            }
        }
Exemple #13
0
        private void SetViewButtonStatus(IRValueInfo result)
        {
            _detailsViewer = _aggregator.GetViewer(result);
            _title         = result.Name;

            CanShowDetail = _detailsViewer != null;
            if (CanShowDetail)
            {
                ShowDetailCommand        = new DelegateCommand(o => _detailsViewer.ViewAsync(result.Expression, _title).DoNotWait(), o => CanShowDetail);
                ShowDetailCommandTooltip = Resources.ShowDetailCommandTooltip;
            }

            var tableCaps = (ViewerCapabilities.Table | ViewerCapabilities.List);

            CanShowOpenCsv = CanShowDetail && (_detailsViewer.Capabilities & tableCaps) != 0 && result.Length > 0;
            if (CanShowOpenCsv)
            {
                OpenInCsvAppCommand        = new DelegateCommand(OpenInCsvApp, o => CanShowOpenCsv);
                OpenInCsvAppCommandTooltip = Resources.OpenCsvAppCommandTooltip;
            }
        }
Exemple #14
0
        public override bool CanView(IRValueInfo value)
        {
            // We can only view collections that have elements.
            var length = value?.Length ?? 0;

            if (length == 0)
            {
                return(false);
            }

            // We can only view atomic vectors or lists.
            // Note that data.frame is always a list, and matrix and array can be either vector or list.
            if (!value.IsAtomic() && value.TypeName != "list")
            {
                return(false);
            }

            // We can only view dimensionless (treated as 1D), 1D, or 2D collections.
            // For 1D collections, only view if there's more than one element (for 2D, we still want
            // to enable grid in that case to expose row & column names).
            var dimCount = value.Dim?.Count ?? 1;

            if (dimCount > 2 || (dimCount == 1 && length == 1))
            {
                return(false);
            }

            // Grid viewer allocates arrays of doubles of the size of each dimension, to precompute cell coordinates.
            // If a given dimension is too large, the corresponding array can easily OOM on allocation. So, restrict
            // dimensions to reasonable sizes.
            foreach (var dim in value.Dim ?? new[] { length })
            {
                if (dim > MaxDim)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #15
0
        public IObjectDetailsViewer GetViewer(IRValueInfo result)
        {
            Lazy <IObjectDetailsViewer> lazyViewer = Viewers.FirstOrDefault(x => x.Value.CanView(result));

            return(lazyViewer?.Value);
        }
Exemple #16
0
 private string GetValue(IRValueInfo v) {
     var value = v.Representation;
     if (value != null) {
         Match match = Regex.Match(value, DataFramePrefix);
         if (match.Success) {
             return match.Groups[1].Value.Trim();
         }
     }
     return value != null ? value.ConvertCharacterCodes() : value;
 }
Exemple #17
0
 public override bool CanView(IRValueInfo evaluation) {
     if (evaluation != null && !evaluation.Classes.Any(t => _excludedClasses.Contains(t))) {
         return evaluation.Dim == null && evaluation.Length > 1;
     }
     return false;
 }
Exemple #18
0
 abstract public bool CanView(IRValueInfo evaluation);
Exemple #19
0
 public override bool CanView(IRValueInfo evaluation) {
     if (evaluation != null && evaluation.Classes.Any(t => _tableClasses.Contains(t))) {
         return evaluation.Dim != null && evaluation.Dim.Count == 2;
     }
     return false;
 }
Exemple #20
0
 public override bool CanView(IRValueInfo evaluation)
 {
     return(evaluation != null && evaluation.Classes.Any(t => _classes.Contains(t)));
 }
Exemple #21
0
 internal RActiveBindingInfo(IRSession session, string environmentExpression, string expression, string name, IRValueInfo computedValue)
     : base(session, environmentExpression, expression, name)
 {
     ComputedValue = computedValue;
 }
 public IObjectDetailsViewer GetViewer(IRValueInfo result) {
     Lazy<IObjectDetailsViewer> lazyViewer = Viewers.FirstOrDefault(x => x.Value.CanView(result));
     return lazyViewer?.Value;
 }
Exemple #23
0
 public IObjectDetailsViewer GetViewer(IRValueInfo result)
 {
     return(Viewers.Select(viewer => viewer.Value).FirstOrDefault(viewer => viewer.CanView(result)));
 }
Exemple #24
0
 /// <seealso cref="RValueFlags.Atomic"/>
 public static bool IsAtomic(this IRValueInfo info) =>
 info.Flags.HasFlag(RValueFlags.Atomic);
Exemple #25
0
 /// <summary>
 /// Whether this value has any attributes.
 /// </summary>
 public static bool HasAttributes(this IRValueInfo info) =>
 info.AttributeCount != null && info.AttributeCount != 0;
Exemple #26
0
 public override bool CanView(IRValueInfo evaluation) {
     return evaluation != null && evaluation.Classes.Any(t => _classes.Contains(t));
 }
Exemple #27
0
 internal RActiveBindingInfo(IRExpressionEvaluator evaluator, string environmentExpression, string expression, string name, IRValueInfo computedValue)
     : base(evaluator, environmentExpression, expression, name)
 {
     ComputedValue = computedValue;
 }
Exemple #28
0
 public abstract bool CanView(IRValueInfo evaluation);
Exemple #29
0
 public bool CanView(IRValueInfo evaluation) {
     return _types.Contains(evaluation?.TypeName);
 }
Exemple #30
0
 public override bool CanView(IRValueInfo evaluation) {
     if (evaluation != null && evaluation.Classes.Any(t => _classes.Contains(t))) {
         return evaluation.Length.HasValue && evaluation.Length > 1 && (evaluation.Dim == null || evaluation.Dim.Count == 1);
     }
     return false;
 }
Exemple #31
0
 /// <seealso cref="RValueFlags.Recursive"/>
 public static bool IsRecursive(this IRValueInfo info) =>
 info.Flags.HasFlag(RValueFlags.Recursive);
Exemple #32
0
 public bool CanView(IRValueInfo evaluation) {
     return _types.Contains(evaluation?.TypeName);
 }
Exemple #33
0
 /// <summary>
 /// Whether this value has any slots.
 /// </summary>
 public static bool HasSlots(this IRValueInfo info) =>
 info.SlotCount != null && info.SlotCount != 0;
Exemple #34
0
        internal RActiveBindingInfo(IRSession session, string environmentExpression, string expression, string name, IRValueInfo computedValue)
            : base(session, environmentExpression, expression, name) {

            ComputedValue = computedValue;
        }