public void RefreshNode(GenericNode node) { // refresh the first parent that *can* be refreshed while (node != null && !node.IsRefreshable) { node = node.Parent as GenericNode; } if (node == null) { return; } // if you refresh a SwfFileNode this way (by asking for it), you get // special feedback SwfFileNode swfNode = node as SwfFileNode; if (swfNode != null) { swfNode.RefreshWithFeedback(true); } else { node.Refresh(true); } }
public override void Refresh(bool recursive) { base.Refresh(recursive); ArrayList projectClasspaths = new ArrayList(); ArrayList globalClasspaths = new ArrayList(); GenericNodeList nodesToDie = new GenericNodeList(); foreach (GenericNode oldRef in Nodes) { nodesToDie.Add(oldRef); } //if (Nodes.Count == 0) recursive = true; // explore classpaths if (PluginMain.Settings.ShowProjectClasspaths) { projectClasspaths.AddRange(project.Classpaths); if (project.AdditionalPaths != null) { projectClasspaths.AddRange(project.AdditionalPaths); } } projectClasspaths.Sort(); if (PluginMain.Settings.ShowGlobalClasspaths) { globalClasspaths.AddRange(PluginMain.Settings.GlobalClasspaths); } globalClasspaths.Sort(); // create references nodes ClasspathNode cpNode; foreach (string projectClasspath in projectClasspaths) { string absolute = projectClasspath; if (!Path.IsPathRooted(absolute)) { absolute = project.GetAbsolutePath(projectClasspath); } if ((absolute + "\\").StartsWith(project.Directory + "\\")) { continue; } if (!project.ShowHiddenPaths && project.IsPathHidden(absolute)) { continue; } cpNode = ReuseNode(absolute, nodesToDie) as ProjectClasspathNode ?? new ProjectClasspathNode(project, absolute, projectClasspath); Nodes.Add(cpNode); cpNode.Refresh(recursive); } foreach (string globalClasspath in globalClasspaths) { string absolute = globalClasspath; if (!Path.IsPathRooted(absolute)) { absolute = project.GetAbsolutePath(globalClasspath); } if (absolute.StartsWith(project.Directory + Path.DirectorySeparatorChar.ToString())) { continue; } cpNode = ReuseNode(absolute, nodesToDie) as ProjectClasspathNode ?? new ClasspathNode(project, absolute, globalClasspath); Nodes.Add(cpNode); cpNode.Refresh(recursive); } // add external libraries at the top level also if (project is AS3Project) { foreach (LibraryAsset asset in (project as AS3Project).SwcLibraries) { if (!asset.IsSwc) { continue; } // check if SWC is inside the project or inside a classpath string absolute = asset.Path; if (!Path.IsPathRooted(absolute)) { absolute = project.GetAbsolutePath(asset.Path); } bool showNode = true; if (absolute.StartsWith(project.Directory)) { showNode = false; } foreach (string path in project.AbsoluteClasspaths) { if (absolute.StartsWith(path)) { showNode = false; break; } } foreach (string path in PluginMain.Settings.GlobalClasspaths) { if (absolute.StartsWith(path)) { showNode = false; break; } } if (showNode && !project.ShowHiddenPaths && project.IsPathHidden(absolute)) { continue; } if (showNode && File.Exists(absolute)) { SwfFileNode swcNode = ReuseNode(absolute, nodesToDie) as SwfFileNode ?? new SwfFileNode(absolute); Nodes.Add(swcNode); swcNode.Refresh(recursive); } } } foreach (GenericNode node in nodesToDie) { node.Dispose(); Nodes.Remove(node); } }
private void RebuildProjectNode(Project project) { activeProject = project; // create the top-level project node ProjectNode projectNode = new ProjectNode(project); Nodes.Add(projectNode); projectNode.Refresh(true); projectNode.Expand(); ArrayList projectClasspaths = new ArrayList(); ArrayList globalClasspaths = new ArrayList(); if (PluginMain.Settings.ShowProjectClasspaths) { projectClasspaths.AddRange(project.Classpaths); if (project.AdditionalPaths != null) { projectClasspaths.AddRange(project.AdditionalPaths); } } if (PluginMain.Settings.ShowGlobalClasspaths) { globalClasspaths.AddRange(PluginMain.Settings.GlobalClasspaths); } ReferencesNode refs = new ReferencesNode(project.Directory, "References"); projectNode.References = refs; ClasspathNode cpNode; foreach (string projectClasspath in projectClasspaths) { string absolute = projectClasspath; if (!Path.IsPathRooted(absolute)) { absolute = project.GetAbsolutePath(projectClasspath); } if ((absolute + "\\").StartsWith(project.Directory + "\\")) { continue; } cpNode = new ProjectClasspathNode(project, absolute, projectClasspath); refs.Nodes.Add(cpNode); cpNode.Refresh(true); } foreach (string globalClasspath in globalClasspaths) { string absolute = globalClasspath; if (!Path.IsPathRooted(absolute)) { absolute = project.GetAbsolutePath(globalClasspath); } if (absolute.StartsWith(project.Directory + Path.DirectorySeparatorChar.ToString())) { continue; } cpNode = new ClasspathNode(project, absolute, globalClasspath); refs.Nodes.Add(cpNode); cpNode.Refresh(true); } // add external libraries at the top level also if (project is AS3Project) { foreach (LibraryAsset asset in (project as AS3Project).SwcLibraries) { if (!asset.IsSwc) { continue; } // check if SWC is inside the project or inside a classpath string absolute = asset.Path; if (!Path.IsPathRooted(absolute)) { absolute = project.GetAbsolutePath(asset.Path); } bool showNode = true; if (absolute.StartsWith(project.Directory)) { showNode = false; } foreach (string path in project.AbsoluteClasspaths) { if (absolute.StartsWith(path)) { showNode = false; break; } } foreach (string path in PluginMain.Settings.GlobalClasspaths) { if (absolute.StartsWith(path)) { showNode = false; break; } } if (showNode && File.Exists(absolute)) { SwfFileNode swcNode = new SwfFileNode(absolute); refs.Nodes.Add(swcNode); swcNode.Refresh(true); } } } }
/// <summary> /// Rebuilds the tree from scratch. /// </summary> public void RebuildTree(bool saveState, bool restoreExpanded) { // store old tree state List <string> previouslyExpanded = restoreExpanded ? ExpandedPaths : new List <string>(); foreach (GenericNode node in Nodes) { node.Dispose(); } BeginUpdate(); SelectedNodes = null; Nodes.Clear(); nodeMap.Clear(); ShowRootLines = false; if (project == null) { EndUpdate(); return; } // create the top-level project node ProjectNode projectNode = new ProjectNode(project); Nodes.Add(projectNode); projectNode.Refresh(true); projectNode.Expand(); ArrayList projectClasspaths = new ArrayList(); ArrayList globalClasspaths = new ArrayList(); if (PluginMain.Settings.ShowProjectClasspaths) { projectClasspaths.AddRange(project.Classpaths); } if (PluginMain.Settings.ShowGlobalClasspaths) { globalClasspaths.AddRange(PluginMain.Settings.GlobalClasspaths); } ClasspathNode cpNode; foreach (string projectClasspath in projectClasspaths) { string absolute = projectClasspath; if (!Path.IsPathRooted(absolute)) { absolute = project.GetAbsolutePath(projectClasspath); } if ((absolute + "\\").StartsWith(project.Directory + "\\")) { continue; } cpNode = new ProjectClasspathNode(project, absolute, projectClasspath); Nodes.Add(cpNode); cpNode.Refresh(true); ShowRootLines = true; } foreach (string globalClasspath in globalClasspaths) { string absolute = globalClasspath; if (!Path.IsPathRooted(absolute)) { absolute = project.GetAbsolutePath(globalClasspath); } if (absolute.StartsWith(project.Directory + Path.DirectorySeparatorChar.ToString())) { continue; } cpNode = new ClasspathNode(project, absolute, globalClasspath); Nodes.Add(cpNode); cpNode.Refresh(true); ShowRootLines = true; } // add external libraries at the top level also if (project is AS3Project) { foreach (LibraryAsset asset in (project as AS3Project).SwcLibraries) { if (!asset.IsSwc) { continue; } // check if SWC is inside the project or inside a classpath string absolute = asset.Path; if (!Path.IsPathRooted(absolute)) { absolute = project.GetAbsolutePath(asset.Path); } bool showNode = true; if (absolute.StartsWith(project.Directory)) { showNode = false; } foreach (string path in project.AbsoluteClasspaths) { if (absolute.StartsWith(path)) { showNode = false; break; } } foreach (string path in PluginMain.Settings.GlobalClasspaths) { if (absolute.StartsWith(path)) { showNode = false; break; } } if (showNode && File.Exists(absolute)) { SwfFileNode swcNode = new SwfFileNode(absolute); Nodes.Add(swcNode); swcNode.Refresh(true); ShowRootLines = true; } } } // restore tree state ExpandedPaths = previouslyExpanded; // scroll to the top projectNode.EnsureVisible(); SelectedNode = projectNode; Win32.Scrolling.scrollToLeft(this); EndUpdate(); }