private void radMenuItem13_Click(object sender, EventArgs e) { var np = new NewItemDialog(); if (np.ShowDialog() == System.Windows.Forms.DialogResult.OK) { var f = new File(); f.Name = np.Filename; f.Src = np.Filename; f.ID = np.Type; Workspace.SelectedProject.Files.Add(f); radTreeView1.Nodes.Clear(); radTreeView1.Nodes.Add(SolutionExplorer.Build(Workspace.Solution)); Workspace.Solution.Save(Workspace.SolutionPath); var p = np.Template; var editor = EditorBuilder.Build(p.Extension, null, null, null); var doc = new DocumentWindow(f.Name); doc.Controls.Add(editor); radDock1.AddDocument(doc); } }
public void AddNewItem() { using (var app = new VisualStudioApp()) { // close any projects before switching source control... app.Dte.Solution.Close(); app.SelectSourceControlProvider("Test Source Provider"); foreach (var projectType in ProjectTypes) { var testDef = SourceControlProject(projectType); using (var solution = testDef.Generate()) { TestSccProvider.DocumentEvents.Clear(); var project = app.OpenProject(solution.Filename, onDialog: OnNoSccDialog); var fileName = "NewFile" + projectType.CodeExtension; using (var newItem = NewItemDialog.FromDte(app)) { newItem.FileName = fileName; newItem.OK(); } System.Threading.Thread.Sleep(250); Assert.IsNotNull(project.ProjectItems.Item(fileName)); AssertDocumentEvents(Path.GetDirectoryName(project.FullName), OnQueryAddFiles(fileName), OnAfterAddFilesEx(fileName) ); } } } }
public void StartNewApp(PythonVisualStudioApp app, DjangoInterpreterSetter interpreterSetter) { var project = app.CreateProject( PythonVisualStudioApp.TemplateLanguageName, PythonVisualStudioApp.DjangoWebProjectTemplate, TestData.GetTempPath(), "StartNewApp" ); app.SolutionExplorerTreeView.SelectProject(project); using (var newAppDialog = NewAppDialog.FromDte(app)) { newAppDialog.AppName = "Fob"; newAppDialog.OK(); } app.SolutionExplorerTreeView.WaitForItem( app.Dte.Solution.FullName, app.Dte.Solution.Projects.Item(1).Name, "Fob", "models.py" ); var appFolder = project.ProjectItems.Item("Fob"); Assert.IsNotNull(appFolder.ProjectItems.Item("models.py")); Assert.IsNotNull(appFolder.ProjectItems.Item("tests.py")); Assert.IsNotNull(appFolder.ProjectItems.Item("views.py")); Assert.IsNotNull(appFolder.ProjectItems.Item("__init__.py")); var templatesFolder = appFolder.ProjectItems.Item("templates"); var templatesAppFolder = templatesFolder.ProjectItems.Item("Fob"); Assert.IsNotNull(templatesAppFolder.ProjectItems.Item("index.html")); app.SolutionExplorerTreeView.SelectProject(project); app.Dte.ExecuteCommand("Project.DjangoCheckDjango17"); using (var console = app.GetInteractiveWindow("Django Management Console - " + project.Name)) { Assert.IsNotNull(console); console.WaitForTextEnd("The interactive Python process has exited.", ">"); var consoleText = console.TextView.TextSnapshot.GetText(); AssertUtil.Contains(consoleText, "Executing manage.py check"); AssertUtil.Contains(consoleText, "System check identified no issues (0 silenced)."); } app.SolutionExplorerTreeView.SelectProject(project); using (var newItem = NewItemDialog.FromDte(app)) { var htmlPage = newItem.ProjectTypes.FindItem("HTML Page"); htmlPage.Select(); newItem.FileName = "NewPage.html"; newItem.OK(); } System.Threading.Thread.Sleep(1000); Assert.IsNotNull(project.ProjectItems.Item("NewPage.html")); }
private void radMenuItem13_Click(object sender, EventArgs e) { var np = new NewItemDialog(); if (np.ShowDialog() == System.Windows.Forms.DialogResult.OK) { var f = new Core.ProjectSystem.File(); f.Name = np.Filename; f.Src = np.Filename; f.ID = np.Type; Workspace.SelectedProject.Files.Add(f); explorerTreeView.Nodes.Clear(); explorerTreeView.Nodes.Add(SolutionExplorer.Build(Workspace.Solution, solutionContextMenu, projectContextMenu, fileContextMenu)); Workspace.Solution.Save(Workspace.SolutionPath); var fi = new FileInfo(Workspace.SolutionPath).Directory.FullName + "\\" + f.Name; System.IO.File.WriteAllBytes(fi, np.Template.Raw); np.Plugin.Events.Fire("OnCreateItem", f, np.Template.Raw); var doc = new DocumentWindow(f.Name); doc.Controls.Add(ViewSelector.Select(np.Template, System.IO.File.ReadAllBytes(fi), f, np.Template.AutoCompletionProvider as IntellisenseProvider).GetView()); AddDocument(doc); } }
private static void ExecutedNewItemDialogCommand(object sender, ExecutedRoutedEventArgs e) { MainWindow _sender = FindWindow(sender); NewItemDialog dlg = new NewItemDialog(); dlg.Owner = _sender; if (dlg.ShowDialog() == true) { switch (dlg.EditType) { case EditType.Appointment: _sender.NewAppointment(); break; case EditType.Contact: _sender.NewContact(); break; case EditType.Task: _sender.NewTask(); break; case EditType.Note: _sender.NewNote(); break; default: break; } } }
public void StartNewApp() { using (var app = new PythonVisualStudioApp()) { var project = app.CreateProject( PythonVisualStudioApp.TemplateLanguageName, PythonVisualStudioApp.DjangoWebProjectTemplate, TestData.GetTempPath(), "StartNewApp" ); app.SolutionExplorerTreeView.SelectProject(project); using (var newAppDialog = NewAppDialog.FromDte(app)) { newAppDialog.AppName = "Fob"; newAppDialog.OK(); } app.SolutionExplorerTreeView.WaitForItem( app.Dte.Solution.FullName, app.Dte.Solution.Projects.Item(1).Name, "Fob", "models.py" ); var appFolder = project.ProjectItems.Item("Fob"); Assert.IsNotNull(appFolder.Collection.Item("models.py")); Assert.IsNotNull(appFolder.Collection.Item("tests.py")); Assert.IsNotNull(appFolder.Collection.Item("views.py")); Assert.IsNotNull(appFolder.Collection.Item("__init__.py")); app.SolutionExplorerTreeView.SelectProject(project); app.Dte.ExecuteCommand("Project.ValidateDjangoApp"); using (var console = app.GetInteractiveWindow("Django Management Console - " + project.Name)) { Assert.IsNotNull(console); console.WaitForTextEnd( "Executing manage.py validate", "0 errors found", "The Python REPL process has exited", ">" ); } app.SolutionExplorerTreeView.SelectProject(project); using (var newItem = NewItemDialog.FromDte(app)) { AutomationWrapper.Select(newItem.ProjectTypes.FindItem("HTML Page")); newItem.FileName = "NewPage.html"; newItem.OK(); } System.Threading.Thread.Sleep(1000); Assert.IsNotNull(project.ProjectItems.Item("NewPage.html")); } }
private void OnNewItem(object sender, EventArgs e) { NewItemDialog dialog = new NewItemDialog(); dialog.Response += delegate(object o, ResponseArgs args) { if (args.ResponseId == ResponseType.Ok) { addNewItem(new TodoItem(dialog.ItemText)); } }; dialog.Run(); dialog.Destroy(); }
public void AddItemPreviousSiblingNotVisible(PythonVisualStudioApp app) { var project = app.OpenProject(@"TestData\AddItemPreviousSiblingNotVisible.sln"); app.OpenSolutionExplorer(); var window = app.SolutionExplorerTreeView; var projectNode = window.WaitForItem("Solution 'AddItemPreviousSiblingNotVisible' (1 of 1 project)", "HelloWorld"); Assert.IsNotNull(projectNode); AutomationWrapper.Select(projectNode); var solutionService = app.GetService <IVsSolution>(typeof(SVsSolution)); Assert.IsNotNull(solutionService); IVsHierarchy selectedHierarchy; ErrorHandler.ThrowOnFailure(solutionService.GetProjectOfUniqueName(project.UniqueName, out selectedHierarchy)); Assert.IsNotNull(selectedHierarchy); HierarchyEvents events = new HierarchyEvents(); uint cookie; selectedHierarchy.AdviseHierarchyEvents(events, out cookie); using (var newItem = NewItemDialog.FromDte(app)) { var pythonFile = newItem.ProjectTypes.FindItem("Empty Python File"); pythonFile.Select(); newItem.FileName = "zmodule1.py"; newItem.OK(); } var test2 = window.WaitForItem("Solution 'AddItemPreviousSiblingNotVisible' (1 of 1 project)", "HelloWorld", "zmodule1.py"); Assert.IsNotNull(test2); selectedHierarchy.UnadviseHierarchyEvents(cookie); object caption; ErrorHandler.ThrowOnFailure( selectedHierarchy.GetProperty( events.SiblingPrev, (int)__VSHPROPID.VSHPROPID_Caption, out caption ) ); Assert.AreEqual("Program.py", caption); }
public void AddNewItem() { Window window; using (var app = new VisualStudioApp()) { var openFile = OpenProjectItem(app, "server.js", out window); using (var newItem = NewItemDialog.FromDte(app)) { newItem.FileName = "NewJSFile.js"; newItem.OK(); } System.Threading.Thread.Sleep(250); var solutionFolder = app.Dte.Solution.Projects.Item(1).ProjectItems; Assert.AreNotEqual(null, solutionFolder.Item("NewJSFile.js")); } }
public void AddNewItemLongPathTooLong() { using (var app = new VisualStudioApp()) { var project = OpenLongFileNameProject(app, 12); var window = app.OpenSolutionExplorer(); // find server.js, send copy & paste, verify copy of file is there var projectNode = window.WaitForItem("Solution 'LongFileNames' (1 project)", "LFN"); AutomationWrapper.Select(projectNode); using (var newItem = NewItemDialog.FromDte(app)) { newItem.FileName = "NewJSFile.js"; newItem.OK(); } VisualStudioApp.CheckMessageBox("The filename or extension is too long."); } }
public void CreateNewScript() { using (var app = new VisualStudioApp()) { var project = app.CreateProject( RConstants.TemplateLanguageName, RConstants.ProjectTemplate_EmptyProject, System.IO.Path.GetTempPath(), "RTestProject"); app.OpenSolutionExplorer().SelectProject(project); using (var newItem = NewItemDialog.FromDte(app)) { AutomationWrapper.Select(newItem.ProjectTypes.FindItem("R Script")); newItem.FileName = "my-script.r"; newItem.OK(); } var document = app.GetDocument("my-script.r"); document.SetFocus(); document.Type("2 -> a"); document.Text.Should().Be("2 -> a# R Script"); } }
public void AddNewItemLongPathBoundary() { using (var app = new VisualStudioApp()) { var project = OpenLongFileNameProject(app, 12); var window = app.OpenSolutionExplorer(); // find server.js, send copy & paste, verify copy of file is there var projectNode = window.WaitForItem("Solution 'LongFileNames' (1 project)", "LFN"); AutomationWrapper.Select(projectNode); using (var newItem = NewItemDialog.FromDte(app)) { newItem.FileName = "NewJSFil.js"; newItem.OK(); } Assert.IsNotNull(window.WaitForItem("Solution 'LongFileNames' (1 project)", "LFN", "NewJSFil.js")); Assert.IsTrue(File.Exists(Path.Combine(Path.GetDirectoryName(project.FullName), "LongFileNames", "NewJSFil.js"))); } }
public void AddNewFileOverwritingExistingFileNotInProject(PythonVisualStudioApp app) { var project = app.OpenProject(@"TestData\AddExistingItem.sln"); app.OpenSolutionExplorer().SelectProject(project); const string filename = "Program2.py"; using (var addItemDlg = NewItemDialog.FromDte(app)) { var pythonFile = addItemDlg.ProjectTypes.FindItem("Empty Python File"); pythonFile.Select(); addItemDlg.FileName = filename; addItemDlg.OK(); } app.CheckMessageBox( MessageBoxButton.Yes, "A file named", filename, "already exists. Do you want to overwrite it?" ); app.OpenSolutionExplorer().WaitForChildOfProject(project, "Program2.py"); }
public void NewItem() { Application.EnableVisualStyles(); NewItemDialog dialog = new NewItemDialog(); Translator translator = new Translator("Dialogs.NewItems"); dialog.SetTemplateConfiguration(translator.GetString("SqlProjectItems")); DialogResult result = dialog.ShowDialog(); if (result == DialogResult.OK) { Console.WriteLine("Filename: [" + dialog.FileName + "]"); Console.WriteLine("Content: [" + dialog.TemplateContent + "]"); } else { Console.WriteLine("Dialog cancelled."); } }
public void AddNewTypeScriptItem() { using (var solution = Project("AddNewTypeScriptItem", Compile("server")).Generate().ToVs()) { var project = solution.WaitForItem("AddNewTypeScriptItem", "server.js"); AutomationWrapper.Select(project); using (var newItem = NewItemDialog.FromDte(solution.App)) { newItem.FileName = "NewTSFile.ts"; newItem.OK(); } using (AutoResetEvent buildDone = new AutoResetEvent(false)) { solution.App.Dte.Events.BuildEvents.OnBuildDone += (sender, args) => { buildDone.Set(); }; solution.App.ExecuteCommand("Build.BuildSolution"); solution.App.WaitForOutputWindowText("Build", "tsc.exe"); Assert.IsTrue(buildDone.WaitOne(10000), "failed to wait for build)"); } } }
public void TestClientServerIntelliSenseModes() { string solutionLabel = "Solution 'ClientServerCode' (1 project)", projectLabel = "ClientServerCode", nodeDirectoryLabel = NodejsFolderNode.AppendLabel("NodeDirectory", FolderContentType.Node), nodeSubDirectoryLabel = NodejsFolderNode.AppendLabel("NodeSubDirectory", FolderContentType.Node), browserDirectoryLabel = NodejsFolderNode.AppendLabel("BrowserDirectory", FolderContentType.Browser), emptyBrowserSubDirectoryLabel = "BrowserSubDirectory", browserSubDirectoryLabel = NodejsFolderNode.AppendLabel("BrowserSubDirectory", FolderContentType.Browser), mixedDirectoryLabel = NodejsFolderNode.AppendLabel("MixedDirectory", FolderContentType.Mixed), mixedDirectoryBrowserDirectoryLabel = NodejsFolderNode.AppendLabel("BrowserDirectory", FolderContentType.Browser), mixedDirectoryNodeDirectoryLabel = NodejsFolderNode.AppendLabel("NodeDirectory", FolderContentType.Node), browserCodeLabel = "browserCode.js", mixedDirectoryRenamedLabel = NodejsFolderNode.AppendLabel("MixedDirectoryRenamed", FolderContentType.Mixed); using (var app = new VisualStudioApp()) { var project = app.OpenProject(@"TestData\ClientServerCode\ClientServerCode.sln"); using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", true)) { // Wait until project is loaded var solutionExplorer = app.OpenSolutionExplorer(); solutionExplorer.WaitForItem( solutionLabel, projectLabel, "app.js"); var nodejsProject = app.GetProject("ClientServerCode").GetNodejsProject(); var projectNode = solutionExplorer.WaitForItem( solutionLabel, projectLabel); var browserDirectory = solutionExplorer.WaitForItem( solutionLabel, projectLabel, browserDirectoryLabel ); Assert.IsNotNull( browserDirectory, "Browser directories should be labeled as such. Could not find " + browserDirectoryLabel); var browserSubDirectory = solutionExplorer.WaitForItem( solutionLabel, projectLabel, browserDirectoryLabel, emptyBrowserSubDirectoryLabel ); Assert.IsNotNull( browserSubDirectory, "Project initialization: could not find " + emptyBrowserSubDirectoryLabel); var nodeDirectory = solutionExplorer.WaitForItem( solutionLabel, projectLabel, nodeDirectoryLabel ); Assert.IsNotNull( nodeDirectory, "Node directories should be labeled as such. Could not find " + nodeDirectoryLabel); var nodeSubDirectory = solutionExplorer.WaitForItem( solutionLabel, projectLabel, nodeDirectoryLabel, nodeSubDirectoryLabel ); Assert.IsNotNull( nodeSubDirectory, "Project initialization: could not find " + nodeSubDirectoryLabel); projectNode.Select(); using (var newItem = NewItemDialog.FromDte(app)) { newItem.FileName = "newItem.js"; newItem.OK(); } Assert.AreEqual( "Compile", nodejsProject.GetItemType("newItem.js"), "Top level files should be set to item type 'Compile'"); Keyboard.Type("process."); Keyboard.Type(Keyboard.CtrlSpace.ToString()); using (var session = app.GetDocument(Path.Combine(nodejsProject.ProjectHome, @"newItem.js")).WaitForSession <ICompletionSession>()) { var completions = session.Session.CompletionSets.First().Completions.Select(x => x.InsertionText); Assert.IsTrue( completions.Contains("env"), "New documents of the node type should open with default VS editor" ); } browserSubDirectory.Select(); using (var newBrowserItem = NewItemDialog.FromDte(app)) { newBrowserItem.FileName = "newBrowserItem.js"; newBrowserItem.OK(); } Keyboard.Type("document."); System.Threading.Thread.Sleep(2000); Keyboard.Type(Keyboard.CtrlSpace.ToString()); using (var session = app.GetDocument(Path.Combine(nodejsProject.ProjectHome, @"BrowserDirectory\browserSubDirectory\newBrowserItem.js")).WaitForSession <ICompletionSession>()) { var completions = session.Session.CompletionSets.First().Completions.Select(x => x.InsertionText); Assert.IsTrue( completions.Contains("body"), "New documents of the browser type should open with default VS editor" ); } browserSubDirectory = solutionExplorer.WaitForItem( solutionLabel, projectLabel, browserDirectoryLabel, browserSubDirectoryLabel ); Assert.IsNotNull( browserSubDirectory, "Folder label was not updated to " + browserSubDirectoryLabel); var newBrowserItemFile = solutionExplorer.WaitForItem( solutionLabel, projectLabel, browserDirectoryLabel, browserSubDirectoryLabel, "newBrowserItem.js" ); Assert.AreEqual( "Content", nodejsProject.GetItemType(@"BrowserDirectory\BrowserSubDirectory\newBrowserItem.js"), "Adding a javascript file to a 'browser' directory should set the item type as Content."); var mixedDirectory = solutionExplorer.WaitForItem( solutionLabel, projectLabel, mixedDirectoryLabel ); Assert.IsNotNull( mixedDirectory, "Folder with mixed browser/node content should be specified as such. Could not find: " + mixedDirectoryLabel); nodeDirectory.Select(); using (var newTypeScriptItem = NewItemDialog.FromDte(app)) { newTypeScriptItem.FileName = "newTypeScriptItem.ts"; newTypeScriptItem.OK(); } Assert.AreEqual( "TypeScriptCompile", nodejsProject.GetItemType(@"NodeDirectory\newTypeScriptItem.ts"), "Non-javascript files should retain their content type."); var newBrowserItemNode = nodejsProject.FindNodeByFullPath( Path.Combine(nodejsProject.ProjectHome, @"BrowserDirectory\BrowserSubDirectory\newBrowserItem.js") ); newBrowserItemNode.ExcludeFromProject(); var excludedBrowserItem = solutionExplorer.WaitForItem( solutionLabel, projectLabel, browserDirectoryLabel, emptyBrowserSubDirectoryLabel ); Assert.IsNotNull( emptyBrowserSubDirectoryLabel, "Label should be removed when there are no included javascript files the directory. Could not find " + emptyBrowserSubDirectoryLabel); (newBrowserItemNode as NodejsFileNode).IncludeInProject(false); var includedBrowserItem = solutionExplorer.WaitForItem( solutionLabel, projectLabel, browserDirectoryLabel, browserSubDirectoryLabel ); Assert.IsNotNull( includedBrowserItem, "Label should be added when a javascript file is included in the directory. Could not find " + browserSubDirectoryLabel); var mixedDirectoryNode = app.GetProject("ClientServerCode").GetNodejsProject().FindNodeByFullPath( Path.Combine(nodejsProject.ProjectHome, @"MixedDirectory\")); System.Threading.Thread.Sleep(2000); mixedDirectory.Select(); Keyboard.PressAndRelease(Key.F2); Keyboard.Type("MixedDirectoryRenamed"); Keyboard.PressAndRelease(Key.Enter); mixedDirectoryNode.ExpandItem(EXPANDFLAGS.EXPF_ExpandFolderRecursively); var renamedMixedDirectory = solutionExplorer.WaitForItem( solutionLabel, projectLabel, mixedDirectoryRenamedLabel, mixedDirectoryBrowserDirectoryLabel, browserCodeLabel ); Assert.IsNotNull( renamedMixedDirectory, "Renaming mixed directory failed: could not find " + browserCodeLabel); newBrowserItemNode.ItemNode.ItemTypeName = "Compile"; var nodeBrowserSubDirectory = solutionExplorer.WaitForItem( solutionLabel, projectLabel, NodejsFolderNode.AppendLabel("BrowserDirectory", FolderContentType.Mixed), NodejsFolderNode.AppendLabel("BrowserSubDirectory", FolderContentType.Node) ); Assert.IsNotNull( nodeBrowserSubDirectory, "Changing the item type should change the directory label. Could not find " + NodejsFolderNode.AppendLabel("BrowserSubDirectory", FolderContentType.Node) ); var nodeDirectoryNode = app.GetProject("ClientServerCode").GetNodejsProject().FindNodeByFullPath( Path.Combine(app.GetProject("ClientServerCode").GetNodejsProject().ProjectHome, @"NodeDirectory\")); (nodeDirectoryNode as NodejsFolderNode).SetItemTypeRecursively(VSLangProj.prjBuildAction.prjBuildActionContent); Assert.AreEqual( "Content", nodejsProject.GetItemType(@"NodeDirectory\NodeSubDirectory\nodeCode.js"), "nodeCode.js file should be marked as content after recursively setting directory contents as Content." ); Assert.AreEqual( "TypeScriptCompile", nodejsProject.GetItemType(@"NodeDirectory\newTypeScriptItem.ts"), "Only javascript file item types should change when marking item types recursively." ); var fromPoint = solutionExplorer.WaitForItem( solutionLabel, projectLabel, mixedDirectoryRenamedLabel, mixedDirectoryNodeDirectoryLabel ).GetClickablePoint(); var toPoint = solutionExplorer.WaitForItem( solutionLabel, projectLabel, mixedDirectoryRenamedLabel, mixedDirectoryBrowserDirectoryLabel ).GetClickablePoint(); Mouse.MoveTo(fromPoint); Mouse.Down(MouseButton.Left); Mouse.MoveTo(toPoint); Mouse.Up(MouseButton.Left); var draggedDirectory = solutionExplorer.WaitForItem( solutionLabel, projectLabel, mixedDirectoryRenamedLabel, NodejsFolderNode.AppendLabel("BrowserDirectory", FolderContentType.Mixed), NodejsFolderNode.AppendLabel("NodeDirectory", FolderContentType.Node) ); Assert.IsNotNull( draggedDirectory, "Labels not properly updated after dragging and dropping directory." ); } } }