private void RemoveUnusedModuleNodesFromHierarchy(HierarchyNode parent, List <HierarchyNode> remove)
 {
     foreach (var obsolete in remove)
     {
         parent.RemoveChild(obsolete);
         ProjectMgr.OnItemDeleted(obsolete);
     }
 }
示例#2
0
 internal static void RemoveNonMemberItems(HierarchyNode project)
 {
     IList<HierarchyNode> nodeList = new List<HierarchyNode>();
     HierarchyHelpers.FindNodes(nodeList, project, IsNodeNonMemberItem, null);
     for (int index = nodeList.Count - 1; index >= 0; index--)
     {
         HierarchyNode parent = nodeList[index].Parent;
         nodeList[index].OnItemDeleted();
         parent.RemoveChild(nodeList[index]);
     }
 }
示例#3
0
 private static HierarchyNode ReplaceCore(RustProjectNode root, HierarchyNode old, Func<HierarchyNode> newN, HierarchyNode parent)
 {
     HierarchyNode newNode = newN();
     while (old.FirstChild != null)
     {
         HierarchyNode current = old.FirstChild;
         root.ProjectMgr.OnItemDeleted(current);
         old.RemoveChild(current);
         current.ID = root.ProjectMgr.ItemIdMap.Add(current);
         newNode.AddChild(current);
     }
     TreeOperations.RemoveSubnodeFromHierarchy(root, old, false);
     parent.AddChild(newNode);
     return newNode;
 }
        internal static void RemoveNonMemberItems(XProjectNode project)
        {
            IList <HierarchyNode> nodeList = new List <HierarchyNode>();

            XHelperMethods.FindNodes(nodeList, project, XProjectMembers.IsNodeNonMemberItem, null);
            ThreadHelper.ThrowIfNotOnUIThread();
            for (int index = nodeList.Count - 1; index >= 0; index--)
            {
                HierarchyNode node   = nodeList[index];
                HierarchyNode parent = node.Parent;

                node.OnItemDeleted();
                parent.RemoveChild(node);
            }
        }
示例#5
0
        private static HierarchyNode ReplaceCore(RustProjectNode root, HierarchyNode old, Func <HierarchyNode> newN, HierarchyNode parent)
        {
            HierarchyNode newNode = newN();

            while (old.FirstChild != null)
            {
                HierarchyNode current = old.FirstChild;
                root.ProjectMgr.OnItemDeleted(current);
                old.RemoveChild(current);
                current.ID = root.ProjectMgr.ItemIdMap.Add(current);
                newNode.AddChild(current);
            }
            TreeOperations.RemoveSubnodeFromHierarchy(root, old, false);
            parent.AddChild(newNode);
            return(newNode);
        }
            private void RemoveAllFilesChildren(HierarchyNode parent)
            {
                for (var current = parent.FirstChild; current != null; current = current.NextSibling)
                {
                    // remove our children first
                    this.RemoveAllFilesChildren(current);

                    this.project.TryDeactivateSymLinkWatcher(current);

                    // then remove us if we're an all files node
                    if (current.ItemNode is AllFilesProjectElement)
                    {
                        this.project.OnItemDeleted(current);
                        parent.RemoveChild(current);
                    }
                }
            }
示例#7
0
 private void RemoveUnusedModuleNodesFromHierarchy(HierarchyNode parent, List<HierarchyNode> remove)
 {
     foreach (var obsolete in remove) {
         parent.RemoveChild(obsolete);
         ProjectMgr.OnItemDeleted(obsolete);
     }
 }
示例#8
0
            private void RemoveAllFilesChildren(HierarchyNode parent) {
                bool removed = false;

                for (var current = parent.FirstChild; current != null; current = current.NextSibling) {
                    // remove our children first
                    RemoveAllFilesChildren(current);

                    _project.TryDeactivateSymLinkWatcher(current);

                    // then remove us if we're an all files node
                    if (current.ItemNode is AllFilesProjectElement) {
                        parent.RemoveChild(current);
                        _project.OnItemDeleted(current);
                        removed = true;
                    }
                }

                if (removed) {
                    _project.OnInvalidateItems(parent);
                }
            }
