public void WhenNoProjectsLoaded_ThenRootNodeIsEmptyAndProjectPickerOpens() { var projectPicker = new Mock <IProjectPickerDialog>(); projectPicker.Setup(p => p.SelectProjectId(It.IsAny <IWin32Window>())).Returns((string)null); this.serviceRegistry.AddSingleton <IProjectPickerDialog>(projectPicker.Object); this.serviceRegistry.AddMock <IComputeEngineAdapter>(); // Open window. var window = new ProjectExplorerWindow(this.serviceProvider); window.ShowWindow(); PumpWindowMessages(); // Check tree. var rootNode = GetRootNode(window); Assert.IsInstanceOf(typeof(CloudNode), rootNode); Assert.AreEqual(0, rootNode.Nodes.Count); // Check picker projectPicker.Verify(p => p.SelectProjectId(It.IsAny <IWin32Window>()), Times.Once); Assert.IsNull(this.ExceptionShown); }
public bool CloseProject() { if (SaveAllInProject() == 2) { return(false); } BottomTabsVisible = true; ProjectUserOptionsManager.SaveOptions(ProjectFactory.Instance.CurrentProject.Path); CloseProjectFiles(); ProjectFactory.Instance.CloseProject(); ProjectExplorerWindow.Clear(); HideContent(ProjectExplorerWindow); HideContent(PropertiesWindow); if (ToolBoxWindow != null) { HideContent(ToolBoxWindow); } this.miProjectExplorer.Visible = false; CodeFileDocumentControl tmp = CurrentCodeFileDocument; //CloseAllButThis(CurrentCodeFileDocument); RestoreFiles(); RestoreWatch(); //CloseFile(tmp, false); WorkbenchServiceFactory.BuildService.CompilerOptions.ProjectCompiled = false; mrDesigner.Visible = false; miCloseProject.Visible = false; this.mRPROJECTToolStripMenuItem.Visible = false; CodeCompletion.CodeCompletionController.comp.CompilerOptions.CurrentProject = null; return(true); }
public void WhenProjectAdded_ThenLinuxInstancesAndInstancesWithoutDiskAreIgnored() { // Add a project. this.serviceProvider.GetService <IProjectRepository>().AddProjectAsync("project-1").Wait(); // Add some instances. var instances = new[] { CreateInstance("windows", "antarctica1-a", true), CreateInstance("linux", "antarctica1-b", false), new Instance() { Id = 1, Name = "nodisk", Zone = "projects/-/zones/antarctica1-a", MachineType = "zones/-/machineTypes/n1-standard-1" } }; // Open window. var computeEngineAdapter = new Mock <IComputeEngineAdapter>(); this.serviceRegistry.AddSingleton <IComputeEngineAdapter>(computeEngineAdapter.Object); computeEngineAdapter .Setup(o => o.ListInstancesAsync("project-1", It.IsAny <CancellationToken>())) .Returns(Task.FromResult <IEnumerable <Instance> >(instances)); var window = new ProjectExplorerWindow(this.serviceProvider); window.ShowWindow(); PumpWindowMessages(); // Check tree. var rootNode = GetRootNode(window); Assert.IsInstanceOf(typeof(CloudNode), rootNode); Assert.AreEqual(1, rootNode.Nodes.Count); var projectNode = (ProjectNode)rootNode.FirstNode; Assert.AreEqual("project-1", projectNode.Text); Assert.AreEqual(1, projectNode.Nodes.Count); var zoneAnode = (ZoneNode)projectNode.FirstNode; Assert.AreEqual("antarctica1-a", zoneAnode.Text); Assert.AreEqual(1, zoneAnode.Nodes.Count); var vmNode = (VmInstanceNode)zoneAnode.FirstNode; Assert.AreEqual(0, vmNode.Nodes.Count); Assert.AreEqual("windows", vmNode.Text); Assert.IsNull(this.ExceptionShown); }
private Container ConfigureDependencyInjection(ProjectExplorerWindow mainWindow) { Container container = new Container(); var components = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsClass && Attribute.IsDefined(t, typeof(Component))); foreach (var component in components) { container.Register(component, component, Lifestyle.Singleton); } container.RegisterInstance(typeof(ProjectExplorerWindow), mainWindow); container.RegisterInstance(typeof(ApplicationConfig), this); return(container); }
public void WhenProjectAdded_ThenLinuxInstancesAreListed() { // Add a project. this.serviceProvider.GetService <IProjectRepository>().AddProjectAsync("project-1").Wait(); // Add some instances. var instances = new[] { CreateInstance("windows", "antarctica1-a", true), CreateInstance("linux", "antarctica1-b", false) }; // Open window. var computeEngineAdapter = new Mock <IComputeEngineAdapter>(); this.serviceRegistry.AddSingleton <IComputeEngineAdapter>(computeEngineAdapter.Object); computeEngineAdapter .Setup(o => o.ListInstancesAsync("project-1", It.IsAny <CancellationToken>())) .Returns(Task.FromResult <IEnumerable <Instance> >(instances)); var window = new ProjectExplorerWindow(this.serviceProvider); window.ShowWindow(); Delay(TimeSpan.FromMilliseconds(100)); // Check tree. var rootNode = GetRootNode(window); Assert.IsInstanceOf(typeof(CloudNode), rootNode); Assert.AreEqual(1, rootNode.Nodes.Count); var projectNode = (ProjectNode)rootNode.FirstNode; Assert.AreEqual("project-1", projectNode.Text); Assert.AreEqual(2, projectNode.Nodes.Count); var zoneAnode = (ZoneNode)projectNode.FirstNode; Assert.AreEqual("antarctica1-a", zoneAnode.Text); Assert.AreEqual(1, zoneAnode.Nodes.Count); var zoneBnode = (ZoneNode)projectNode.LastNode; Assert.AreEqual("antarctica1-b", zoneBnode.Text); Assert.AreEqual(1, zoneBnode.Nodes.Count); Assert.AreEqual("windows", ((VmInstanceNode)zoneAnode.FirstNode).Text); Assert.AreEqual("linux", ((VmInstanceNode)zoneBnode.FirstNode).Text); Assert.IsNull(this.ExceptionShown); }
public void Execute(object parameter) { if (ViewModel.LoadedProject != null) { MessageBox.Show("You currently have a project open. To avoid losing any changes made please use the 'Close' button first.", "Load new project", MessageBoxButton.OK); } else { ProjectExplorerWindow projectExplorer = new ProjectExplorerWindow(); projectExplorer.Owner = App.Current.MainWindow; projectExplorer.WindowStartupLocation = WindowStartupLocation.CenterOwner; projectExplorer.ShowDialog(); } }
public void WhenProjectAdded_ThenWindowsInstancesAreListed() { // Add a project. this.serviceProvider.GetService <ProjectInventoryService>().AddProjectAsync("project-1").Wait(); // Add some instances. var instances = new[] { CreateInstance("instance-1a", "antarctica1-a", true), CreateInstance("instance-1b", "antarctica1-b", true) }; // Open window. var computeEngineAdapter = new Mock <IComputeEngineAdapter>(); this.serviceRegistry.AddSingleton <IComputeEngineAdapter>(computeEngineAdapter.Object); computeEngineAdapter .Setup(o => o.QueryInstancesAsync("project-1")) .Returns(Task.FromResult <IEnumerable <Instance> >(instances)); var window = new ProjectExplorerWindow(this.serviceProvider); window.ShowWindow(); PumpWindowMessages(); // Check tree. var rootNode = GetRootNode(window); Assert.IsInstanceOf(typeof(CloudNode), rootNode); Assert.AreEqual(1, rootNode.Nodes.Count); var projectNode = (ProjectNode)rootNode.FirstNode; Assert.AreEqual("project-1", projectNode.Text); Assert.AreEqual(2, projectNode.Nodes.Count); var zoneAnode = (ZoneNode)projectNode.FirstNode; Assert.AreEqual("antarctica1-a", zoneAnode.Text); Assert.AreEqual(1, zoneAnode.Nodes.Count); var vmNode = (VmInstanceNode)zoneAnode.FirstNode; Assert.AreEqual("instance-1a", vmNode.Text); Assert.AreEqual(0, vmNode.Nodes.Count); Assert.IsNull(this.ExceptionShown); }
public HResult Show() { try { if (_window == null) { _window = (ProjectExplorerWindow)_package.CreateToolWindow(typeof(ProjectExplorerWindow)); } return(_window.Frame.Show()); } catch (Exception ex) { return(ErrorUtil.GetHResult(ex)); } }
public void NewProject() { NewProjectForm npf = new NewProjectForm(); Form1StringResources.SetTextForAllControls(npf); if (npf.ShowDialog() == DialogResult.OK) { if (ProjectFactory.Instance.ProjectLoaded) { if (!CloseProject()) { return; } } PascalABCCompiler.IProjectInfo proj = ProjectFactory.Instance.CreateProject(npf.ProjectName, npf.ProjectFileName, npf.ProjectType); ProjectExplorerWindow.LoadProject(npf.ProjectName, ProjectFactory.Instance.CurrentProject); ProjectExplorerWindow.Show(); //ShowContent(ProjectExplorerWindow,true); CloseFilesAndSaveState(); ClearAndSaveWatch(); SelectContent(ProjectExplorerWindow, false); WorkbenchServiceFactory.FileService.OpenFile(proj.MainFile, null); ActiveCodeFileDocument = CurrentCodeFileDocument; AddLastProject(npf.ProjectFileName); if (CodeCompletion.CodeCompletionController.comp != null) { CodeCompletion.CodeCompletionController.comp.CompilerOptions.CurrentProject = proj; } this.mRPROJECTToolStripMenuItem.Visible = true; this.miCloseProject.Visible = true; if (proj.ProjectType == PascalABCCompiler.ProjectType.WindowsApp) { //string s = ProjectFactory.Instance.GetFullUnitFileName(); //OpenFile(null,s); //CurrentCodeFileDocument.AddDesigner(null); ProjectTask.NewForm(ProjectExplorerWindow, false);//roman// GenerateMainProgramForDesigner(proj.MainFile); //OpenFile(s,null); //SaveFileAs(CurrentCodeFileDocument,s); //CurrentCodeFileDocument.DesignerAndCodeTabs.SelectedTab = CurrentCodeFileDocument.DesignerPage; //ProjectTask.AddFile(ProjectExplorerWindow,Path.GetFileName(s)); SaveAll(false); } } }
public void WhenQueryInstanceFails_ProjectIsShownAsEmpty() { // Add a project. this.serviceProvider.GetService <IProjectRepository>().AddProjectAsync("valid-project").Wait(); this.serviceProvider.GetService <IProjectRepository>().AddProjectAsync("forbidden-project").Wait(); // Add some instances to project-1. var instances = new[] { CreateInstance("windows", "antarctica1-a", true) }; // Open window. var computeEngineAdapter = new Mock <IComputeEngineAdapter>(); this.serviceRegistry.AddSingleton <IComputeEngineAdapter>(computeEngineAdapter.Object); computeEngineAdapter .Setup(o => o.ListInstancesAsync("valid-project", It.IsAny <CancellationToken>())) .Returns(Task.FromResult <IEnumerable <Instance> >(instances)); computeEngineAdapter .Setup(o => o.ListInstancesAsync("forbidden-project", It.IsAny <CancellationToken>())) .Throws(new AdapterException("Access denied or something", null)); var window = new ProjectExplorerWindow(this.serviceProvider); window.ShowWindow(); PumpWindowMessages(); // Check tree. var rootNode = GetRootNode(window); Assert.AreEqual(2, rootNode.Nodes.Cast <ProjectNode>().Count()); var projectNode = rootNode.Nodes.Cast <ProjectNode>() .Where(n => n.ProjectId == "forbidden-project") .FirstOrDefault();; Assert.AreEqual(0, projectNode.Nodes.Count); }
private static TreeNode GetRootNode(ProjectExplorerWindow window) { var tree = window.GetChild <TreeView>("treeView"); return(tree.Nodes.Cast <TreeNode>().First()); }
public OpenBuiltinContextMenuCommand(ProjectExplorerWindow projectExplorerWindow, FilesPatternProvider filesPatternProvider, IseIntegrator iseIntegrator) { this.projectExplorerWindow = projectExplorerWindow; this.filesPatternProvider = filesPatternProvider; this.iseIntegrator = iseIntegrator; }
public void OpenProject(string projectFileName) { if (!File.Exists(projectFileName)) { MessageBox.Show(string.Format(PascalABCCompiler.StringResources.Get("!PROJECT_NOT_FOUND{0}"), projectFileName), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (ProjectFactory.Instance.ProjectLoaded) { CloseProject(); } try { PascalABCCompiler.IProjectInfo proj = ProjectFactory.Instance.OpenProject(projectFileName); ProjectExplorerWindow.LoadProject(Path.GetFileNameWithoutExtension(projectFileName), ProjectFactory.Instance.CurrentProject); ICSharpCode.FormsDesigner.ToolboxProvider.ReloadSideTabs(false); CloseFilesAndSaveState(); ClearAndSaveWatch(); this.miProjectExplorer.Visible = true; ShowContent(ProjectExplorerWindow, false); UserProjectSettings setts = ProjectUserOptionsManager.LoadOptions(projectFileName); foreach (IReferenceInfo ri in ProjectFactory.Instance.CurrentProject.References) { var path = Compiler.get_assembly_path(Path.Combine(ProjectFactory.Instance.ProjectDirectory, ri.FullAssemblyName), false); if (path == null) { path = Compiler.get_assembly_path(ri.FullAssemblyName, false); } ICSharpCode.FormsDesigner.ToolboxProvider.AddComponentsFromAssembly(PascalABCCompiler.NetHelper.NetHelper.LoadAssembly(path)); } if (setts != null) { foreach (OpenedFileInfo fi in setts.OpenDocuments) { if (fi.InProject) { string f = Path.Combine(proj.ProjectDirectory, fi.FileName); if (File.Exists(f)) { WorkbenchServiceFactory.FileService.OpenFile(f, null); } } else if (File.Exists(fi.FileName)) { WorkbenchServiceFactory.FileService.OpenFile(fi.FileName, null); } if (fi.CaretLine > 0) { CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.Caret.Line = fi.CaretLine; } if (fi.CaretColumn > 0) { CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.Caret.Column = fi.CaretColumn; } } if (!string.IsNullOrEmpty(setts.CurrentDocument)) { if (!setts.CurrentDocumentIsInProject) { if (File.Exists(setts.CurrentDocument)) { WorkbenchServiceFactory.FileService.OpenFile(setts.CurrentDocument, null); } } else { string f = Path.Combine(proj.ProjectDirectory, setts.CurrentDocument); if (File.Exists(f)) { WorkbenchServiceFactory.FileService.OpenFile(f, null); } } } else { WorkbenchServiceFactory.FileService.OpenFile(proj.MainFile, null); } foreach (WatchExprInfo wi in setts.WatchExprs) { AddVariable(wi.Expression, false); } } else { WorkbenchServiceFactory.FileService.OpenFile(proj.MainFile, null); } ActiveCodeFileDocument = CurrentCodeFileDocument; AddLastProject(projectFileName); if (CodeCompletion.CodeCompletionController.comp != null) { CodeCompletion.CodeCompletionController.comp.CompilerOptions.CurrentProject = proj; } this.mRPROJECTToolStripMenuItem.Visible = true; this.miCloseProject.Visible = true; } catch (PascalABCCompiler.TooOldProjectFileVersion) { MessageBox.Show(Form1StringResources.Get("TOO_OLD_PROJECT_FILE_VERSION"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(Form1StringResources.Get("ERROR_OPEN_PROJECT"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public SelectItemCommand(ProjectExplorerWindow projectExplorerWindow) { this.projectExplorerWindow = projectExplorerWindow; }
public LocateFileInTreeCommand(ProjectExplorerWindow projectExplorerWindow, IseIntegrator iseIntegrator, TreeViewModel treeViewModel) { this.projectExplorerWindow = projectExplorerWindow; this.iseIntegrator = iseIntegrator; this.treeViewModel = treeViewModel; }
public TreeViewModel(IconProvider iconProvider, ProjectExplorerWindow projectExplorerWindow) { this.itemsMap = new Dictionary <string, TreeViewEntryItemModel>(); this.iconProvider = iconProvider; this.projectExplorerWindow = projectExplorerWindow; }
public FindInFilesCommand(MainViewModel mainViewModel, ProjectExplorerWindow projectExplorerWindow) { this.mainViewModel = mainViewModel; this.projectExplorerWindow = projectExplorerWindow; }
public void ConfigureApplication(ProjectExplorerWindow mainWindow) { this.ConfigureLogging(); this.container = this.ConfigureDependencyInjection(mainWindow); Application.Current.Dispatcher.UnhandledException += DispatcherUnhandledExceptionHandler; }
public OpenBuiltinContextMenuCommand(ProjectExplorerWindow projectExplorerWindow) { this.projectExplorerWindow = projectExplorerWindow; }
public CollapseAllCommand(ProjectExplorerWindow projectExplorerWindow) { this.projectExplorerWindow = projectExplorerWindow; }
public TreeViewModel(IconProvider iconProvider, ProjectExplorerWindow projectExplorerWindow) { this.itemsMap = new Dictionary<string, TreeViewEntryItemModel>(); this.iconProvider = iconProvider; this.projectExplorerWindow = projectExplorerWindow; }