/// <summary> /// Detail view is a tree view. /// Each item at tree path is an <seealso cref="ObjectNodeTree"/> object. /// The tree view displays the <paramref name="node"/> as name : value pair. /// User can click at the "value" to show matching log entries. /// /// This method composes a filter on node value, adds it to existing AdvancedFilterText. /// The filter has format of root_node_name.node_name...node_name = "node.value". /// Example: jsonPayload.serviceContext.service="frontend" /// </summary> private void FilterOnTreeNodeValue(ObjectNodeTree node) { IsAutoReloadChecked = false; // Firstly compose a new filter line. StringBuilder newFilter = new StringBuilder(); newFilter.Append($"{node.FilterLabel}=\"{node.FilterValue}\""); while ((node = node.Parent).Parent != null) { if (!string.IsNullOrWhiteSpace(node.FilterLabel)) { newFilter.Insert(0, $"{node.FilterLabel}."); } } // Append the new filter line to existing filter text. // Or to the composed filter if it is currently showing simple filters. if (ShowAdvancedFilter) { newFilter.Insert(0, Environment.NewLine); newFilter.Insert(0, AdvancedFilterText); } else { newFilter.Insert(0, ComposeSimpleFilters()); } // Show advanced filter. AdvancedFilterText = newFilter.ToString(); ShowAdvancedFilter = true; ErrorHandlerUtils.HandleAsyncExceptions(ReloadAsync); }
/// <summary> /// Detail view is a tree view. /// Each item at tree path is an <seealso cref="ObjectNodeTree"/> object. /// The tree view displays the <paramref name="node"/> as name : value pair. /// User can click at the "value" to show matching log entries. /// /// This method composes a filter on node value, adds it to existing AdvancedFilterText. /// The filter has format of root_node_name.node_name...node_name = "node.value". /// Example: jsonPayload.serviceContext.service="frontend" /// </summary> private async Task FilterOnTreeNodeValueAsync(ObjectNodeTree node) { IsAutoReloadChecked = false; // Firstly compose a new filter line. var newFilter = new StringBuilder(); newFilter.Append($"{node.FilterLabel}=\"{node.FilterValue}\""); while ((node = node.Parent)?.Parent != null) { if (!string.IsNullOrWhiteSpace(node.FilterLabel)) { newFilter.Insert(0, $"{node.FilterLabel}."); } } // Append the new filter line to existing filter text. // Or to the composed filter if it is currently showing simple filters. if (ShowAdvancedFilter) { newFilter.Insert(0, Environment.NewLine); newFilter.Insert(0, AdvancedFilterText); } else { newFilter.Insert(0, ComposeSimpleFilters()); } var newWindow = await ToolWindowCommandUtils.AddToolWindowAsync <LogsViewerToolWindow>(); newWindow.ViewModel.FilterLog(newFilter.ToString()); }
/// <summary> /// Create an instance of the <seealso cref="ObjectNodeTree"/> class. /// </summary> /// <param name="name">object name</param> /// <param name="obj">An object</param> /// <param name="parent">The parent <seealso cref="ObjectNodeTree"/> object.</param> public ObjectNodeTree(string name, object obj, ObjectNodeTree parent) { Parent = parent; _name = name; if (obj == null) { return; } ParseObjectTree(obj); }
/// <summary> /// Create an instance of the <seealso cref="ObjectNodeTree"/> class. /// </summary> /// <param name="name">object name</param> /// <param name="obj">An object</param> /// <param name="parent">The parent <seealso cref="ObjectNodeTree"/> object.</param> public ObjectNodeTree(string name, object obj, ObjectNodeTree parent) { Parent = parent; _name = name; if (obj == null) { return; } ParseObjectTree(obj); CopyCommand = new ProtectedCommand(() => Clipboard.SetText(NodeValue ?? JsonConvert.SerializeObject(obj))); }
/// <summary> /// Adds an object as leaf node. /// </summary> protected ObjectNodeTree AddChildren(string name, object obj) { ObjectNodeTree newNode = null; if (obj != null) { if (obj is JObject) { newNode = new JObjectNode(name, obj as JObject, this); } else if (obj is JArray) { newNode = new JArrayNode(name, obj as JArray, this); } else { newNode = new ObjectNodeTree(name, obj, this); } Children.Add(newNode); } return(newNode); }
/// <summary> /// Initializes a new instance of <seealso cref="JArrayNode"/> class. /// </summary> /// <param name="name">The name to display for this <paramref name="jArrayObj"/>.</param> /// <param name="jArrayObj">A <seealso cref="JArray"/> object to parse.</param> /// <param name="parent">The parent object that owns <paramref name="jArrayObj"/>. </param> public JArrayNode(string name, JArray jArrayObj, ObjectNodeTree parent) : base(name, jArrayObj, parent) { }
/// <summary> /// Create a new instance of <seealso cref="JObjectNode"/> class. /// </summary> /// <param name="name">The name to display for this object.</param> /// <param name="jObj">A <seealso cref="JObjectNode"/> object to parse.</param> /// <param name="parent">The parent object that owns <paramref name="jObj"/>.</param> public JObjectNode(string name, JObject jObj, ObjectNodeTree parent) : base(name, jObj, parent) { }