示例#9
0
        protected void ReloadHierarchy(HierarchyNode parent, IEnumerable <IPackage> modules)
        {
            //  We're going to reuse nodes for which matching modules exist in the new set.
            //  The reason for this is that we want to preserve the expansion state of the
            //  hierarchy. If we just bin everything off and recreate it all from scratch
            //  it'll all be in the collapsed state, which will be annoying for users who
            //  have drilled down into the hierarchy
            var recycle = new Dictionary <string, DependencyNode>();
            var remove  = new List <HierarchyNode>();

            for (var current = parent.FirstChild; null != current; current = current.NextSibling)
            {
                var dep = current as DependencyNode;
                if (null == dep)
                {
                    if (!(current is GlobalModulesNode) && !(current is LocalModulesNode))
                    {
                        remove.Add(current);
                    }
                    continue;
                }

                if (modules != null && modules.Any(
                        module =>
                        module.Name == dep.Package.Name &&
                        module.Version == dep.Package.Version &&
                        module.IsBundledDependency == dep.Package.IsBundledDependency &&
                        module.IsDevDependency == dep.Package.IsDevDependency &&
                        module.IsListedInParentPackageJson == dep.Package.IsListedInParentPackageJson &&
                        module.IsMissing == dep.Package.IsMissing &&
                        module.IsOptionalDependency == dep.Package.IsOptionalDependency))
                {
                    recycle[dep.Package.Name] = dep;
                }
                else
                {
                    remove.Add(current);
                }
            }

            foreach (var obsolete in remove)
            {
                parent.RemoveChild(obsolete);
                ProjectMgr.OnItemDeleted(obsolete);
            }

            if (modules != null)
            {
                foreach (var package in modules)
                {
                    DependencyNode child;

                    if (recycle.ContainsKey(package.Name))
                    {
                        child         = recycle[package.Name];
                        child.Package = package;
                    }
                    else
                    {
                        child = new DependencyNode(_projectNode, parent as DependencyNode, package);
                        parent.AddChild(child);
                    }

                    ReloadHierarchy(child, package.Modules);
                    if (ProjectMgr.ParentHierarchy != null)
                    {
                        child.ExpandItem(EXPANDFLAGS.EXPF_CollapseFolder);
                    }
                }
            }
        }
示例#10
0
        protected void ReloadHierarchy(HierarchyNode parent, IEnumerable<IPackage> modules) {
            //  We're going to reuse nodes for which matching modules exist in the new set.
            //  The reason for this is that we want to preserve the expansion state of the
            //  hierarchy. If we just bin everything off and recreate it all from scratch
            //  it'll all be in the collapsed state, which will be annoying for users who
            //  have drilled down into the hierarchy
            var recycle = new Dictionary<string, DependencyNode>();
            var remove = new List<HierarchyNode>();
            for (var current = parent.FirstChild; null != current; current = current.NextSibling) {
                var dep = current as DependencyNode;
                if (null == dep) {
                    if (!(current is GlobalModulesNode) && !(current is LocalModulesNode)) {
                        remove.Add(current);
                    }
                    continue;
                }

                if (modules != null && modules.Any(
                    module =>
                        module.Name == dep.Package.Name
                        && module.Version == dep.Package.Version
                        && module.IsBundledDependency == dep.Package.IsBundledDependency
                        && module.IsDevDependency == dep.Package.IsDevDependency
                        && module.IsListedInParentPackageJson == dep.Package.IsListedInParentPackageJson
                        && module.IsMissing == dep.Package.IsMissing
                        && module.IsOptionalDependency == dep.Package.IsOptionalDependency)) {
                    recycle[dep.Package.Name] = dep;
                } else {
                    remove.Add(current);
                }
            }

            foreach (var obsolete in remove) {
                parent.RemoveChild(obsolete);
                ProjectMgr.OnItemDeleted(obsolete);
            }

            if (modules != null) {
                foreach (var package in modules) {
                    DependencyNode child;

                    if (recycle.ContainsKey(package.Name)) {
                        child = recycle[package.Name];
                        child.Package = package;
                    }
                    else {
                        child = new DependencyNode(_projectNode, parent as DependencyNode, package);
                        parent.AddChild(child);
                    }

                    ReloadHierarchy(child, package.Modules);
                    if (ProjectMgr.ParentHierarchy != null) {
                        child.ExpandItem(EXPANDFLAGS.EXPF_CollapseFolder);
                    }
                }
            }
        }