Exemplo n.º 1
0
        AntTreeNode GetBuildTargetNode(XmlNode node, string defaultTarget)
        {
            var attributes = node.Attributes;

            Debug.Assert(attributes != null, "attributes != null");
            var         targetName  = attributes["name"]?.InnerText ?? string.Empty;
            var         description = attributes["description"]?.InnerText ?? string.Empty;
            AntTreeNode result;

            if (targetName == defaultTarget)
            {
                result = new AntTreeNode(targetName, IconPublicTarget)
                {
                    NodeFont = new Font(tree.Font.Name, tree.Font.Size, FontStyle.Bold)
                };
            }
            else if (!string.IsNullOrEmpty(description))
            {
                result = new AntTreeNode(targetName, IconPublicTarget);
            }
            else
            {
                result = new AntTreeNode(targetName, IconInternalTarget);
            }
            result.Target      = targetName;
            result.ToolTipText = description;
            return(result);
        }
Exemplo n.º 2
0
        AntTreeNode GetBuildFileNode(string file)
        {
            var xml = new XmlDocument();

            xml.Load(file);
            var documentElement = xml.DocumentElement;

            Debug.Assert(documentElement != null, "documentElement != null");
            var defaultTarget = documentElement.Attributes["default"]?.InnerText ?? "";
            var projectName   = documentElement.Attributes["name"]?.InnerText ?? file;
            var description   = documentElement.Attributes["description"]?.InnerText ?? "";

            if (string.IsNullOrEmpty(projectName))
            {
                projectName = file;
            }
            var rootNode = new AntTreeNode(projectName, IconFile)
            {
                File        = file,
                Target      = defaultTarget,
                ToolTipText = description
            };
            var 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;
                    }
                    var attributes = node.Attributes;
                    Debug.Assert(attributes != null, "attributes != null");
                    if (string.IsNullOrEmpty(attributes["description"]?.InnerText))
                    {
                        continue;
                    }
                    skipHiddenTargets = true;
                    break;
                }
            }
            foreach (XmlNode node in documentElement.ChildNodes)
            {
                if (node.Name != "target")
                {
                    continue;
                }
                // skip private and optionally hidden targets
                var attributes = node.Attributes;
                Debug.Assert(attributes != null, "attributes != null");
                var targetName = attributes["name"]?.InnerText;
                if (!string.IsNullOrEmpty(targetName) && (targetName[0] == '-'))
                {
                    continue;
                }
                if (skipHiddenTargets && string.IsNullOrEmpty(attributes["description"]?.InnerText))
                {
                    continue;
                }
                var targetNode = GetBuildTargetNode(node, defaultTarget);
                targetNode.File = file;
                rootNode.Nodes.Add(targetNode);
            }
            rootNode.Expand();
            return(rootNode);
        }