// ------------------------------------------------------------------- /// <summary> /// Populates the tree with the current solution and the projects /// loaded in the solution. /// </summary> private void PopulateTree() { string solutionDir, solutionFile, solutionUser; IVsSolution solution = VsShellUtils.GetSolution(serviceProvider); solution.GetSolutionInfo(out solutionDir, out solutionFile, out solutionUser); string solutionName = Path.GetFileNameWithoutExtension(solutionFile); TreeNode root = new TreeNode( String.Format(Messages.SolutionPlaceholder, solutionName)); root.Tag = solution; treeView.Nodes.Add(root); if (FindSolutionInSelection(solution)) { root.Checked = true; } foreach (HierarchyItem item in VsShellUtils.GetLoadedProjects(solution)) { AddHierarchyItemToNode(item, root); } treeView.ExpandAll(); }
//~ Methods .......................................................... // ------------------------------------------------------ /// <summary> /// Called when the form is loaded. /// </summary> /// <param name="e"> /// An <code>EventArgs</code> object. /// </param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); // Recursively add each project's hierarchy items to the tree. foreach (HierarchyItem item in VsShellUtils.GetLoadedProjects(serviceProvider)) { AddNode(item, hierarchyItemTree.Nodes); } }
public void PopulateFromSolution() { TestSuiteCollector collector = new TestSuiteCollector(); foreach (HierarchyItem projectHier in VsShellUtils.GetLoadedProjects(solution)) { Project project = projectHier.GetExtObjectAs <Project>(); collector.Process(project); } suites = collector.Suites; possibleTestFiles = collector.PossibleTestFiles; mainExists = collector.MainFunctionExists; }
// ------------------------------------------------------------------- /// <summary> /// Collects the projects that are currently selected in the Solution /// Explorer and invokes the submission wizard. /// </summary> private void SubmitProject_Invoked(object sender, EventArgs e) { HierarchyItem[] selectedItems = VsShellUtils.GetCurrentSelection(this); List <ISubmittableItem> submittables = new List <ISubmittableItem>(); IVsSolution solution = VsShellUtils.GetSolution(this); string solutionDir, solutionFile, solutionUser; solution.GetSolutionInfo(out solutionDir, out solutionFile, out solutionUser); if (selectedItems.Length > 0) { foreach (HierarchyItem selectedItem in selectedItems) { if (selectedItem.IsProject) { submittables.Add(new SubmittableProject(solutionDir, selectedItem)); } } // Handle subprojects here by filtering them out of the list // if their parent project is also in the list? // If the selection includes all of the projects in the // solution, then just make the solution itself the current // selection. IEnumerable <HierarchyItem> allProjects = VsShellUtils.GetLoadedProjects(solution); if (AreAllProjectsInSubmittables(allProjects, submittables)) { submittables.Clear(); submittables.Add(new SubmittableSolution(solution)); } if (submittables.Count > 0) { ShowSubmissionWizard(submittables.ToArray()); } } }
internal NewCxxTestSuiteWizardPage1(IServiceProvider sp, HierarchyItem headerUnderTest) { InitializeComponent(); serviceProvider = sp; this.headerUnderTest = headerUnderTest; // Initialize the project list. foreach (HierarchyItem item in VsShellUtils.GetLoadedProjects(serviceProvider)) { existingProjectsCombo.Items.Add(new ProjectItem(item)); } if (headerUnderTest != null) { string header = headerUnderTest.ProjectRelativePath; headerUnderTestField.Text = header; nameField.Text = Path.GetFileNameWithoutExtension(header) + "Tests"; bool madeSelection = false; foreach (ProjectItem item in existingProjectsCombo.Items) { if (item.Item.Equals(headerUnderTest.ContainingProject)) { existingProjectsCombo.SelectedItem = item; madeSelection = true; break; } } if (!madeSelection) { existingProjectsCombo.SelectedIndex = 0; } } superclassField.Text = "CxxTest::TestSuite"; }