public async Task InitializeProjectFromDiskAsync() { await Project.CreateInMemoryImport(); _fileWatcher.Start(); await _threadHandling.SwitchToUIThread(); // Make sure R package is loaded VsAppShell.EnsurePackageLoaded(RGuidList.RPackageGuid); // Verify project is not on a network share and give warning if it is CheckRemoteDrive(_projectDirectory); _workflow = _workflowProvider.GetOrCreate(); _session = _workflow.RSession; _history = _workflow.History; if (_workflow.ActiveWindow == null) { var window = await _workflow.GetOrCreateVisualComponent(_componentContainerFactory); window.Container.Show(true); } try { await _session.HostStarted; } catch (Exception) { return; } // TODO: need to compute the proper paths for remote, but they might not even exist if the project hasn't been deployed. // https://github.com/Microsoft/RTVS/issues/2223 if (!_session.IsRemote) { var rdataPath = Path.Combine(_projectDirectory, DefaultRDataName); bool loadDefaultWorkspace = _fileSystem.FileExists(rdataPath) && await GetLoadDefaultWorkspace(rdataPath); using (var evaluation = await _session.BeginEvaluationAsync()) { if (loadDefaultWorkspace) { await evaluation.LoadWorkspaceAsync(rdataPath); } await evaluation.SetWorkingDirectoryAsync(_projectDirectory); } _toolsSettings.WorkingDirectory = _projectDirectory; } _history.TryLoadFromFile(Path.Combine(_projectDirectory, DefaultRHistoryName)); CheckSurveyNews(); }
public override CommandResult Invoke(Guid group, int id, object inputArg, ref object outputArg) { var initialPath = RToolsSettings.Current.WorkingDirectory != null?PathHelper.EnsureTrailingSlash(RToolsSettings.Current.WorkingDirectory) : null; var file = _appShell.BrowseForFileOpen(IntPtr.Zero, Resources.HistoryFileFilter, initialPath, Resources.LoadHistoryTitle); if (file != null) { _history.TryLoadFromFile(file); } return(CommandResult.Executed); }
public override CommandResult Invoke(Guid group, int id, object inputArg, ref object outputArg) { var settings = _interactiveWorkflow.Shell.GetService <IRSettings>(); var initialPath = settings.WorkingDirectory != null?PathHelper.EnsureTrailingSlash(settings.WorkingDirectory) : null; var file = _interactiveWorkflow.Shell.FileDialog().ShowOpenFileDialog(Resources.HistoryFileFilter, initialPath, Resources.LoadHistoryTitle); if (file != null) { _history.TryLoadFromFile(file); } return(CommandResult.Executed); }
public async Task InitializeProjectFromDiskAsync() { await Project.CreateInMemoryImport(); _fileWatcher.Start(); // Force REPL window up and continue only when it is shown await _threadHandling.SwitchToUIThread(); // Make sure R package is loaded VsAppShell.EnsurePackageLoaded(RGuidList.RPackageGuid); // Verify project is not on a network share and give warning if it is CheckRemoteDrive(_projectDirectory); _workflow = _workflowProvider.GetOrCreate(); _session = _workflow.RSession; _history = _workflow.History; if (_workflow.ActiveWindow == null) { var window = await _workflow.GetOrCreateVisualComponent(_componentContainerFactory); window.Container.Show(true); } try { await _session.HostStarted; } catch (Exception) { return; } var rdataPath = Path.Combine(_projectDirectory, DefaultRDataName); bool loadDefaultWorkspace = _fileSystem.FileExists(rdataPath) && await GetLoadDefaultWorkspace(rdataPath); using (var evaluation = await _session.BeginEvaluationAsync()) { if (loadDefaultWorkspace) { await evaluation.LoadWorkspace(rdataPath); } await evaluation.SetWorkingDirectory(_projectDirectory); } _toolsSettings.WorkingDirectory = _projectDirectory; _history.TryLoadFromFile(Path.Combine(_projectDirectory, DefaultRHistoryName)); CheckSurveyNews(); }
public async Task InitializeProjectFromDiskAsync() { await Project.CreateInMemoryImport(); _fileWatcher.Start(); await _threadHandling.SwitchToUIThread(); // Make sure R package is loaded VsAppShell.EnsurePackageLoaded(RGuidList.RPackageGuid); // Verify project is not on a network share and give warning if it is CheckRemoteDrive(_projectDirectory); _workflow = _workflowProvider.GetOrCreate(); _session = _workflow.RSession; _history = _workflow.History; if (_workflow.ActiveWindow == null) { var window = await _workflow.GetOrCreateVisualComponentAsync(); window.Container.Show(focus: true, immediate: false); } try { await _session.HostStarted; } catch (Exception) { return; } // TODO: need to compute the proper paths for remote, but they might not even exist if the project hasn't been deployed. // https://github.com/Microsoft/RTVS/issues/2223 if (!_session.IsRemote) { var rdataPath = Path.Combine(_projectDirectory, DefaultRDataName); bool loadDefaultWorkspace = _coreShell.Services.FileSystem.FileExists(rdataPath) && await GetLoadDefaultWorkspace(rdataPath); if (loadDefaultWorkspace) { await _session.LoadWorkspaceAsync(rdataPath); } await _session.SetWorkingDirectoryAsync(_projectDirectory); _toolsSettings.WorkingDirectory = _projectDirectory; } _history.TryLoadFromFile(Path.Combine(_projectDirectory, DefaultRHistoryName)); CheckSurveyNews(); }
public async Task InitializeProjectFromDiskAsync() { await Project.CreateInMemoryImport(); _fileWatcher.Start(); // Force REPL window up and continue only when it is shown await _threadHandling.SwitchToUIThread(); // Make sure R package is loaded VsAppShell.EnsurePackageLoaded(RGuidList.RPackageGuid); // Verify project is not on a network share and give warning if it is CheckRemoteDrive(_projectDirectory); _workflow = _workflowProvider.GetOrCreate(); _session = _workflow.RSession; _history = _workflow.History; if (_workflow.ActiveWindow == null) { var window = await _workflow.GetOrCreateVisualComponent(_componentContainerFactory); window.Container.Show(true); } try { await _session.HostStarted; } catch (Exception) { return; } var rdataPath = Path.Combine(_projectDirectory, DefaultRDataName); bool loadDefaultWorkspace = _fileSystem.FileExists(rdataPath) && await GetLoadDefaultWorkspace(rdataPath); using (var evaluation = await _session.BeginEvaluationAsync()) { if (loadDefaultWorkspace) { await evaluation.LoadWorkspace(rdataPath); } await evaluation.SetWorkingDirectory(_projectDirectory); } _toolsSettings.WorkingDirectory = _projectDirectory; _history.TryLoadFromFile(Path.Combine(_projectDirectory, DefaultRHistoryName)); }