// ------------------------------------------------------------------- /// <summary> /// Updates the read-only text field that displays a string /// representation of the selected projects to be submitted. /// </summary> private void UpdateSubmittablesField() { if (submittables.Length == 0) { projectsToSubmitField.Text = Messages.ChooseProjectsPrompt; } else if (submittables[0] is SubmittableSolution) { SubmittableSolution ss = (SubmittableSolution)submittables[0]; projectsToSubmitField.Text = String.Format(Messages.EntireSolutionMessage, Path.GetFileNameWithoutExtension(ss.SolutionName)); } else { SubmittableProject sp = (SubmittableProject)submittables[0]; StringBuilder builder = new StringBuilder(); builder.Append(sp.HierarchyItem["Name"]); for (int i = 1; i < submittables.Length; i++) { builder.Append(", "); builder.Append(((SubmittableProject)submittables[i]). HierarchyItem["Name"]); } projectsToSubmitField.Text = builder.ToString(); } }
// ------------------------------------------------------------------- /// <summary> /// Searches the current selection to determine if the given hierarchy /// item is contained in it. /// </summary> /// <param name="hierarchyItem"> /// The hierarchy item to search for. /// </param> /// <returns> /// True if the hierarchy item was found in the selection; otherwise, /// false. /// </returns> private bool FindHierarchyItemInSelection(HierarchyItem hierarchyItem) { foreach (ISubmittableItem item in selection) { SubmittableProject sp = item as SubmittableProject; if (sp != null) { if (sp.HierarchyItem.Equals(hierarchyItem)) { return(true); } } } return(false); }
// ------------------------------------------------------------------- /// <summary> /// Gets a value indicating whether all of the projects in the given /// list of hierarchy items are also in the given list of submittable /// items. /// </summary> /// <remarks> /// This method is used to determine if we should just submit the whole /// solution when every project is selected. /// </remarks> /// <param name="allProjects"> /// A list of hierarchy items that represent projects. /// </param> /// <param name="submittables"> /// A list of submittable items. /// </param> /// <returns> /// True if all of the projects are contained in the list of /// submittable items. /// </returns> private bool AreAllProjectsInSubmittables( IEnumerable <HierarchyItem> allProjects, IEnumerable <ISubmittableItem> submittables) { List <HierarchyItem> masterList = new List <HierarchyItem>( allProjects); foreach (ISubmittableItem item in submittables) { SubmittableProject sp = item as SubmittableProject; if (sp != null) { masterList.Remove(sp.HierarchyItem); } } return(masterList.Count == 0); }
// ------------------------------------------------------------------- /// <summary> /// Appends to a selection list the submittable item in the given node, /// if it is checked. /// </summary> /// <remarks> /// This method handles nested elements -- if the parent of an item is /// checked, that means that all of its children are as well, so only /// the parent needs to be added to the selection. If a parent node is /// not checked, then we recursively look at its children to determine /// if any of them need to be added to the selection. /// </remarks> /// <param name="items"> /// The list that will be built up to contain the selection. /// </param> /// <param name="node"> /// The node to possibly add to the selection. /// </param> private void AppendSelectionFromNode(List <ISubmittableItem> items, TreeNode node) { if (node.Checked) { string solutionDir, solutionFile, solutionUser; IVsSolution solution = VsShellUtils.GetSolution(serviceProvider); solution.GetSolutionInfo(out solutionDir, out solutionFile, out solutionUser); ISubmittableItem item = null; if (node.Tag is IVsSolution) { item = new SubmittableSolution((IVsSolution)node.Tag); } else if (node.Tag is HierarchyItem) { HierarchyItem hierarchy = (HierarchyItem)node.Tag; item = new SubmittableProject(solutionDir, hierarchy); } if (item != null) { items.Add(item); } } else { foreach (TreeNode child in node.Nodes) { AppendSelectionFromNode(items, child); } } }
// ------------------------------------------------------------------- /// <summary> /// Appends to a selection list the submittable item in the given node, /// if it is checked. /// </summary> /// <remarks> /// This method handles nested elements -- if the parent of an item is /// checked, that means that all of its children are as well, so only /// the parent needs to be added to the selection. If a parent node is /// not checked, then we recursively look at its children to determine /// if any of them need to be added to the selection. /// </remarks> /// <param name="items"> /// The list that will be built up to contain the selection. /// </param> /// <param name="node"> /// The node to possibly add to the selection. /// </param> private void AppendSelectionFromNode(List<ISubmittableItem> items, TreeNode node) { if (node.Checked) { string solutionDir, solutionFile, solutionUser; IVsSolution solution = VsShellUtils.GetSolution(serviceProvider); solution.GetSolutionInfo(out solutionDir, out solutionFile, out solutionUser); ISubmittableItem item = null; if (node.Tag is IVsSolution) { item = new SubmittableSolution((IVsSolution)node.Tag); } else if (node.Tag is HierarchyItem) { HierarchyItem hierarchy = (HierarchyItem)node.Tag; item = new SubmittableProject(solutionDir, hierarchy); } if(item != null) { items.Add(item); } } else { foreach (TreeNode child in node.Nodes) { AppendSelectionFromNode(items, child); } } }