void UpdateProjectFileParent(ITreeNavigator nav)
        {
            ITreeBuilder tb = Context.GetTreeBuilder(nav);

            if (!(tb.DataItem is ProjectFolder))
            {
                tb.MoveToParent();
            }
            while (tb.DataItem is ProjectFolder)
            {
                tb.Update();
                tb.MoveToParent();
            }
        }
Example #2
0
		void RemoveFile (ProjectFile file, Project project)
		{
			ITreeBuilder tb = Context.GetTreeBuilder ();
			
			if (file.Subtype == Subtype.Directory) {
				if (!tb.MoveToObject (new ProjectFolder (file.Name, project)))
					return;
				tb.MoveToParent ();
				tb.UpdateAll ();
				return;
			} else {
				if (tb.MoveToObject (file)) {
					tb.Remove (true);
				} else {
					// We can't use IsExternalToProject here since the ProjectFile has
					// already been removed from the project
					string parentPath = file.IsLink
						? project.BaseDirectory.Combine (file.Link.IsNullOrEmpty? file.FilePath.FileName : file.Link.ToString ()).ParentDirectory
						: file.FilePath.ParentDirectory;
					
					if (!tb.MoveToObject (new ProjectFolder (parentPath, project)))
						return;
				}
			}
			
			while (tb.DataItem is ProjectFolder) {
				ProjectFolder f = (ProjectFolder) tb.DataItem;
				if (!Directory.Exists (f.Path) && !project.Files.GetFilesInVirtualPath (f.Path.ToRelative (project.BaseDirectory)).Any ())
					tb.Remove (true);
				else
					break;
			}
		}
 private void OnConnectionRemoved(object sender, DatabaseConnectionContextEventArgs args)
 {
     if (builder.MoveToObject(args.ConnectionContext))
     {
         builder.Remove();
         builder.MoveToParent();
     }
 }
        void OnNodeHidden(object sender, EventArgs args)
        {
            ITreeBuilder builder = Context.GetTreeBuilder(sender);

            if (builder != null)
            {
                builder.MoveToParent();
                builder.UpdateAll();
            }
        }
Example #5
0
        private void OnConnectionRemoved(object sender, DatabaseConnectionContextEventArgs args)
        {
            ITreeBuilder builder = Context.GetTreeBuilder(args.ConnectionContext);

            if (builder.MoveToObject(args.ConnectionContext))
            {
                builder.Remove();
                builder.MoveToParent();
                builder.UpdateAll();
            }
        }
        void RefreshChildNodes(DotNetProject project)
        {
            ITreeBuilder builder = Context.GetTreeBuilder(project);

            if (builder != null)
            {
                if (builder.MoveToChild("References", typeof(ProjectReferenceCollection)))
                {
                    builder.UpdateAll();
                    builder.MoveToParent();
                }

                if (builder.MoveToChild("Packages", typeof(ProjectPackagesFolderNode)))
                {
                    var packagesFolder = (ProjectPackagesFolderNode)builder.DataItem;
                    packagesFolder.ClearPackageReferences();
                    builder.UpdateAll();
                    builder.MoveToParent();
                }
            }
        }
        void RefreshChildNodes(DotNetProject project)
        {
            ITreeBuilder builder = Context.GetTreeBuilder(project);

            if (builder != null)
            {
                if (builder.MoveToChild(ProjectPackagesFolderNode.NodeName, typeof(ProjectPackagesFolderNode)))
                {
                    var packagesFolder = (ProjectPackagesFolderNode)builder.DataItem;
                    packagesFolder.RefreshPackages();
                    builder.MoveToParent();
                }
            }
        }
Example #8
0
        void OnPackageReferencesChanged(object sender, EventArgs e)
        {
            var          projectPackagesNode = (ProjectPackagesFolderNode)sender;
            ITreeBuilder builder             = Context.GetTreeBuilder(projectPackagesNode);

            if (builder != null)
            {
                builder.UpdateAll();
                builder.MoveToParent();
            }

            if (builder.MoveToChild("References", typeof(ProjectReferenceCollection)))
            {
                builder.UpdateAll();
            }
        }
		ProjectPackagesFolderNode GetPackagesFolderNode (ITreeBuilder treeBuilder)
		{
			NodePosition originalPosition = treeBuilder.CurrentPosition;

			if (!treeBuilder.MoveToParent ()) {
				return null;
			}

			ProjectPackagesFolderNode packagesFolder = null;
			if (treeBuilder.MoveToChild (ProjectPackagesFolderNode.NodeName, typeof(ProjectPackagesFolderNode))) {
				packagesFolder = treeBuilder.DataItem as ProjectPackagesFolderNode;
			}

			treeBuilder.MoveToPosition (originalPosition);

			return packagesFolder;
		}
