Inheritance: HierarchyNode
示例#1
0
        private void RenameFolder(string newName)
        {
            // Do the rename (note that we only do the physical rename if the leaf name changed)
            string newPath = Path.Combine(this.Parent.VirtualNodeName, newName);

            if (String.Compare(Path.GetFileName(VirtualNodeName), newName, StringComparison.Ordinal) != 0)
            {
                this.RenameDirectory(Path.Combine(this.ProjectMgr.ProjectFolder, newPath));
            }
            this.VirtualNodeName = newPath;

            this.ItemNode.Rename(VirtualNodeName);
            ThreadHelper.ThrowIfNotOnUIThread();

            // Let all children know of the new path
            for (HierarchyNode child = this.FirstChild; child != null; child = child.NextSibling)
            {
                FileNode childFileNode = child as FileNode;
                if (childFileNode != null && childFileNode.IsLink)
                {
                    string linkPath = Path.Combine(newPath, child.Caption);
                    childFileNode.RenameFileNode(child.Url, child.Url, linkPath, this.ID);
                }
                else if (!(child is FolderNode))
                {
                    child.SetEditLabel(child.Caption);
                }
                else
                {
                    FolderNode childFolderNode = (FolderNode)child;
                    childFolderNode.RenameFolder(childFolderNode.Caption);
                }
            }

            // Some of the previous operation may have changed the selection so set it back to us
            IVsUIHierarchyWindow uiWindow = UIHierarchyUtilities.GetUIHierarchyWindow(this.ProjectMgr.Site, SolutionExplorer);

            // This happens in the context of renaming a folder.
            // Since we are already in solution explorer, it is extremely unlikely that we get a null return.
            // If we do, the consequences are minimal: the parent node will be selected instead of the
            // renamed node.
            if (uiWindow != null)
            {
                ErrorHandler.ThrowOnFailure(uiWindow.ExpandItem(this.ProjectMgr, this.ID, EXPANDFLAGS.EXPF_SelectItem));
            }
        }
示例#2
0
        protected virtual void RenameFolder(string newName)
        {
            // Do the rename (note that we only do the physical rename if the leaf name changed)
            string newPath = Path.Combine(this.Parent.VirtualNodeName, newName);

            if (!String.Equals(Path.GetFileName(VirtualNodeName), newName, StringComparison.Ordinal))
            {
                this.RenameDirectory(Path.Combine(this.ProjectManager.ProjectFolder, newPath));
            }
            this.VirtualNodeName = newPath;

            this.ItemNode.Rename(VirtualNodeName);

            // Let all children know of the new path
            for (HierarchyNode child = this.FirstChild; child != null; child = child.NextSibling)
            {
                FolderNode node = child as FolderNode;

                if (node == null)
                {
                    child.SetEditLabel(child.Caption);
                }
                else
                {
                    node.RenameFolder(node.Caption);
                }
            }

            // Some of the previous operation may have changed the selection so set it back to us
            IVsUIHierarchyWindow uiWindow = UIHierarchyUtilities.GetUIHierarchyWindow(this.ProjectManager.Site, SolutionExplorer);

            // This happens in the context of renaming a folder.
            // Since we are already in solution explorer, it is extremely unlikely that we get a null return.
            // If we do, the consequences are minimal: the parent node will be selected instead of the
            // renamed node.
            if (uiWindow != null)
            {
                ErrorHandler.ThrowOnFailure(uiWindow.ExpandItem(this.ProjectManager.InteropSafeIVsUIHierarchy, this.Id, EXPANDFLAGS.EXPF_SelectItem));
            }

            ProjectManager.ItemIdMap.UpdateCanonicalName(this);
        }
示例#3
0
 /// <summary>
 /// To support virtual folders, override this method to return your own folder nodes
 /// </summary>
 /// <param name="path">Path to store for this folder</param>
 /// <param name="element">Element corresponding to the folder</param>
 /// <returns>A FolderNode that can then be added to the hierarchy</returns>
 protected internal virtual FolderNode CreateFolderNode(string path, ProjectElement element)
 {
     FolderNode folderNode = new FolderNode(this, path, element);
     return folderNode;
 }
示例#4
0
 public NemerleOAFolderItem(OAProject project, FolderNode node)
     : base(project, node)
 {
 }
示例#5
0
        /// <summary>
        /// To support virtual folders, override this method to return your own folder nodes
        /// </summary>
        /// <param name="path">Path to store for this folder</param>
        /// <param name="element">Element corresponding to the folder</param>
        /// <returns>A FolderNode that can then be added to the hierarchy</returns>
        public virtual FolderNode CreateFolderNode(string path, ProjectElement element)
        {
            if (element == null)
                throw new ArgumentNullException("element");

            FolderNode folderNode = new FolderNode(this, path, element);
            return folderNode;
        }