//--------------------------------------------------------------------- public void OpenSettingsWindow(ProjectSelectionKind kind) { var window = ConfigureSettingsWindows(kind, true); var frame = (IVsWindowFrame)window.Frame; Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(frame.Show()); }
//--------------------------------------------------------------------- StartUpProjectSettings ComputeOptionalSettings( SolutionConfiguration2 activeConfiguration, ProjectSelectionKind kind) { var solution = (Solution2)dte.Solution; var projects = GetProjects(solution); ExtendedProject project = null; switch (kind) { case ProjectSelectionKind.StartUpProject: project = GetOptionalStartupProject(solution, projects); break; case ProjectSelectionKind.SelectedProject: project = GetOptionalSelectedProject(projects); break; } if (project == null) { return(null); } return(ComputeOptionalSettings(activeConfiguration, projects, project)); }
//--------------------------------------------------------------------- void RunCoverage(ProjectSelectionKind kind) { IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); var errorHandler = new ErrorHandler(uiShell); errorHandler.Execute(() => { var dte = (DTE2)GetService(typeof(EnvDTE.DTE)); var outputWindow = (IVsOutputWindow)GetService(typeof(SVsOutputWindow)); var outputWriter = new OutputWindowWriter(dte, outputWindow); errorHandler.OutputWriter = outputWriter; var mainSettingsManager = new MainSettingsManager(this, dte); var coverageViewManager = GetCoverageViewManager(); var coverageTreeManager = new CoverageTreeManager(this, dte, coverageViewManager); var projectBuilder = new ProjectBuilder(dte, errorHandler, outputWriter); var deserializer = new CoverageDataDeserializer(); var openCppCoverageRunner = new CoverageRunner( dte, outputWriter, coverageTreeManager, projectBuilder, coverageViewManager, deserializer, errorHandler); mainSettingsManager.ShowSettingsWindows(openCppCoverageRunner, kind); }); }
//--------------------------------------------------------------------- SettingToolWindow ConfigureSettingsWindows( ProjectSelectionKind kind, bool displayProgramOutput) { this.mainSettingController.UpdateFields(kind, displayProgramOutput); var window = this.windowFinder.FindToolWindow <SettingToolWindow>(); window.Init(this.mainSettingController); return(window); }
//--------------------------------------------------------------------- public void UpdateStartUpProject(ProjectSelectionKind kind) { var settings = this.StartUpProjectSettingsBuilder.ComputeSettings(kind); this.BasicSettingController.UpdateStartUpProject(settings); this.FilterSettingController.UpdateStartUpProject(); this.ImportExportSettingController.UpdateStartUpProject(); this.MiscellaneousSettingController.UpdateStartUpProject(); SaveSettings(); }
//--------------------------------------------------------------------- public void UpdateStartUpProject(ProjectSelectionKind kind) { if (this.StartUpProjectSettingsBuilder == null) { throw new InvalidOperationException("StartUpProjectSettingsBuilder should be set."); } var settings = this.StartUpProjectSettingsBuilder.ComputeSettings(kind); this.BasicSettingController.UpdateStartUpProject(settings); this.FilterSettingController.UpdateStartUpProject(); this.ImportExportSettingController.UpdateStartUpProject(); this.MiscellaneousSettingController.UpdateStartUpProject(); }
//--------------------------------------------------------------------- public void UpdateSettings(ProjectSelectionKind kind) { if (this.StartUpProjectSettingsBuilder == null) { throw new InvalidOperationException("StartUpProjectSettingsBuilder should be set."); } if (File.Exists(settingsFile)) { AllControllers allControllers = JsonConvert.DeserializeObject <AllControllers>(File.ReadAllText(settingsFile)); if (allControllers.basicSettingController.CurrentProject.Equals(this.StartUpProjectSettingsBuilder.ComputeSettings(kind).ProjectName)) { RecoverSettings(allControllers); return; } } UpdateStartUpProject(kind); }
//--------------------------------------------------------------------- public void UpdateFields(ProjectSelectionKind kind, bool displayProgramOutput) { var settings = ComputeStartUpProjectSettings(kind); this.UpdateStartUpProject(settings); this.selectedProjectPath = settings.ProjectPath; this.displayProgramOutput = displayProgramOutput; this.solutionConfigurationName = settings.SolutionConfigurationName; this.kind = kind; var uiSettings = this.settingsStorage.TryLoad(this.selectedProjectPath, this.solutionConfigurationName); if (uiSettings != null) { this.BasicSettingController.UpdateSettings(uiSettings.BasicSettingController); this.FilterSettingController.UpdateSettings(uiSettings.FilterSettingController); this.ImportExportSettingController.UpdateSettings(uiSettings.ImportExportSettingController); this.MiscellaneousSettingController.UpdateSettings(uiSettings.MiscellaneousSettingController); } }
//--------------------------------------------------------------------- public StartUpProjectSettings ComputeSettings(ProjectSelectionKind kind) { var solution = (Solution2)dte.Solution; var solutionBuild = (SolutionBuild2)solution.SolutionBuild; var activeConfiguration = (SolutionConfiguration2)solutionBuild.ActiveConfiguration; if (activeConfiguration != null) { var settings = ComputeOptionalSettings(activeConfiguration, kind); if (settings != null) { return(settings); } } return(new StartUpProjectSettings { CppProjects = new List <StartUpProjectSettings.CppProject>() }); }
//--------------------------------------------------------------------- public void ShowSettingsWindows( CoverageRunner coverageRunner, ProjectSelectionKind kind) { var configurationManager = new ConfigurationManager(); var settingsBuilder = new StartUpProjectSettingsBuilder(this.dte, configurationManager); var window = this.package.FindToolWindow( typeof(SettingToolWindow), 0, true) as SettingToolWindow; if (window == null || window.Frame == null) { throw new NotSupportedException("Cannot create tool window"); } window.Controller.StartUpProjectSettingsBuilder = settingsBuilder; window.Controller.CoverageRunner = coverageRunner; window.Controller.UpdateStartUpProject(kind); var frame = (IVsWindowFrame)window.Frame; Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(frame.Show()); }
//--------------------------------------------------------------------- StartUpProjectSettings ComputeStartUpProjectSettings(ProjectSelectionKind kind) { return(this.startUpProjectSettingsBuilder.ComputeSettings(kind)); }
//--------------------------------------------------------------------- public void RunCoverage(ProjectSelectionKind kind) { this.RunCommand(mainWindowsManager => mainWindowsManager.RunCoverage(kind) ); }
//--------------------------------------------------------------------- public void OpenSettingsWindow(ProjectSelectionKind kind) { this.RunCommand(mainWindowsManager => mainWindowsManager.OpenSettingsWindow(kind) ); }
//--------------------------------------------------------------------- public void RunCoverage(ProjectSelectionKind kind) { var window = ConfigureSettingsWindows(kind, false); window.Controller.RunCoverageCommand.Execute(null); }