protected override void ShowAddEnvironmentDialog() { AddEnvironmentDialog.ShowAddCondaEnvironmentDialogAsync( Site, null, Workspace, MissingEnvName, EnvironmentYmlPath, null ).HandleAllExceptions(Site, typeof(CondaEnvCreateInfoBar)).DoNotWait(); }
protected override void ShowAddEnvironmentDialog() { AddEnvironmentDialog.ShowAddVirtualEnvironmentDialogAsync( Site, null, Workspace, null, null, RequirementsTxtPath ).HandleAllExceptions(Site, typeof(VirtualEnvCreateInfoBar)).DoNotWait(); }
public override void DoCommand(object sender, EventArgs args) { var service = _window._site.GetComponentModel().GetService <IInterpreterRegistryService>(); var sln = (IVsSolution)_window._site.GetService(typeof(SVsSolution)); var project = sln?.EnumerateLoadedPythonProjects().FirstOrDefault(); string ymlPath = project?.GetEnvironmentYmlPath(); string txtPath = project?.GetRequirementsTxtPath(); AddEnvironmentDialog.ShowAddEnvironmentDialogAsync(_window._site, project, null, ymlPath, txtPath) .HandleAllExceptions(_window._site, typeof(PythonProjectNode)).DoNotWait(); }
public Task InvokeAsync() { // We'll add support for open folder later // https://github.com/Microsoft/PTVS/issues/4852 var project = (_envSwitchMgr.Context as EnvironmentSwitcherProjectContext)?.Project; if (project == null) { var sln = (IVsSolution)_serviceProvider.GetService(typeof(SVsSolution)); project = sln?.EnumerateLoadedPythonProjects().FirstOrDefault(); } string ymlPath = project?.GetEnvironmentYmlPath(); string txtPath = project?.GetRequirementsTxtPath(); return(AddEnvironmentDialog.ShowAddEnvironmentDialogAsync(_serviceProvider, project, null, ymlPath, txtPath)); }
public static Task AddEnvironmentAsync(EnvironmentSwitcherManager envSwitchMgr, IServiceProvider serviceProvider, AddEnvironmentDialog.PageKind page) { var workspace = (envSwitchMgr.Context as EnvironmentSwitcherWorkspaceContext)?.Workspace; var project = (envSwitchMgr.Context as EnvironmentSwitcherProjectContext)?.Project; if (workspace == null && project == null) { var sln = (IVsSolution)serviceProvider.GetService(typeof(SVsSolution)); project = sln?.EnumerateLoadedPythonProjects().FirstOrDefault(); } return(AddEnvironmentDialog.ShowDialogAsync( page, serviceProvider, project, workspace, null, null, null )); }
public Task InvokeAsync() { var workspace = (_envSwitchMgr.Context as EnvironmentSwitcherWorkspaceContext)?.Workspace; var project = (_envSwitchMgr.Context as EnvironmentSwitcherProjectContext)?.Project; if (workspace == null && project == null) { var sln = (IVsSolution)_serviceProvider.GetService(typeof(SVsSolution)); project = sln?.EnumerateLoadedPythonProjects().FirstOrDefault(); } return(AddEnvironmentDialog.ShowDialogAsync( _page, _serviceProvider, project, workspace, null, null, null )); }
public override async Task CheckAsync() { if (IsCreated) { return; } if (!Project.Site.GetPythonToolsService().GeneralOptions.PromptForEnvCreate) { return; } var suppressProp = Project.GetProjectProperty(PythonConstants.SuppressEnvironmentCreationPrompt); if (suppressProp.IsTrue()) { return; } if (!Project.IsActiveInterpreterGlobalDefault) { return; } var txtPath = Project.GetRequirementsTxtPath(); if (!File.Exists(txtPath)) { return; } Action createVirtualEnv = () => { Logger?.LogEvent( PythonLogEvent.VirtualEnvCreateInfoBar, new VirtualEnvCreateInfoBarInfo() { Action = VirtualEnvCreateInfoBarActions.Create, } ); AddEnvironmentDialog.ShowAddVirtualEnvironmentDialogAsync( Project.Site, Project, null, null, txtPath ).HandleAllExceptions(Project.Site, typeof(VirtualEnvCreateInfoBar)).DoNotWait(); Close(); }; Action projectIgnore = () => { Logger?.LogEvent( PythonLogEvent.VirtualEnvCreateInfoBar, new VirtualEnvCreateInfoBarInfo() { Action = VirtualEnvCreateInfoBarActions.Ignore, } ); Project.SetProjectProperty(PythonConstants.SuppressEnvironmentCreationPrompt, true.ToString()); Close(); }; var messages = new List <IVsInfoBarTextSpan>(); var actions = new List <InfoBarActionItem>(); messages.Add(new InfoBarTextSpan( Strings.RequirementsTxtCreateVirtualEnvInfoBarMessage.FormatUI( PathUtils.GetFileOrDirectoryName(txtPath), Project.Caption ))); actions.Add(new InfoBarButton(Strings.RequirementsTxtInfoBarCreateVirtualEnvAction, createVirtualEnv)); actions.Add(new InfoBarButton(Strings.RequirementsTxtInfoBarProjectIgnoreAction, projectIgnore)); Logger?.LogEvent( PythonLogEvent.VirtualEnvCreateInfoBar, new VirtualEnvCreateInfoBarInfo() { Action = VirtualEnvCreateInfoBarActions.Prompt, } ); Create(new InfoBarModel(messages, actions, KnownMonikers.StatusInformation, isCloseButtonVisible: true)); }