コード例 #1
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;
			}
		}
コード例 #2
0
        void OnSystemFileDeleted(object sender, FileEventArgs args)
        {
            if (Context.Tree.IsDestroyed)
            {
                return;
            }
            foreach (FileEventInfo e in args)
            {
                try {
                    Project project = GetProjectForFile(e.FileName);

                    ITreeBuilder tb = Context.GetTreeBuilder();

                    if (e.IsDirectory)
                    {
                        if (tb.MoveToObject(new ProjectFolder(e.FileName, project)))
                        {
                            if (tb.Options ["ShowAllFiles"] && (project == null || !ProjectFolderCommandHandler.PathExistsInProject(project, e.FileName)))
                            {
                                tb.Remove();
                                return;
                            }
                        }
                    }
                    else
                    {
                        if (tb.MoveToObject(new SystemFile(e.FileName, project)))
                        {
                            tb.Remove();
                            return;
                        }
                    }

                    // Find the parent folder, and update it's children count

                    string parentPath = Path.GetDirectoryName(e.FileName);
                    if (tb.MoveToObject(new ProjectFolder(parentPath, project)))
                    {
                        if (tb.Options ["ShowAllFiles"] && Directory.Exists(parentPath))
                        {
                            tb.UpdateChildren();
                        }
                    }
                } catch (Exception ex) {
                    LoggingService.LogInternalError($"Error while updating project tree in OnSystemFileDeleted : {string.Join (", ", args.Select (x => x.FileName))}.", ex);
                }
            }
        }
コード例 #3
0
        void OnPackageDependenciesChanged(object sender, EventArgs e)
        {
            var          cache   = (PackageDependencyNodeCache)sender;
            var          project = cache.Project;
            ITreeBuilder builder = Context.GetTreeBuilder(project);

            if (builder == null)
            {
                return;
            }

            if (builder.MoveToChild(DependenciesNode.NodeName, typeof(DependenciesNode)))
            {
                if (builder.MoveToChild(PackageDependenciesNode.NodeName, typeof(PackageDependenciesNode)))
                {
                    var node = builder.DataItem as PackageDependenciesNode;
                    if (node != null && !node.HasChildNodes())
                    {
                        builder.Remove();
                        return;
                    }
                    builder.UpdateAll();
                }
            }
        }
コード例 #4
0
        void OnSystemFileRenamed(object sender, FileCopyEventArgs args)
        {
            foreach (FileCopyEventInfo e in args)
            {
                Project project = GetProjectForFile(e.SourceFile);
                if (project == null)
                {
                    return;
                }

                if (e.IsDirectory)
                {
                    /*				string childPath;
                     *                              ITreeBuilder tb = FindParentFolderNode (e.SourceFile, project, out childPath);
                     *                              if (tb != null && tb.Options ["ShowAllFiles"]) {
                     *                                      tb.UpdateAll ();
                     *                              }
                     */
                }
                else
                {
                    ITreeBuilder tb = Context.GetTreeBuilder(new SystemFile(e.SourceFile, project));
                    if (tb != null)
                    {
                        tb.Remove(true);
                        tb.AddChild(new SystemFile(e.TargetFile, project));
                    }
                }
            }
        }
 private void OnConnectionRemoved(object sender, DatabaseConnectionContextEventArgs args)
 {
     if (builder.MoveToObject(args.ConnectionContext))
     {
         builder.Remove();
         builder.MoveToParent();
     }
 }
コード例 #6
0
        void OnEntryRemoved(object sender, WorkspaceItemEventArgs e)
        {
            ITreeBuilder tb = Context.GetTreeBuilder(e.Item);

            if (tb != null)
            {
                tb.Remove();
            }
        }
コード例 #7
0
        void OnEntryRemoved(object sender, SolutionItemEventArgs e)
        {
            ITreeBuilder tb = Context.GetTreeBuilder(e.SolutionItem);

            if (tb != null)
            {
                tb.Remove();
            }
        }
コード例 #8
0
        void OnSystemFileDeleted(object sender, FileEventArgs args)
        {
            foreach (FileEventInfo e in args)
            {
                Project project = GetProjectForFile(e.FileName);
                if (project == null)
                {
                    return;
                }

                ITreeBuilder tb = Context.GetTreeBuilder();

                if (e.IsDirectory)
                {
                    if (tb.MoveToObject(new ProjectFolder(e.FileName, project)))
                    {
                        if (tb.Options ["ShowAllFiles"] && !ProjectFolderCommandHandler.PathExistsInProject(project, e.FileName))
                        {
                            tb.Remove();
                            return;
                        }
                    }
                }
                else
                {
                    if (tb.MoveToObject(new SystemFile(e.FileName, project)))
                    {
                        tb.Remove();
                        return;
                    }
                }

                // Find the parent folder, and update it's children count

                string parentPath = Path.GetDirectoryName(e.FileName);
                if (tb.MoveToObject(new ProjectFolder(parentPath, project)))
                {
                    if (tb.Options ["ShowAllFiles"] && Directory.Exists(parentPath))
                    {
                        tb.UpdateChildren();
                    }
                }
            }
        }
