/// <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. 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 = ToolWindowCommandUtils.AddToolWindow <LogsViewerToolWindow>(); newWindow.ViewModel.FilterLog(newFilter.ToString()); }
public void TestAddToolWindow() { var expectedResult = new ToolWindowPane { Frame = _defaultFrame }; PackageMock.Setup(p => p.FindToolWindow <ToolWindowPane>(false, 0)) .Returns(() => null); PackageMock.Setup(p => p.FindToolWindow <ToolWindowPane>(true, 0)) .Returns(() => expectedResult); var actualResult = ToolWindowCommandUtils.AddToolWindow <ToolWindowPane>(); Assert.AreEqual(expectedResult, actualResult); }
/// <summary> /// Initializes a new instance of the <see cref="LogsViewerToolWindowCommand"/> class. /// Adds our command handlers for menu (commands must exist in the command table file) /// </summary> /// <param name="package">Owner package, not null.</param> private LogsViewerToolWindowCommand(IGoogleCloudExtensionPackage package) { if (package == null) { throw new ArgumentNullException(nameof(package)); } _package = package; var commandService = ServiceProvider.GetService(typeof(IMenuCommandService)) as IMenuCommandService; if (commandService != null) { var menuItem = new OleMenuCommand( (sender, e) => ToolWindowCommandUtils.AddToolWindow <LogsViewerToolWindow>(), MenuCommandID); menuItem.BeforeQueryStatus += ToolWindowCommandUtils.EnableMenuItemOnValidProjectId; commandService.AddCommand(menuItem); } }
private void OnBrowseStackdriverLogCommand() { var window = ToolWindowCommandUtils.AddToolWindow <LogsViewerToolWindow>(); window?.FilterVMInstanceLog(Instance.Id.ToString()); }
private void OnBrowseStackdriverLogCommand() { var window = ToolWindowCommandUtils.AddToolWindow <LogsViewerToolWindow>(); window?.FilterGAEServiceLog(_service.Id, _version.Id); }