Example #10
0
        void OnFileNestingRulesChanged(ProjectFile fileToUpdate, ProjectFile newParent)
        {
            Debug.Assert(fileToUpdate != null);

            ITreeBuilder tb = Context.GetTreeBuilder(fileToUpdate);

            if (tb != null)
            {
                tb.MoveToParent();
                tb.UpdateAll();
            }

            if (newParent != null)
            {
                tb = Context.GetTreeBuilder(newParent);
                tb?.UpdateAll();
            }
        }
        ProjectPackagesFolderNode GetPackagesFolderNode(ITreeBuilder treeBuilder)
        {
            NodePosition originalPosition = treeBuilder.CurrentPosition;

            if (!treeBuilder.MoveToParent())
            {
                return(null);
            }

            ProjectPackagesFolderNode packagesFolder = null;

            if (treeBuilder.MoveToChild(ProjectPackagesFolderNode.NodeName, typeof(ProjectPackagesFolderNode)))
            {
                packagesFolder = treeBuilder.DataItem as ProjectPackagesFolderNode;
            }

            treeBuilder.MoveToPosition(originalPosition);

            return(packagesFolder);
        }
Example #12
0
        void OnSystemFileDeleted(object sender, FileEventArgs args)
        {
            if (!args.Any(f => f.IsDirectory))
            {
                return;
            }

            // When a folder is deleted, we need to remove all references in the tree, for all projects
            ITreeBuilder tb   = Context.GetTreeBuilder();
            var          dirs = args.Where(d => d.IsDirectory).Select(d => d.FileName).ToArray();

            foreach (var p in IdeApp.Workspace.GetAllProjects())
            {
                foreach (var dir in dirs)
                {
                    if (tb.MoveToObject(new ProjectFolder(dir, p)) && tb.MoveToParent())
                    {
                        tb.UpdateAll();
                    }
                }
            }
        }
Example #13
0
        void OnSystemFileCreated(object sender, FileEventArgs args)
        {
            if (!args.Any(f => f.IsDirectory))
            {
                return;
            }

            // When a folder is created, we need to refresh the parent if the folder was created externally.
            ITreeBuilder tb   = Context.GetTreeBuilder();
            var          dirs = args.Where(d => d.IsDirectory).Select(d => d.FileName).ToArray();

            foreach (var p in IdeApp.Workspace.GetAllProjects())
            {
                foreach (var dir in dirs)
                {
                    if (tb.MoveToObject(new ProjectFolder(dir, p)))
                    {
                        if (tb.MoveToParent())
                        {
                            tb.UpdateAll();
                        }
                    }
                    else if (tb.MoveToObject(new ProjectFolder(dir.ParentDirectory, p)))
                    {
                        tb.UpdateAll();
                    }
                    else if (dir.ParentDirectory == p.BaseDirectory)
                    {
                        if (tb.MoveToObject(p))
                        {
                            tb.UpdateAll();
                        }
                    }
                }
            }
        }
Example #14
0
        void RemoveFile(ProjectFile file, Project project)
        {
            ITreeBuilder tb = Context.GetTreeBuilder();

            if (file.Subtype == Subtype.Directory)
            {
                if (!tb.MoveToObject(new ProjectFolder(file.Name, project)))
                {
                    return;
                }
                tb.MoveToParent();
                tb.UpdateAll();
                return;
            }
            else
            {
                if (tb.MoveToObject(file))
                {
                    tb.Remove(true);
                }
                else
                {
                    // We can't use IsExternalToProject here since the ProjectFile has
                    // already been removed from the project
                    FilePath parentPath = file.IsLink
                                                ? project.BaseDirectory.Combine(file.Link.IsNullOrEmpty? file.FilePath.FileName : file.Link.ToString()).ParentDirectory
                                                : file.FilePath.ParentDirectory;

                    if (!tb.MoveToObject(new ProjectFolder(parentPath, project)))
                    {
                        if (project.UseFileWatcher && parentPath.IsChildPathOf(project.BaseDirectory))
                        {
                            // Keep looking for folder higher up the tree so any empty folders
                            // can be removed.
                            while (parentPath != project.BaseDirectory)
                            {
                                parentPath = parentPath.ParentDirectory;
                                if (tb.MoveToObject(new ProjectFolder(parentPath, project)))
                                {
                                    tb.UpdateAll();
                                    break;
                                }
                            }
                        }
                        else
                        {
                            return;
                        }
                    }
                }
            }

            while (tb.DataItem is ProjectFolder)
            {
                ProjectFolder f = (ProjectFolder)tb.DataItem;
                if (!Directory.Exists(f.Path) && !project.Files.GetFilesInVirtualPath(f.Path.ToRelative(project.BaseDirectory)).Any())
                {
                    tb.Remove(true);
                }
                else if (project.UseFileWatcher)
                {
                    // Ensure empty folders are removed if they are not part of the project.
                    while (!tb.HasChildren() && tb.MoveToParent())
                    {
                        tb.UpdateAll();
                    }
                    break;
                }
                else
                {
                    break;
                }
            }
        }