Пример #1
0
        public BuildDefinitionExplorerNode(IBuildDefinitionTreeNode node, char separator, ITFS tfs)
            : base(node.Path, node.Name)
        {
            TFS  = tfs;
            Node = node;
            if (_hiconLeaf == IntPtr.Zero && _hiconOpenFolder == IntPtr.Zero)
            {
                _hiconLeafAllBuildDef = ((Bitmap)BuildExplorerPlugin.Icons.Images[0]).GetHicon();
                _hiconLeaf            = ((Bitmap)BuildExplorerPlugin.Icons.Images[2]).GetHicon();
                _hiconOpenFolder      = ((Bitmap)BuildExplorerPlugin.Icons.Images[4]).GetHicon();
                _hiconCloseFolder     = ((Bitmap)BuildExplorerPlugin.Icons.Images[3]).GetHicon();
            }

            this.separator = separator;
            if (node.Children.Count == 0 /*&& node.Name!="All Build Definitions"*/)
            {
                InitAsLeaf();
            }
            else
            {
                InitAsFolder();
            }
            IsAllBuildDefinitionsNode = node.Name == "All Build Definitions";
            if (IsAllBuildDefinitionsNode)
            {
                NodePriority = AllBuildDefinitionsNodePriority;
            }
            IsDisabled = node.IsDisabled;
        }
 public static List <IBuildDefinitionTreeNode> ValidateAsRoot(this IBuildDefinitionTreeNode src, string name)
 {
     _currentRoot = src;
     _nodesCheked.Clear();
     Assert.IsTrue(src.IsRoot, "node is not root");
     Assert.AreEqual(src.Name, name, "Name mismatch");
     _nodesCheked.Add(src);
     return(new List <IBuildDefinitionTreeNode>(src.Children));
 }
Пример #3
0
 private void RecursiveBuildNodes(IBuildDefinitionTreeNode root, BaseHierarchyNode teNode, char sep)
 {
     //create nodes on this level and call recursive on children.
     foreach (var buildNode in root.Children.Select(node => new BuildDefinitionExplorerNode(node, sep, TFS)))
     {
         buildNode.AddChildren();
         teNode.AddChild(buildNode);
     }
     teNode.Expand(false);
 }
        public static IBuildDefinitionTreeNode VerifyAllChecked(this IBuildDefinitionTreeNode src)
        {
            Check(_currentRoot);
            VerifyAllChecked(_currentRoot.Children);

            Assert.IsTrue(_nodesCheked.Count == 0, "No check on the following nodes:"
                          + Environment.NewLine

                          + _nodesCheked.Aggregate("", (outString, nextNode) => outString + Environment.NewLine + PrintNode(nextNode)));
            return(_currentRoot);
        }
 internal void AddChild(IBuildDefinitionTreeNode child)
 {
     ((BuildDefinitionTreeNode)child).Parent = this;
     _children.Add(child);
 }
Пример #6
0
        /// <summary>
        /// Populate a IBuildDefinitionTreeNode with a new path.
        /// </summary>
        /// <param name="path">The path to to the build definition.</param>
        /// <param name="sep">The seperator</param>
        /// <param name="root">The root if not provided it will be created.</param>
        /// <param name="disabled">True if the build is marked as disabled</param>
        /// <returns>The root</returns>
        public static IBuildDefinitionTreeNode CreateOrMergeIntoTree(string path, char sep, IBuildDefinitionTreeNode root, bool disabled)
        {
            Contract.Requires(root != null);
            IBuildDefinitionTreeNode returnRoot = null;
            //path contains the parent.Name.
            var parent = root;

            //split to get parent, child and the rest if possible we want null results (StringSplitOptions.None) since that makes testing simpler.
            var parts = _splitStrategy.GenerateFoldersFromName(path, sep);


            //special case when only adding root.
            if (parts.Length == 1)
            {
                return(new BuildDefinitionRootNode(parts.Last(), sep));
            }

            //generate needed hierarchy.
            //ignore last part: is it allways treated as leaf.
            for (var i = 0; i < parts.Length - 1; i++)
            {
                var part = parts[i];
                //if root does not exists, use first part to generate root name.
                if (returnRoot == null)
                {
                    parent = root ?? new BuildDefinitionRootNode(part, sep);
                    //root
                    returnRoot = parent;
                }
                else
                {
                    //Find the existing child with the name if any.
                    var part1 = part;

                    //first node with same name and which is not a leaf node
                    //this will support
                    //Builds:
                    //    test.min
                    //    test
                    var folder = parent.Children.Where(c => Compare(part1, c.Name) && !c.IsLeafNode).FirstOrDefault();
                    if (folder == null)
                    {
                        folder = new BuildDefinitionFolderNode(part, sep);
                        ((BuildDefinitionTreeNode)parent).AddChild(folder);
                    }
                    parent = folder;
                }
            }

            //allways add last part as leaf node if not only root
            if (parts.Length > 1)
            {
                // Check to see if the last part is an existing  folder
                var part1  = parts.Last();
                var folder = parent.Children.Where(c => Compare(part1, c.Name)).FirstOrDefault();

                if (folder != null)  // // Check to see if the last part is an existing  folder
                {
                    parent = folder;
                    part1  = "$";
                }
                var leaf = new BuildDefinitionLeafNode(part1, sep, disabled);
                ((BuildDefinitionTreeNode)parent).AddChild(leaf);
            }

            return(returnRoot);
        }
Пример #7
0
 public static IBuildDefinitionTreeNode CreateOrMergeIntoTree(string path, char sep, IBuildDefinitionTreeNode root)
 {
     return(CreateOrMergeIntoTree(path, sep, root, false));
 }
 private static string PrintNode(IBuildDefinitionTreeNode node)
 {
     return("Unchecked node " + node.Name + ", isLeaf = " + node.IsLeafNode + ", IsDisabled " + node.IsDisabled + ", Path = " + node.Path);
 }
 private static void Check(IBuildDefinitionTreeNode node)
 {
     Assert.IsTrue(_nodesCheked.Contains(node), PrintNode(node));
     _nodesCheked.Remove(node);
 }
Пример #10
0
 public BuildDefinitionExplorerNode(IBuildDefinitionTreeNode node, char separator, bool isFolderNode, ITFS tfs)
     : this(node, separator, tfs)
 {
     this.isFolderNode = isFolderNode;
 }