From 78cbc3bb396e429bc6e903d132759d87d30d8a2c Mon Sep 17 00:00:00 2001 From: Gene Pavlovsky Date: Fri, 8 Apr 2016 00:16:19 +0300 Subject: [PATCH] PluginUI.cs: optionally hide targets without a description. Settings.cs: added the SkipHiddenTargets option to control this behavior. Note: with this option turned on, the panel shows the same target as listed by running `ant -projecthelp`. --- AntPanel/PluginUI.cs | 21 ++++++++++++++++++++- AntPanel/Settings.cs | 4 ++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/AntPanel/PluginUI.cs b/AntPanel/PluginUI.cs index 7bd3452..6149eb4 100644 --- a/AntPanel/PluginUI.cs +++ b/AntPanel/PluginUI.cs @@ -218,16 +218,35 @@ AntTreeNode GetBuildFileNode(string file) Target = defaultTarget, ToolTipText = description }; + bool skipHiddenTargets = ((Settings)pluginMain.Settings).SkipHiddenTargets; + if (skipHiddenTargets) + { + // no-description targets should be hidden only if at least one target has a description + skipHiddenTargets = false; + foreach (XmlNode node in documentElement.ChildNodes) + { + if (node.Name != "target") continue; + XmlAttributeCollection attributes = node.Attributes; + Debug.Assert(attributes != null, "attributes != null"); + if (!string.IsNullOrEmpty(attributes["description"]?.InnerText)) + { + skipHiddenTargets = true; + break; + } + } + } foreach (XmlNode node in documentElement.ChildNodes) { if (node.Name != "target") continue; - // skip private targets + // skip private and optionally hidden targets XmlAttributeCollection attributes = node.Attributes; Debug.Assert(attributes != null, "attributes != null"); XmlAttribute targetNameAttr = attributes["name"]; string targetName = targetNameAttr?.InnerText; if (!string.IsNullOrEmpty(targetName) && (targetName[0] == '-')) continue; + if (skipHiddenTargets && string.IsNullOrEmpty(attributes["description"]?.InnerText)) + continue; AntTreeNode targetNode = GetBuildTargetNode(node, defaultTarget); targetNode.File = file; rootNode.Nodes.Add(targetNode); diff --git a/AntPanel/Settings.cs b/AntPanel/Settings.cs index fb1ffb4..aff1957 100644 --- a/AntPanel/Settings.cs +++ b/AntPanel/Settings.cs @@ -13,5 +13,9 @@ public class Settings [DefaultValue("")] [Editor(typeof(FolderNameEditor), typeof(UITypeEditor))] public string AntPath { get; set; } + + [DisplayName("Hide no-description targets"), DefaultValue(false)] + [Description("Hide targets that don't have a description (unless all of the targets don't have one)")] + public Boolean SkipHiddenTargets { get; set; } } } \ No newline at end of file