//one of the test methods for debugging, running against //sqlcmd - due to bug in S2K5, where we hang wen executing //this method causes hang as well bool ExecStmt(string cmdText) { if (ow != null) { CreateOutputWindow("Debug"); } try { _app.StatusBar.Text = "Debug started"; string buildPath = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory(); buildPath = Path.Combine(buildPath, "MSBUILD.exe"); owp.OutputString("Debug Started\n"); System.Diagnostics.Process p = new System.Diagnostics.Process(); string sqlFile = ""; sqlFile = Path.Combine(ProjectPath, "sql.proj"); string paramString = string.Format("\"{0}\" /t:ExecDebug /p:CmdText=\"{1}\"", sqlFile, cmdText); p.StartInfo = new ProcessStartInfo(buildPath, paramString); p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = true; p.StartInfo.RedirectStandardOutput = true; p.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived); p.Start(); p.BeginOutputReadLine(); p.WaitForExit(); owp.Activate(); string statusMsg = "succeeded"; if (p.ExitCode != 0) { statusMsg = "failed"; } _app.StatusBar.Text = string.Format("Debug {0}", statusMsg); ow.Parent.Activate(); ow.Parent.AutoHides = true; return(true); } catch (Exception e) { _app.StatusBar.Text = "Debug failed"; string msg = string.Format("An unexpected exception occured.\n\nThe exception is: {0}", e.Message); owp.OutputString(msg); return(false); } finally { } }
private void Excute(object sender, EventArgs e) { _myOutPane.Activate(); _lstExcludePath = _dte.GetExcludePathList(); _count = 0; _selectedMenu = (PkgCmdIdList)((MenuCommand)sender).CommandID.ID; var table = new RunningDocumentTable(this); _lstAlreadyOpenFiles = table.Select(p => p.Moniker).ToList(); var selectedItem = _dte.SelectedItems.Item(1); WriteLog($"{Environment.NewLine}===================================================================================="); WriteLog($"Start: {DateTime.Now}"); var sp = new Stopwatch(); sp.Start(); //以下判断只会进一次 if (selectedItem.Project == null && selectedItem.ProjectItem == null) //从解决方案一级进来的 { ProcessSolution(); } else if (selectedItem.Project != null) //从项目一级进来的 { ProcessProject(selectedItem.Project); } else if (selectedItem.ProjectItem != null) //从文件夹一级或者文件一级进来的 { if (selectedItem.ProjectItem.ProjectItems.Count > 0) //此项下页还有文件,如:文件夹,T4模板 { ProcessProjectItem(selectedItem.ProjectItem); ProcessProjectItems(selectedItem.ProjectItem.ProjectItems); } else //此项下什么都没有了,直接处理 { ProcessProjectItem(selectedItem.ProjectItem); } } sp.Stop(); WriteLog($"Finish: {DateTime.Now} Files: {_count - 2} Elapsed: {sp.ElapsedMilliseconds / 1000}s"); _dte.ExecuteCommand("View.Output"); _myOutPane.Activate(); }
private void OnEventReady(object sender, EventArrivedEventArgs args) { //output to OutputWindow _DTE dteObj = (_DTE)GetNodeSite().GetService(typeof(_DTE)); if (outputPane == null) { OutputWindow ouputWindow = (OutputWindow)dteObj.Windows.Item(EnvDTE.Constants.vsWindowKindOutput).Object; outputPane = ouputWindow.OutputWindowPanes.Item("{1BD8A850-02D1-11d1-bee7-00a0c913d1f8}"); } dteObj.ExecuteCommand("View.Output", ""); outputPane.Activate(); outputPane.OutputString(FormEventString(args.NewEvent) + "\n"); //also, add a child node WMIInstanceNode eventNode = new WMIInstanceNode((ManagementObject)args.NewEvent, new ManagementClass(args.NewEvent.ClassPath.Path, null), this.connectAs, this.password); eventNodes.Add(eventNode); GetNodeSite().AddChild(eventNode); }
private void ActivateOutputWindow() { Window window = dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput); window.Activate(); owp.Activate(); }
static void InitializeVsPaneIfNeeded() { if (_outputWindowPane != null) { _outputWindowPane.Activate(); return; } var wnd = CodeRush.ApplicationObject.Windows.Item(Constants.vsWindowKindOutput); if (wnd == null) { return; } var outputWindow = wnd.Object as OutputWindow; if (outputWindow == null) { return; } try { _outputWindowPane = outputWindow.OutputWindowPanes.Item("XpandAddIns"); } catch { _outputWindowPane = outputWindow.OutputWindowPanes.Add("XpandAddIns"); } }
/// <summary> /// Validates configuration and performs analysis /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> protected override void CommandClicked(object sender, EventArgs e) { Configuration config = ConfigurationProvider.Load(); if (!ValidateConfiguration(config)) { return; } OutputWindowPane outputPane = CreatePane("Dexter"); outputPane.Clear(); outputPane.Activate(); System.Threading.Tasks.Task.Run(() => { dexter = new Dexter(config); DataReceivedEventHandler writeToOutputPane = (s, e1) => outputPane.OutputString(e1.Data + Environment.NewLine); dexter.OutputDataReceived += writeToOutputPane; dexter.ErrorDataReceived += writeToOutputPane; OnAnalysisStarted(EventArgs.Empty); Result result = dexter.Analyse(); OnAnalysisFinished(EventArgs.Empty); ReportResult(result); }); }
static public void PrintMessage(string from, string message, bool activate = false) { ThreadHelper.ThrowIfNotOnUIThread(); OutputWindowPane resultPane = null; if (panes.TryGetValue(from, out resultPane) == false) { DTE2 dte = (DTE2)Package.GetGlobalService(typeof(DTE)); OutputWindow outWindow = dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput).Object as OutputWindow; var activePane = outWindow.ActivePane; foreach (OutputWindowPane pane in outWindow.OutputWindowPanes) { if (pane.Name == from) { resultPane = pane; } } if (resultPane == null) { resultPane = outWindow.OutputWindowPanes.Add(from); } panes.Add(from, resultPane); if (!activate) { activePane.Activate(); } } resultPane.OutputString(message + "\n"); if (activate) { resultPane.Activate(); } }
private OutputWindowPane PrepareOutputWindowPane() { dte.ExecuteCommand("View.Output"); OutputWindow outputWindow = dte.ToolWindows.OutputWindow; OutputWindowPane outputWindowPane = null; foreach (OutputWindowPane pane in outputWindow.OutputWindowPanes) { if (pane.Name == "MonoTools") { outputWindowPane = pane; break; } } if (outputWindowPane == null) { outputWindowPane = outputWindow.OutputWindowPanes.Add("MonoTools"); } outputWindowPane.Activate(); outputWindowPane.Clear(); outputWindowPane.OutputString($"MonoTools {App.Version} © johnshope.com 2016\r\n"); return(outputWindowPane); }
private void OutputPaneShow() { ts.TraceData(TraceEventType.Verbose, 1, "OutputPaneShow"); _window.Activate(); _outputWindowPane.Activate(); Application.DoEvents(); }
internal void LogError(string statusMessage, Exception exception) { DebugCheck.NotEmpty(statusMessage); _dte2.StatusBar.Text = statusMessage; OutputWindowPane buildOutputWindow = _dte2.ToolWindows.OutputWindow.OutputWindowPanes.Cast <OutputWindowPane>().FirstOrDefault(p => p.Name == "Build" || p.Name == "生成"); if (buildOutputWindow == null) { return; } buildOutputWindow.OutputString(Environment.NewLine); var errorMessage = exception == null ? statusMessage : exception + Environment.NewLine; var edmSchemaErrorException = exception as EdmSchemaErrorException; if (edmSchemaErrorException != null) { errorMessage += edmSchemaErrorException.Message + Environment.NewLine; errorMessage += string.Join("", edmSchemaErrorException.Errors.Select(p => p + Environment.NewLine)); } var compilerErrorException = exception as CompilerErrorException; if (compilerErrorException != null) { errorMessage += compilerErrorException.Message + Environment.NewLine; errorMessage += string.Join("", compilerErrorException.Errors.Select(p => p + Environment.NewLine)); } buildOutputWindow.OutputString(errorMessage); buildOutputWindow.Activate(); }
public void Write(string text) { CreateOutputPane(Name); // Creates the OutputWindowPane if it does not already exist. if (_outputWindowPane != null) { try { _outputWindowPane.Activate(); _outputWindowPane.OutputString(text); } catch (Exception ex1) { System.Diagnostics.Debug.WriteLine("Exception writing text '" + text + "': " + ex1.ToString()); // Exceeded maximum output pane size? try { _outputWindowPane.Clear(); _outputWindowPane.OutputString(text); } catch (Exception ex2) { System.Diagnostics.Debug.WriteLine("Exception writing text '" + text + "': " + ex2.ToString()); } } } }
private void ProvisionProject(DTE2 dte, OutputWindowPane activePane, Project targetProject) { string classpathFile = Path.GetDirectoryName(targetProject.FullName) + "\\.classpath"; if (!File.Exists(classpathFile)) { activePane.Activate(); activePane.OutputString("File not found: .classpath. A provisioning build needs to complete successfully first\n"); return; } var doc = new XmlDocument(); doc.Load(classpathFile); var entries = doc.GetElementsByTagName("classpathentry"); // filter entries by kind = "lib" for (int i = 0; i < entries.Count; ++i) { var node = entries.Item(i); var path = node.Attributes["path"]; var type = node.Attributes["kind"]; if (path != null) { if (type != null && type.Value.Equals("lib")) { AddReferenceToProject(targetProject, path.Value.EndsWith(".jar") ? path.Value : path.Value + "/", activePane); } } } targetProject.Save(); }
private void LogActivity(string format, params object[] args) { string prefix = $"[{DateTime.Now.ToString("M/d/y h:mm:ss.FFF", CultureInfo.InvariantCulture)} RunCustomToolOnBuild] {format}"; _outputPane.Activate(); _outputPane.OutputString(string.Format(prefix, args) + Environment.NewLine); }
public static void WriteToOutputWindow(DTE dte, string message, bool clearBefore) { try { Window win = dte.Windows.Item("{34E76E81-EE4A-11D0-AE2E-00A0C90FFFC3}"); OutputWindow comwin = (OutputWindow)win.Object; if (OWP == null) { foreach (OutputWindowPane w in comwin.OutputWindowPanes) { if (w.Name == "SharePoint Solution Deployer (SPSD)") { OWP = w; } } } if (OWP == null) { OWP = comwin.OutputWindowPanes.Add("SharePoint Solution Deployer (SPSD)"); } if (clearBefore) { OWP.Clear(); } OWP.Activate(); Application.DoEvents(); OWP.OutputString(message + Environment.NewLine); OWP.ForceItemsToTaskList(); } catch (Exception) { } }
public DriverUI(DTE dte, Window outputWindow, OutputWindowPane pane) { _dte = dte; _outputWindow = outputWindow; _pane = pane; _buttonTag = Guid.NewGuid().ToString(); // http://stackoverflow.com/questions/12049362/programmatically-add-add-in-button-to-the-standard-toolbar // add a toolbar button to the standard toolbar var bar = ((CommandBars)_dte.CommandBars)["Standard"]; if (bar != null) { var control = (CommandBarButton)bar.Controls.Add(MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, true); control.Style = MsoButtonStyle.msoButtonIcon; control.TooltipText = BarButtonControlCaption; control.Caption = BarButtonControlCaption; control.Tag = _buttonTag; control.BeginGroup = true; control.Click += (CommandBarButton ctrl, ref bool d) => { _outputWindow.Visible = true; pane.Activate(); }; } else { Log.W("failed to add command button, no Standard command bar"); } updateUI(); }
private static OutputWindowPane PrepareOutputWindowPane(DTE2 dte) { dte.ExecuteCommand("View.Output"); OutputWindow outputWindow = dte.ToolWindows.OutputWindow; OutputWindowPane outputWindowPane = null; foreach (OutputWindowPane pane in outputWindow.OutputWindowPanes) { if (pane.Name == "MonoHelper") { outputWindowPane = pane; break; } } if (outputWindowPane == null) { outputWindowPane = outputWindow.OutputWindowPanes.Add("MonoHelper"); } outputWindowPane.Activate(); outputWindowPane.Clear(); outputWindowPane.OutputString("MonoHelper, Version 1.2\r\n"); outputWindowPane.OutputString("Copyright (C) Christopher Dresel 2015\r\n"); outputWindowPane.OutputString("\r\n"); return(outputWindowPane); }
/// <summary> /// Method for creating and writting to a debug window /// </summary> /// <param name="application"></param> /// <param name="message"></param> public void WriteToOutputWindow(DTE2 application, string message) { try { EnvDTE.Events events = application.Events; OutputWindow outputWindow = (OutputWindow)application.Windows.Item(Constants.vsWindowKindOutput).Object; // Find the "Test Pane" Output window pane; if it doesn't exist, // create it. OutputWindowPane pane = null; try { pane = outputWindow.OutputWindowPanes.Item("Format SQL"); } catch { pane = outputWindow.OutputWindowPanes.Add("Format SQL"); } // Show the Output window and activate the new pane. outputWindow.Parent.AutoHides = false; outputWindow.Parent.Activate(); pane.Activate(); // Add a line of text to the new pane. pane.OutputString(message + "\r\n"); } catch { //MessageBox.Show(message, "T-SQL Tidy Error"); } }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void Execute(object sender, EventArgs e) { // コマンドハンドラなので、メインのUIスレッドから呼ばれてるはずだけど、非同期でもいいのでとりあえず考慮しない方向で検討 ThreadHelper.ThrowIfNotOnUIThread(); if (dte == null) { return; } OutputWindowPane pane = null; var paneName = "ソリューションファイルのアップロード"; foreach (var obj in dte.ToolWindows.OutputWindow.OutputWindowPanes) { pane = obj as OutputWindowPane; if (pane.Name == paneName) { break; } pane = null; } if (pane == null) { pane = dte.ToolWindows.OutputWindow.OutputWindowPanes.Add(paneName); } // 中身を空にして、出力準備を行う pane.Clear(); pane.Activate(); dte.ToolWindows.OutputWindow.Parent.Activate(); // 同期処理でまずは、アイテム列挙 var uploadSln = ListupTargetFiles(dte, pane); // ここは行った先で非同期になる UploadSolution(uploadSln); }
public static void FocusOnLog() { if (_outputWindowPane != null) { _outputWindowPane.Activate(); } }
/// <summary> /// Activates given pane. /// </summary> public void Activate() { if (outputPane != null) { outputPane.Activate(); } }
/// <summary> /// Activates the message pane of the Qt VS Tools extension. /// </summary> public static void ActivateMessagePane() { if (wndp == null) { return; } wndp.Activate(); }
/// <summary>Logs the specified message.</summary> /// <param name="message">The message.</param> public void Log(string message) { ThreadHelper.ThrowIfNotOnUIThread(); outputPane?.Activate(); outputPane?.OutputString(Environment.NewLine); outputPane?.OutputString(message); }
public static void AddMessage(string message, string prefix = null) { OutputWindowPane?.OutputString($"{(string.IsNullOrWhiteSpace(prefix) ? "" : prefix + ": ")}{message}{(message.EndsWith("\n") ? "" : "\n")}"); if (prefix == ERROR || prefix == WARNING) { OutputWindowPane?.Activate(); } }
/// <summary>The trace logger.</summary> /// <param name="dte"></param> public TraceLogger(DTE dte) { this.dte = dte; outputPane = GetOutputPane(); outputPane.Activate(); Log("Successfuly created source control file selector logger"); }
/// <summary> /// Constructs the WebServer, starts the web server process. /// </summary> /// <param name="outputWindowPane">Existing output pane to send web server output to.</param> /// <param name="properties">PropertyManager that is set to a valid project/platform.</param> public WebServer(OutputWindowPane outputWindowPane, PropertyManager properties) { if (outputWindowPane == null) { throw new ArgumentNullException("outputWindowPane"); } if (properties == null) { throw new ArgumentNullException("properties"); } webServerOutputPane_ = outputWindowPane; // Read port from properties, if invalid port then set to default value. int webServerPort; if (!int.TryParse(properties.WebServerPort, out webServerPort)) { webServerPort = DefaultWebServerPort; } string webServerExecutable = "python.exe"; string httpd = Path.Combine(properties.SDKRootDirectory, "examples", "httpd.py"); if (!File.Exists(httpd)) { httpd = Path.Combine(properties.SDKRootDirectory, "tools", "httpd.py"); } string webServerArguments = httpd + " --no_dir_check " + webServerPort; webServerOutputPane_.Clear(); webServerOutputPane_.OutputString(Strings.WebServerStartMessage + "\n"); webServerOutputPane_.Activate(); // Start the web server process. try { webServer_ = new System.Diagnostics.Process(); webServer_.StartInfo.CreateNoWindow = true; webServer_.StartInfo.UseShellExecute = false; webServer_.StartInfo.RedirectStandardOutput = true; webServer_.StartInfo.RedirectStandardError = true; webServer_.StartInfo.FileName = webServerExecutable; webServer_.StartInfo.Arguments = webServerArguments; webServer_.StartInfo.WorkingDirectory = properties.ProjectDirectory; webServer_.OutputDataReceived += WebServerMessageReceive; webServer_.ErrorDataReceived += WebServerMessageReceive; webServer_.Start(); webServer_.BeginOutputReadLine(); webServer_.BeginErrorReadLine(); } catch (Exception e) { webServerOutputPane_.OutputString(Strings.WebServerStartFail + "\n"); webServerOutputPane_.OutputString("Exception: " + e.Message + "\n"); } }
private void ExecuteConversion(NetVertVsProject.NetVertExecutionEnum excuteFilter) { List <NetVertVsProject> TmpProjs; TmpProjs = GetEnabledProjects(excuteFilter); if (TmpProjs.Count > 0) { FOutputPane.Clear(); FOutputPane.Activate(); FOutputPane.OutputString("==== Start Conversion of " + TmpProjs.Count.ToString() + " Projects ====" + vbCrLf); //create new converters FConverterVBCS = new VSProjectFileConverter(ConverterLanguages.VBNetToCSharp); FConverterCSVB = new VSProjectFileConverter(ConverterLanguages.CSharpToVBNet); FConverterVBCS.AfterFileProcessed += NetVertConverter_AfterFileProcessed; FConverterCSVB.AfterFileProcessed += NetVertConverter_AfterFileProcessed; //convert all projects foreach (NetVertVsProject nvp in TmpProjs) { ConvertProject(nvp); } //output summary if (FConverterVBCS.TotalProjectsCount > 0) { FOutputPane.OutputString("--------------------------------------" + vbCrLf); FOutputPane.OutputString("Summary VB.NET -> C#" + vbCrLf); FOutputPane.OutputString(FConverterVBCS.SummaryText + vbCrLf); } if (FConverterCSVB.TotalProjectsCount > 0) { FOutputPane.OutputString("--------------------------------------" + vbCrLf); FOutputPane.OutputString("Summary C# -> VB.NET" + vbCrLf); FOutputPane.OutputString(FConverterCSVB.SummaryText + vbCrLf); } FOutputPane.OutputString("==== Finish ====" + vbCrLf); } else { if (excuteFilter == NetVertVsProject.NetVertExecutionEnum.OnlyManual) { FOutputPane.Clear(); FOutputPane.Activate(); FOutputPane.OutputString("==== No Projects are Enabled for Conversion ====" + vbCrLf); } } }
private void CreateOutputPane() { _outputPane = _outputPanes.Add("IvyVisual"); if (_outputPane != null) { _outputPane.Activate(); } }
public void Write(string message) { if (_pane != null) { _pane.Activate(); _pane.OutputString(message); _pane.OutputString("\n"); } }
public VsOutputPane() { _pane = GetOrCreatePane(Guid.Parse(TemplatesPaneGuid), true, false); if (_pane != null) { _pane.Activate(); } }
/// <summary> /// New Start Debug Command Events Before Execution Event Handler. Call the method responsible for building the app. /// </summary> /// <param name="Guid"> Command GUID. </param> /// <param name="ID"> Command ID. </param> /// <param name="CustomIn"> Custom IN Object. </param> /// <param name="CustomOut"> Custom OUT Object. </param> /// <param name="CancelDefault"> Cancel the default execution of the command. </param> private void startDebugCommandEvents_BeforeExecute(string Guid, int ID, object CustomIn, object CustomOut, ref bool CancelDefault) { bool bbPlatform = false; if (_dte.Solution.SolutionBuild.ActiveConfiguration != null) { SolutionContexts scCollection = _dte.Solution.SolutionBuild.ActiveConfiguration.SolutionContexts; foreach (SolutionContext sc in scCollection) { if (sc.PlatformName == "BlackBerry" || sc.PlatformName == "BlackBerrySimulator") { bbPlatform = true; if (sc.PlatformName == "BlackBerrySimulator") { _isSimulator = true; } else { _isSimulator = false; } } } } Debug.WriteLine("Before Start Debug"); if (VSNDK.Package.ControlDebugEngine.isDebugEngineRunning || !bbPlatform) { // Disable the override of F5 (this allows the debugged process to continue execution) CancelDefault = false; } else { // Create a reference to the Output window. // Create a tool window reference for the Output window // and window pane. OutputWindow ow = ((DTE2)_dte).ToolWindows.OutputWindow; // Select the Build pane in the Output window. _owP = ow.OutputWindowPanes.Item("Build"); _owP.Activate(); UpdateManagerData upData = new UpdateManagerData(this); if (!upData.validateDeviceVersion(_isSimulator)) { CancelDefault = true; } else { BuildBar(); CancelDefault = true; } } }
public override void TestSuiteStarted() { dte.ToolWindows.OutputWindow.Parent.Activate(); dte.ToolWindows.ErrorList.Parent.Activate(); dte.ToolWindows.OutputWindow.Parent.SetFocus(); testPane = GetOutputPane("Test"); testPane.Activate(); testPane.Clear(); SetStatusBarMessage("Testing Started"); }
/// <summary> /// Constructs the WebServer, starts the web server process. /// </summary> /// <param name="outputWindowPane">Existing output pane to send web server output to.</param> /// <param name="properties">PropertyManager that is set to a valid project/platform.</param> public WebServer(OutputWindowPane outputWindowPane, PropertyManager properties) { if (outputWindowPane == null) { throw new ArgumentNullException("outputWindowPane"); } if (properties == null) { throw new ArgumentNullException("properties"); } webServerOutputPane_ = outputWindowPane; // Read port from properties, if invalid port then set to default value. int webServerPort; if (!int.TryParse(properties.WebServerPort, out webServerPort)) { webServerPort = DefaultWebServerPort; } string webServerExecutable = "python.exe"; string httpd = Path.Combine(properties.SDKRootDirectory, "examples", "httpd.py"); if (!File.Exists(httpd)) httpd = Path.Combine(properties.SDKRootDirectory, "tools", "httpd.py"); string webServerArguments = httpd + " --no_dir_check " + webServerPort; webServerOutputPane_.Clear(); webServerOutputPane_.OutputString(Strings.WebServerStartMessage + "\n"); webServerOutputPane_.Activate(); // Start the web server process. try { webServer_ = new System.Diagnostics.Process(); webServer_.StartInfo.CreateNoWindow = true; webServer_.StartInfo.UseShellExecute = false; webServer_.StartInfo.RedirectStandardOutput = true; webServer_.StartInfo.RedirectStandardError = true; webServer_.StartInfo.FileName = webServerExecutable; webServer_.StartInfo.Arguments = webServerArguments; webServer_.StartInfo.WorkingDirectory = properties.ProjectDirectory; webServer_.OutputDataReceived += WebServerMessageReceive; webServer_.ErrorDataReceived += WebServerMessageReceive; webServer_.Start(); webServer_.BeginOutputReadLine(); webServer_.BeginErrorReadLine(); } catch (Exception e) { webServerOutputPane_.OutputString(Strings.WebServerStartFail + "\n"); webServerOutputPane_.OutputString("Exception: " + e.Message + "\n"); } }
/// <summary> /// Initializes a new instance of the <see cref="OutputWindowWriter"/> class. /// </summary> /// <param name="applicationObject">The application object.</param> public OutputWindowWriter(_DTE applicationObject) { Window window = applicationObject.Windows.Item(Constants.vsWindowKindOutput); OutputWindow outputWindow = (OutputWindow)window.Object; outputWindowPane = outputWindow.OutputWindowPanes .OfType<OutputWindowPane>() .Where(p => p.Name == "WSCF.blue") .FirstOrDefault() ?? outputWindow.OutputWindowPanes.Add("WSCF.blue"); outputWindowPane.Clear(); outputWindowPane.Activate(); }
//one of the test methods for debugging, running against //sqlcmd - due to bug in S2K5, where we hang wen executing //this method causes hang as well bool ExecStmt2(string cmdText) { OutputWindow ow = _app.ToolWindows.OutputWindow; ow.Parent.Activate(); try { owp = ow.OutputWindowPanes.Item("Debug"); } catch { owp = ow.OutputWindowPanes.Add("Debug"); } try { _app.StatusBar.Text = "Debug started"; ow.Parent.Activate(); owp.Activate(); string buildPath = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory(); buildPath = Path.Combine(buildPath, "MSBUILD.exe"); owp.OutputString("Debug Started\n"); System.Diagnostics.Process p = new System.Diagnostics.Process(); string sqlFile = ""; //sqlcmd -d test2 -Q "select dbo.MyAdder99 sqlFile = Path.Combine(ProjectPath, "sql.proj"); //string paramString = string.Format("\"{0}\" /t:ExecDebug /p:CmdText=\"{1}\"", sqlFile, cmdText); //p.StartInfo = new ProcessStartInfo("cmd.exe", "/k " + buildPath + " \"" + sqlFile + "\" /t:ExecDebug /p:CmdText=\"" + cmdText + "\""); p.StartInfo = new ProcessStartInfo("sqlcmd.exe", "-d test2 -Q \"" + cmdText + "\""); p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = true; p.StartInfo.RedirectStandardOutput = true; p.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived); p.Start(); p.BeginOutputReadLine(); //owp.OutputString(p.StandardOutput.ReadToEnd()); p.WaitForExit(); owp.Activate(); string statusMsg = "succeeded"; if (p.ExitCode != 0) statusMsg = "failed"; _app.StatusBar.Text = string.Format("Debug {0}", statusMsg); ow.Parent.Activate(); //ow.Parent.AutoHides = true; return true; } catch (Exception e) { _app.StatusBar.Text = "Debug failed"; string msg = string.Format("An unexpected exception occured.\n\nThe exception is: {0}", e.Message); owp.OutputString(msg); return false; } finally { } }
/// <summary> /// New Start Debug Command Events Before Execution Event Handler. Call the method responsible for building the app. /// </summary> /// <param name="Guid"> Command GUID. </param> /// <param name="ID"> Command ID. </param> /// <param name="CustomIn"> Custom IN Object. </param> /// <param name="CustomOut"> Custom OUT Object. </param> /// <param name="CancelDefault"> Cancel the default execution of the command. </param> private void startDebugCommandEvents_BeforeExecute(string Guid, int ID, object CustomIn, object CustomOut, ref bool CancelDefault) { bool bbPlatform = false; if (_dte.Solution.SolutionBuild.ActiveConfiguration != null) { isDebugConfiguration = checkDebugConfiguration(); SolutionContexts scCollection = _dte.Solution.SolutionBuild.ActiveConfiguration.SolutionContexts; foreach (SolutionContext sc in scCollection) { if (sc.PlatformName == "BlackBerry" || sc.PlatformName == "BlackBerrySimulator") { bbPlatform = true; if (sc.PlatformName == "BlackBerrySimulator") _isSimulator = true; else _isSimulator = false; } } } Debug.WriteLine("Before Start Debug"); if (VSNDK.Package.ControlDebugEngine.isDebugEngineRunning || !bbPlatform) { // Disable the override of F5 (this allows the debugged process to continue execution) CancelDefault = false; } else { try { Solution2 soln = (Solution2)_dte.Solution; buildThese = new List<String>(); _targetDir = new List<string[]>(); foreach (String startupProject in (Array)soln.SolutionBuild.StartupProjects) { foreach (Project p1 in soln.Projects) { if (p1.UniqueName == startupProject) { buildThese.Add(p1.FullName); processName = p1.Name; ConfigurationManager config = p1.ConfigurationManager; Configuration active = config.ActiveConfiguration; foreach (Property prop in active.Properties) { try { if (prop.Name == "OutputPath") { string[] path = new string[2]; path[0] = p1.Name; path[1] = prop.Value.ToString(); _targetDir.Add(path); break; } } catch { } } break; } } } } catch (Exception ex) { Debug.WriteLine(ex.Message); } // Create a reference to the Output window. // Create a tool window reference for the Output window // and window pane. OutputWindow ow = ((DTE2)_dte).ToolWindows.OutputWindow; // Select the Build pane in the Output window. _owP = ow.OutputWindowPanes.Item("Build"); _owP.Activate(); if (isDebugConfiguration) { UpdateManagerData upData; if (_targetDir.Count > 0) upData = new UpdateManagerData(_targetDir[0][1]); else upData = new UpdateManagerData(); if (!upData.validateDeviceVersion(_isSimulator)) { CancelDefault = true; } else { BuildBar(); CancelDefault = true; } } else { BuildBar(); CancelDefault = true; } } }
/// <summary> /// New Start Debug Command Events Before Execution Event Handler. Call the method responsible for building the app. /// </summary> /// <param name="Guid"> Command GUID. </param> /// <param name="ID"> Command ID. </param> /// <param name="CustomIn"> Custom IN Object. </param> /// <param name="CustomOut"> Custom OUT Object. </param> /// <param name="CancelDefault"> Cancel the default execution of the command. </param> private void startDebugCommandEvents_BeforeExecute(string Guid, int ID, object CustomIn, object CustomOut, ref bool CancelDefault) { bool bbPlatform = false; if (_dte.Solution.SolutionBuild.ActiveConfiguration != null) { SolutionContexts scCollection = _dte.Solution.SolutionBuild.ActiveConfiguration.SolutionContexts; foreach (SolutionContext sc in scCollection) { if (sc.PlatformName == "BlackBerry" || sc.PlatformName == "BlackBerrySimulator") { bbPlatform = true; if (sc.PlatformName == "BlackBerrySimulator") _isSimulator = true; else _isSimulator = false; } } } Debug.WriteLine("Before Start Debug"); if (VSNDK.Package.ControlDebugEngine.isDebugEngineRunning || !bbPlatform) { // Disable the override of F5 (this allows the debugged process to continue execution) CancelDefault = false; } else { // Create a reference to the Output window. // Create a tool window reference for the Output window // and window pane. OutputWindow ow = ((DTE2)_dte).ToolWindows.OutputWindow; // Select the Build pane in the Output window. _owP = ow.OutputWindowPanes.Item("Build"); _owP.Activate(); UpdateManagerData upData = new UpdateManagerData(this); if (!upData.validateDeviceVersion(_isSimulator)) { CancelDefault = true; } else { BuildBar(); CancelDefault = true; } } }
/// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary> /// <param term='Application'>Root object of the host application.</param> /// <param term='ConnectMode'>Describes how the Add-in is being loaded.</param> /// <param term='AddInInst'>Object representing this Add-in.</param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object Application, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom) { applicationObject = (DTE2)Application; addInInstance = (AddIn)AddInInst; try { switch (ConnectMode) { case ext_ConnectMode.ext_cm_UISetup: break; case ext_ConnectMode.ext_cm_Startup: break; case ext_ConnectMode.ext_cm_AfterStartup: AddTemporaryUI(); break; } theOutputPane = applicationObject.ToolWindows.OutputWindow.OutputWindowPanes.Add("Sonar Analysis"); theOutputPane.Activate(); } catch (System.Exception e) { System.Windows.Forms.MessageBox.Show(e.ToString()); } }
/// <summary> /// Function that builds the contents of the generated file based on the contents of the input file /// </summary> /// <param name="inputFileContent">Content of the input file</param> /// <returns>Generated file as a byte array</returns> protected override byte[] GenerateCode(string inputFileContent) { try { ProjectItem projItem = GetProjectItem(); if (!projItem.Saved) projItem.Save(""); DTE2 dte2 = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.10.0"); if (dte2 == null) GeneratorWarning(0, "Can't obtain DTE2", 0, 0); else { _generalPane = dte2.ToolWindows.OutputWindow.ActivePane; _generalPane.Activate(); } System.Diagnostics.Process wjay = new System.Diagnostics.Process(); try { wjay.StartInfo.WorkingDirectory = Path.GetDirectoryName(projItem.get_FileNames(1)); FileInfo fi = new FileInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\wjay.exe"); if (fi.Exists) wjay.StartInfo.FileName = fi.FullName; else wjay.StartInfo.FileName = "c:\\utils\\wjay.exe"; if (File.Exists(Path.Combine(Path.GetDirectoryName(projItem.get_FileNames(1)), "yydebug"))) wjay.StartInfo.Arguments = "-t -c -v " + Path.GetFileName(projItem.get_FileNames(1)); else wjay.StartInfo.Arguments = "-c -v " + Path.GetFileName(projItem.get_FileNames(1)); wjay.StartInfo.UseShellExecute = false; wjay.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; wjay.StartInfo.CreateNoWindow = true; wjay.StartInfo.RedirectStandardInput = true; wjay.StartInfo.RedirectStandardOutput = true; _jayOutput = new StringBuilder(); wjay.OutputDataReceived += new DataReceivedEventHandler(ProcessOutputHandler); wjay.StartInfo.RedirectStandardError = true; _jayErrors = new List<string>(); wjay.ErrorDataReceived += new DataReceivedEventHandler(ProcessErrorHandler); wjay.Start(); wjay.BeginOutputReadLine(); wjay.BeginErrorReadLine(); StreamReader Skeleton = File.OpenText(wjay.StartInfo.WorkingDirectory + "\\skeleton.cs"); wjay.StandardInput.Write(Skeleton.ReadToEnd()); wjay.StandardInput.Flush(); wjay.StandardInput.Close(); wjay.WaitForExit(); if (wjay.ExitCode == 0) { StreamReader youtput = new StreamReader(wjay.StartInfo.WorkingDirectory + "\\y.output"); List<String> slist = new List<string>(); while (!youtput.EndOfStream) { if (slist.Count > 10) slist.RemoveAt(0); slist.Add(youtput.ReadLine()); } youtput.Close(); if (_generalPane != null) { _generalPane.OutputString("Running wjay.exe:\n"); for (int k = 1; k < 3 && slist.Count - k > 0; k++) if (!String.IsNullOrEmpty(slist[slist.Count - k])) _generalPane.OutputString(slist[slist.Count - k] + "\n"); System.Windows.Forms.Application.DoEvents(); } //Get the Encoding used by the writer. We're getting the WindowsCodePage encoding, //which may not work with all languages Encoding enc = Encoding.ASCII; //Get the preamble (byte-order mark) for our encoding byte[] preamble = enc.GetPreamble(); int preambleLength = preamble.Length; //Convert the writer contents to a byte array byte[] body = enc.GetBytes(_jayOutput.ToString()); //Prepend the preamble to body (store result in resized preamble array) Array.Resize<byte>(ref preamble, preambleLength + body.Length); Array.Copy(body, 0, preamble, preambleLength, body.Length); //Return the combined byte array return preamble; } else { foreach(string s in _jayErrors) GeneratorError(1, s, 1, 1); //Returning null signifies that generation has failed return null; } } finally { wjay.Close(); } } catch (Exception e) { GeneratorError(4, e.ToString(), 1, 1); //Returning null signifies that generation has failed return null; } }
/// <summary> /// Run initialization code on first connection of the AddIn /// </summary> /// <param name="appObj">Application Object</param> /// <param name="addin">Add In Object</param> public void Connect(DTE2 appObj, EnvDTE.AddIn addin) { /// Initialize External and Internal Variables. _applicationObject = appObj; _addInInstance = addin; isDebugEngineRunning = false; /// Register Command Events _commandEvents = new VSNDKCommandEvents(appObj); _commandEvents.RegisterCommand(GuidList.guidVSStd2KString, CommandConstants.cmdidSolutionPlatform, cmdNewPlatform_afterExec, cmdNewPlatform_beforeExec); _commandEvents.RegisterCommand(GuidList.guidVSStd2KString, CommandConstants.cmdidSolutionCfg, cmdNewPlatform_afterExec, cmdNewPlatform_beforeExec); _commandEvents.RegisterCommand(GuidList.guidVSStd97String, CommandConstants.cmdidStartDebug, startDebugCommandEvents_AfterExecute, startDebugCommandEvents_BeforeExecute); _commandEvents.RegisterCommand(GuidList.guidVSStd2KString, CommandConstants.cmdidStartDebugContext, startDebugCommandEvents_AfterExecute, startDebugCommandEvents_BeforeExecute); _commandEvents.RegisterCommand(GuidList.guidVSStd97String, CommandConstants.cmdidStartNoDebug, startNoDebugCommandEvents_AfterExecute, startNoDebugCommandEvents_BeforeExecute); _commandEvents.RegisterCommand(GuidList.guidVSDebugGroup, CommandConstants.cmdidDebugBreakatFunction, cmdNewFunctionBreakpoint_afterExec, cmdNewFunctionBreakpoint_beforeExec); // ??? Check why Solution.SolutionBuild.Deploy(false) fires OnBuildComplete event immediately after start deploying when _buildEvents is initialized here. // ??? To avoid that, we should initialize _buildEvents in BuildBar(), but here should be the right place. _buildEvents = _applicationObject.Events.BuildEvents; _buildEvents.OnBuildBegin += new _dispBuildEvents_OnBuildBeginEventHandler(this.OnBuildBegin); // Create a reference to the Output window. // Create a tool window reference for the Output window // and window pane. OutputWindow ow = _applicationObject.ToolWindows.OutputWindow; // Select the Build pane in the Output window. _owP = ow.OutputWindowPanes.Item("Build"); _owP.Activate(); DisableIntelliSenseErrorReport(true); CheckSolutionPlatformCommand(); }
private void CreateOutputWindow(string winText) { ow = _app.ToolWindows.OutputWindow; ow.Parent.Activate(); try { owp = ow.OutputWindowPanes.Item(winText); owp.Clear(); ow.Parent.Activate(); owp.Activate(); } catch { owp = ow.OutputWindowPanes.Add(winText); } }