コード例 #9
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 OnFileRemoved(object sender, FileEventArgs e)
 {
     foreach (FileEventInfo info in e)
     {
         ITreeBuilder treeBuilder = Context.GetTreeBuilder();
         if (treeBuilder.MoveToObject(new WorkspaceFolder(info.FileName)))
         {
             treeBuilder.Remove();
         }
     }
 }
コード例 #11
0
        void OnRemoveReference(object sender, ProjectReferenceEventArgs e)
        {
            ITreeBuilder tb = Context.GetTreeBuilder(e.Project);

            if (tb != null)
            {
                if (tb.FindChild(e.ProjectReference, true))
                {
                    tb.Remove();
                }
            }
        }
コード例 #12
0
        void OnFileRemoved(object s, SolutionItemFileEventArgs args)
        {
            SolutionFolder folder = (SolutionFolder)s;
            ITreeBuilder   tb     = Context.GetTreeBuilder(folder.ParentSolution);

            if (tb != null)
            {
                if (tb.MoveToChild(args.File, typeof(SolutionFolderFileNode)))
                {
                    tb.Remove();
                }
            }
        }
コード例 #13
0
        void OnRemoveReference(object sender, ProjectReferenceEventArgs e)
        {
            var p = e.Project as DotNetProject;

            if (p != null)
            {
                ITreeBuilder tb = Context.GetTreeBuilder(p.References);
                if (tb != null && tb.FindChild(e.ProjectReference, true))
                {
                    tb.Remove();
                }
            }
        }
コード例 #14
0
        void OnEntryRemoved(object sender, SolutionItemChangeEventArgs e)
        {
            // If reloading, ignore the event. We handle it in OnEntryAdded.
            if (e.Reloading)
            {
                return;
            }

            ITreeBuilder tb = Context.GetTreeBuilder(e.SolutionItem);

            if (tb != null)
            {
                tb.Remove();
            }
        }
コード例 #15
0
        void OnFolderRemoved(object sender, FileEventArgs e)
        {
            ITreeBuilder tb = Context.GetTreeBuilder(sender);

            if (tb != null)
            {
                if (!tb.HasChildren())
                {
                    tb.Remove();
                }
                else
                {
                    tb.UpdateAll();
                }
            }
        }
コード例 #16
0
 void OnAddFile(object sender, ProjectFileEventArgs e)
 {
     if (!e.ProjectFile.IsLink)
     {
         object target;
         if (e.ProjectFile.Subtype == Subtype.Directory)
         {
             target = new ProjectFolder(e.ProjectFile.FilePath, e.Project);
         }
         else
         {
             ITreeBuilder tb = Context.GetTreeBuilder(new SystemFile(e.ProjectFile.Name, e.Project));
             if (tb != null)
             {
                 tb.Remove(true);
             }
             target = e.ProjectFile;
         }
         Context.Tree.AddNodeInsertCallback(target, new TreeNodeCallback(UpdateProjectFileParent));
     }
 }
コード例 #17
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;
                }
            }
        }
コード例 #18
0
        void OnClassInformationChanged(object sender, TypeUpdateInformationEventArgs e)
        {
//			DateTime t = DateTime.Now;
            Dictionary <object, bool> oldStatus         = new Dictionary <object, bool> ();
            List <string>             namespacesToClean = new List <string> ();
            ITreeBuilder tb = Context.GetTreeBuilder();

            foreach (IType cls in e.TypeUpdateInformation.Removed)
            {
                if (tb.MoveToObject(new ClassData(e.Project, cls)))
                {
                    oldStatus [tb.DataItem] = tb.Expanded;

                    ITreeNavigator np = tb.Clone();
                    np.MoveToParent();
                    oldStatus [np.DataItem] = np.Expanded;

                    tb.Remove(true);
                }
                namespacesToClean.Add(cls.Namespace);
            }

            foreach (IType cls in e.TypeUpdateInformation.Modified)
            {
                ClassData ucd = new ClassData(e.Project, cls);
                if (tb.MoveToObject(ucd))
                {
                    ClassData cd = (ClassData)tb.DataItem;
                    cd.UpdateFrom(ucd);
                    tb.UpdateAll();
                }
            }

            foreach (IType cls in e.TypeUpdateInformation.Added)
            {
                AddClass(e.Project, cls);
            }

            // Clean empty namespaces

            foreach (string ns in namespacesToClean)
            {
                string subns = ns;
                while (subns != null)
                {
                    bool found = tb.MoveToObject(new ProjectNamespaceData(e.Project, subns));
                    if (!found)
                    {
                        found = tb.MoveToObject(new ProjectNamespaceData(null, subns));
                    }
                    if (found)
                    {
                        while (tb.DataItem is NamespaceData && !tb.HasChildren())
                        {
                            tb.Remove(true);
                        }
                        break;
                    }
                    int i = subns.LastIndexOf('.');
                    if (i != -1)
                    {
                        subns = subns.Substring(0, i);
                    }
                    else
                    {
                        subns = null;
                    }
                }
            }

            // Restore expand status

            foreach (KeyValuePair <object, bool> de in oldStatus)
            {
                if (de.Value && tb.MoveToObject(de.Key))
                {
                    tb.ExpandToNode();
                    tb.Expanded = true;
                }
            }
        }