Skip to content

Commit

Permalink
Merge pull request #27 from gene-pavlovsky/hide_no_description_targets
Browse files Browse the repository at this point in the history
PluginUI.cs: optionally hide targets without a description.
  • Loading branch information
SlavaRa committed Apr 13, 2016
2 parents 10b9c64 + 78cbc3b commit f376e97
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
21 changes: 20 additions & 1 deletion AntPanel/PluginUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions AntPanel/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}

0 comments on commit f376e97

Please sign in to comment.