diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs index ebaa4b8c53..4bb29a8550 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs @@ -138,6 +138,9 @@ namespace ICSharpCode.SharpDevelop.Services } else if (version == null || version.Length == 0) { MessageService.ShowMessage("${res:XML.MainMenu.DebugMenu.Error.BadAssembly}"); } else { + if (DebugStarting != null) + DebugStarting(this, EventArgs.Empty); + Debugger.Process process = debugger.Start(processStartInfo.FileName, processStartInfo.WorkingDirectory, processStartInfo.Arguments); @@ -228,6 +231,7 @@ namespace ICSharpCode.SharpDevelop.Services } } + public event EventHandler DebugStarting; public event EventHandler DebugStarted; public event EventHandler DebugStopped; public event EventHandler IsProcessRunningChanged; diff --git a/src/Libraries/DockPanel_Src/WinFormsUI/Docking/DockContentHandler.cs b/src/Libraries/DockPanel_Src/WinFormsUI/Docking/DockContentHandler.cs index 3d84a01cf1..94b0a16821 100644 --- a/src/Libraries/DockPanel_Src/WinFormsUI/Docking/DockContentHandler.cs +++ b/src/Libraries/DockPanel_Src/WinFormsUI/Docking/DockContentHandler.cs @@ -704,17 +704,17 @@ namespace WeifenLuo.WinFormsUI.Docking // Change the parent of a control with focus may result in the first // MDI child form get activated. //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - bool bRestoreFocus = false; - if (Form.ContainsFocus) - { - if (value == null) - DockPanel.ContentFocusManager.GiveUpFocus(this.Content); - else - { - DockPanel.SaveFocus(); - bRestoreFocus = true; - } - } +// bool bRestoreFocus = false; +// if (Form.ContainsFocus) +// { +// if (value == null) +// DockPanel.ContentFocusManager.GiveUpFocus(this.Content); +// else +// { +// DockPanel.SaveFocus(); +// bRestoreFocus = true; +// } +// } //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Form.Parent = value; @@ -724,8 +724,27 @@ namespace WeifenLuo.WinFormsUI.Docking // Change the parent of a control with focus may result in the first // MDI child form get activated. //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +/* Workaround disabled: in SharpDevelop, the Activate() call causes an exception on layout changes + iff no document is open and a pad has the focus. + I don't think we need this workaround because we don't use MDI. + +System.InvalidOperationException: Invalid Content: ActiveContent must be one ofthe visible contents, or null if there is no visible content. + at WeifenLuo.WinFormsUI.Docking.DockPane.set_ActiveContent(IDockContent value) in d:\SD\3.0\SharpDevelop\src\Libraries\DockPanel_Src\WinFormsUI\Docking\DockPane.cs:line 162 + at WeifenLuo.WinFormsUI.Docking.DockContentHandler.Activate() in d:\SD\3.0\SharpDevelop\src\Libraries\DockPanel_Src\WinFormsUI\Docking\DockContentHandler.cs:line 618 + at WeifenLuo.WinFormsUI.Docking.DockContentHandler.SetParent(Control value) in d:\SD\3.0\SharpDevelop\src\Libraries\DockPanel_Src\WinFormsUI\Docking\DockContentHandler.cs:line 728 + at WeifenLuo.WinFormsUI.Docking.DockContentHandler.SetPane(DockPane pane) in d:\SD\3.0\SharpDevelop\src\Libraries\DockPanel_Src\WinFormsUI\Docking\DockContentHandler.cs:line 674 + at WeifenLuo.WinFormsUI.Docking.DockContentHandler.SetPaneAndVisible(DockPane pane) in d:\SD\3.0\SharpDevelop\src\Libraries\DockPanel_Src\WinFormsUI\Docking\DockContentHandler.cs:line 651 + at WeifenLuo.WinFormsUI.Docking.DockContentHandler.SetDockState(Boolean isHidden, DockState visibleState, DockPane oldPane) in d:\SD\3.0\SharpDevelop\src\Libraries\DockPanel_Src\WinFormsUI\Docking\DockContentHandler.cs:line 504 + at WeifenLuo.WinFormsUI.Docking.DockContentHandler.set_PanelPane(DockPane value) in d:\SD\3.0\SharpDevelop\src\Libraries\DockPanel_Src\WinFormsUI\Docking\DockContentHandler.cs:line 388 + at WeifenLuo.WinFormsUI.Docking.DockPanel.Persistor.LoadFromXml(DockPanel dockPanel, Stream stream, DeserializeDockContent deserializeContent, Boolean closeStream) in d:\SD\3.0\SharpDevelop\src\Libraries\DockPanel_Src\WinFormsUI\Docking\DockPanel.Persistor.cs:line 614 + at WeifenLuo.WinFormsUI.Docking.DockPanel.Persistor.LoadFromXml(DockPanel dockPanel, Stream stream, DeserializeDockContent deserializeContent) in d:\SD\3.0\SharpDevelop\src\Libraries\DockPanel_Src\WinFormsUI\Docking\DockPanel.Persistor.cs:line 378 + at WeifenLuo.WinFormsUI.Docking.DockPanel.LoadFromXml(Stream stream, DeserializeDockContent deserializeContent) in d:\SD\3.0\SharpDevelop\src\Libraries\DockPanel_Src\WinFormsUI\Docking\DockPanel.Persistor.cs:line 772 + at ICSharpCode.SharpDevelop.Gui.SdiWorkbenchLayout.LoadDockPanelLayout(String fileName) in d:\SD\3.0\SharpDevelop\src\Main\Base\Project\Src\Gui\Workbench\Layouts\SdiWorkspaceLayout.cs:line 213 + at ICSharpCode.SharpDevelop.Gui.SdiWorkbenchLayout.LoadLayoutConfiguration()in d:\SD\3.0\SharpDevelop\src\Main\Base\Project\Src\Gui\Workbench\Layouts\SdiWorkspaceLayout.cs:line 190 + if (bRestoreFocus) Activate(); + */ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } diff --git a/src/Libraries/DockPanel_Src/patchnotes.txt b/src/Libraries/DockPanel_Src/patchnotes.txt index cc0a27b5a8..4c13e9e143 100644 --- a/src/Libraries/DockPanel_Src/patchnotes.txt +++ b/src/Libraries/DockPanel_Src/patchnotes.txt @@ -14,3 +14,9 @@ Patch #2: that was active when SharpDevelop was closed does not exist anymore after an AddIn was removed manually or SharpDevelop was updated) Committed in revision 2732. + +Patch #3: + Disable MDI focus workaround in DockContentHandler.cs + This fixes the System.InvalidOperationException: Invalid Content: ActiveContent must be one ofthe visible contents, or null if there is no visible content. + that occurs on layout changes iff no document is open and a pad has the focus. + Committed in revision 2751. \ No newline at end of file diff --git a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs index 8f9d2a03f0..b9f13ddace 100644 --- a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs @@ -2623,7 +2623,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter public override object TrackedVisitQueryExpressionJoinClause(QueryExpressionJoinClause joinClause, object data) { - outputFormatter.PrintToken(Tokens.From); + outputFormatter.PrintToken(Tokens.Join); outputFormatter.Space(); VisitQueryExpressionFromOrJoinClause(joinClause, data); outputFormatter.Space(); diff --git a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs index ebb5cb6400..08274ca08c 100644 --- a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs @@ -2775,47 +2775,126 @@ namespace ICSharpCode.NRefactory.PrettyPrinter public override object TrackedVisitQueryExpression(QueryExpression queryExpression, object data) { - throw new NotImplementedException(); + outputFormatter.IndentationLevel++; + queryExpression.FromClause.AcceptVisitor(this, data); + queryExpression.FromLetWhereClauses.ForEach(PrintClause); + if (queryExpression.Orderings.Count > 0) { + outputFormatter.NewLine(); + outputFormatter.Indent(); + outputFormatter.PrintText("Order By"); + outputFormatter.Space(); + AppendCommaSeparatedList(queryExpression.Orderings); + } + PrintClause(queryExpression.SelectOrGroupClause); + PrintClause(queryExpression.IntoClause); + outputFormatter.IndentationLevel--; + return null; + } + + void PrintClause(QueryExpressionClause clause) + { + if (!clause.IsNull) { + outputFormatter.PrintLineContinuation(); + outputFormatter.Indent(); + clause.AcceptVisitor(this, null); + } } - public override object TrackedVisitQueryExpressionFromClause(QueryExpressionFromClause queryExpressionFromClause, object data) + public override object TrackedVisitQueryExpressionFromClause(QueryExpressionFromClause fromClause, object data) { - throw new NotImplementedException(); + outputFormatter.PrintText("From"); + outputFormatter.Space(); + VisitQueryExpressionFromOrJoinClause(fromClause, data); + return null; + } + + public override object TrackedVisitQueryExpressionJoinClause(QueryExpressionJoinClause joinClause, object data) + { + outputFormatter.PrintText("Join"); + outputFormatter.Space(); + VisitQueryExpressionFromOrJoinClause(joinClause, data); + outputFormatter.Space(); + outputFormatter.PrintToken(Tokens.On); + outputFormatter.Space(); + joinClause.OnExpression.AcceptVisitor(this, data); + outputFormatter.Space(); + outputFormatter.PrintToken(Tokens.Assign); + outputFormatter.Space(); + joinClause.EqualsExpression.AcceptVisitor(this, data); + if (!string.IsNullOrEmpty(joinClause.IntoIdentifier)) { + outputFormatter.Space(); + outputFormatter.PrintText("Into"); + outputFormatter.Space(); + outputFormatter.PrintIdentifier(joinClause.IntoIdentifier); + } + return null; } - public override object TrackedVisitQueryExpressionGroupClause(QueryExpressionGroupClause queryExpressionGroupClause, object data) + void VisitQueryExpressionFromOrJoinClause(QueryExpressionFromOrJoinClause clause, object data) { - throw new NotImplementedException(); + outputFormatter.PrintIdentifier(clause.Identifier); + outputFormatter.Space(); + outputFormatter.PrintToken(Tokens.In); + outputFormatter.Space(); + clause.InExpression.AcceptVisitor(this, data); } - public override object TrackedVisitQueryExpressionIntoClause(QueryExpressionIntoClause queryExpressionIntoClause, object data) + public override object TrackedVisitQueryExpressionLetClause(QueryExpressionLetClause letClause, object data) { - throw new NotImplementedException(); + outputFormatter.PrintToken(Tokens.Let); + outputFormatter.Space(); + outputFormatter.PrintIdentifier(letClause.Identifier); + outputFormatter.Space(); + outputFormatter.PrintToken(Tokens.Assign); + outputFormatter.Space(); + return letClause.Expression.AcceptVisitor(this, data); } - public override object TrackedVisitQueryExpressionOrdering(QueryExpressionOrdering queryExpressionOrdering, object data) + public override object TrackedVisitQueryExpressionGroupClause(QueryExpressionGroupClause groupClause, object data) { - throw new NotImplementedException(); + outputFormatter.PrintText("Group"); + outputFormatter.Space(); + groupClause.Projection.AcceptVisitor(this, data); + outputFormatter.Space(); + outputFormatter.PrintText("By"); + outputFormatter.Space(); + return groupClause.GroupBy.AcceptVisitor(this, data); } - public override object TrackedVisitQueryExpressionSelectClause(QueryExpressionSelectClause queryExpressionSelectClause, object data) + public override object TrackedVisitQueryExpressionIntoClause(QueryExpressionIntoClause intoClause, object data) { - throw new NotImplementedException(); + outputFormatter.PrintText("Into"); + outputFormatter.Space(); + outputFormatter.PrintIdentifier(intoClause.IntoIdentifier); + outputFormatter.Space(); + return intoClause.ContinuedQuery.AcceptVisitor(this, data); } - public override object TrackedVisitQueryExpressionWhereClause(QueryExpressionWhereClause queryExpressionWhereClause, object data) + public override object TrackedVisitQueryExpressionOrdering(QueryExpressionOrdering ordering, object data) { - throw new NotImplementedException(); + ordering.Criteria.AcceptVisitor(this, data); + if (ordering.Direction == QueryExpressionOrderingDirection.Ascending) { + outputFormatter.Space(); + outputFormatter.PrintText("Ascending"); + } else if (ordering.Direction == QueryExpressionOrderingDirection.Descending) { + outputFormatter.Space(); + outputFormatter.PrintText("Descending"); + } + return null; } - public override object TrackedVisitQueryExpressionJoinClause(QueryExpressionJoinClause queryExpressionJoinClause, object data) + public override object TrackedVisitQueryExpressionSelectClause(QueryExpressionSelectClause selectClause, object data) { - throw new NotImplementedException(); + outputFormatter.PrintToken(Tokens.Select); + outputFormatter.Space(); + return selectClause.Projection.AcceptVisitor(this, data); } - public override object TrackedVisitQueryExpressionLetClause(QueryExpressionLetClause queryExpressionLetClause, object data) + public override object TrackedVisitQueryExpressionWhereClause(QueryExpressionWhereClause whereClause, object data) { - throw new NotImplementedException(); + outputFormatter.PrintText("Where"); + outputFormatter.Space(); + return whereClause.Condition.AcceptVisitor(this, data); } } } diff --git a/src/Main/Base/Project/Src/Commands/ChooseLayoutCommand.cs b/src/Main/Base/Project/Src/Commands/ChooseLayoutCommand.cs index 2fab5b46f3..23c6a4dccd 100644 --- a/src/Main/Base/Project/Src/Commands/ChooseLayoutCommand.cs +++ b/src/Main/Base/Project/Src/Commands/ChooseLayoutCommand.cs @@ -39,6 +39,7 @@ namespace ICSharpCode.SharpDevelop.Commands public override void Run() { if (editingLayout) return; + LoggingService.Debug("ChooseLayoutCommand.Run()"); ComboBox comboBox = ((ToolBarComboBox)Owner).ComboBox; string dataPath = Path.Combine(PropertyService.DataDirectory, "resources" + Path.DirectorySeparatorChar + "layouts"); @@ -147,15 +148,14 @@ namespace ICSharpCode.SharpDevelop.Commands } catch (Exception) {} } } - WorkbenchSingleton.Workbench.WorkbenchLayout.LoadConfiguration(); - - LayoutChanged(null, null); + LayoutConfiguration.ReloadDefaultLayout(); } } void LayoutChanged(object sender, EventArgs e) { if (editingLayout) return; + LoggingService.Debug("ChooseLayoutCommand.LayoutChanged(object,EventArgs)"); ToolBarComboBox toolbarItem = (ToolBarComboBox)Owner; ComboBox comboBox = toolbarItem.ComboBox; for (int i = 0; i < comboBox.Items.Count; ++i) { diff --git a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/LayoutConfiguration.cs b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/LayoutConfiguration.cs index e5bb0e478c..72c342cea6 100644 --- a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/LayoutConfiguration.cs +++ b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/LayoutConfiguration.cs @@ -20,6 +20,8 @@ namespace ICSharpCode.SharpDevelop.Gui const string configFile = "LayoutConfig.xml"; public static readonly List Layouts = new List(); + const string DefaultLayoutName = "Default"; + public static string[] DefaultLayouts = new string[] { "Default", "Debug", @@ -107,22 +109,30 @@ namespace ICSharpCode.SharpDevelop.Gui return DisplayName; } + static string currentLayoutName = DefaultLayoutName; + public static string CurrentLayoutName { get { - - return PropertyService.Get("Workbench.CurrentLayout", "Default"); + return currentLayoutName; } set { if (WorkbenchSingleton.InvokeRequired) throw new InvalidOperationException("Invoke required"); if (value != CurrentLayoutName) { - PropertyService.Set("Workbench.CurrentLayout", value); + currentLayoutName = value; WorkbenchSingleton.Workbench.WorkbenchLayout.LoadConfiguration(); OnLayoutChanged(EventArgs.Empty); } } } + public static void ReloadDefaultLayout() + { + currentLayoutName = DefaultLayoutName; + WorkbenchSingleton.Workbench.WorkbenchLayout.LoadConfiguration(); + OnLayoutChanged(EventArgs.Empty); + } + public static string CurrentLayoutFileName { get { string configPath = Path.Combine(PropertyService.ConfigDirectory, "layouts"); diff --git a/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs b/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs index 1c7e5b4f35..4fe10c1cc8 100644 --- a/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs +++ b/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs @@ -108,13 +108,13 @@ namespace ICSharpCode.SharpDevelop.Gui NavigationService.InitializeService(); workbench.ActiveContentChanged += delegate { - Console.WriteLine("ActiveContentChanged to " + workbench.ActiveContent); + LoggingService.Debug("ActiveContentChanged to " + workbench.ActiveContent); }; workbench.ActiveViewContentChanged += delegate { - Console.WriteLine("ActiveViewContentChanged to " + workbench.ActiveViewContent); + LoggingService.Debug("ActiveViewContentChanged to " + workbench.ActiveViewContent); }; workbench.ActiveWorkbenchWindowChanged += delegate { - Console.WriteLine("ActiveWorkbenchWindowChanged to " + workbench.ActiveWorkbenchWindow); + LoggingService.Debug("ActiveWorkbenchWindowChanged to " + workbench.ActiveWorkbenchWindow); }; } diff --git a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs index 71c2b85013..2abd5d9b64 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs @@ -72,6 +72,7 @@ namespace ICSharpCode.SharpDevelop.Debugging get { if (currentDebugger == null) { currentDebugger = GetCompatibleDebugger(); + currentDebugger.DebugStarting += new EventHandler(OnDebugStarting); currentDebugger.DebugStarted += new EventHandler(OnDebugStarted); currentDebugger.DebugStopped += new EventHandler(OnDebugStopped); } @@ -97,25 +98,25 @@ namespace ICSharpCode.SharpDevelop.Debugging } } + public static event EventHandler DebugStarting; public static event EventHandler DebugStarted; public static event EventHandler DebugStopped; - static void OnDebugStarted(object sender, EventArgs e) - { - // OnDebugStarted runs on the main thread, but for some reason we - // have to delay the layout change a bit to work around SD2-1325 - WorkbenchSingleton.SafeThreadAsyncCall(OnDebugStartedInvoked); - if (DebugStarted != null) - DebugStarted(null, EventArgs.Empty); - } - - static void OnDebugStartedInvoked() + static void OnDebugStarting(object sender, EventArgs e) { WorkbenchSingleton.Workbench.WorkbenchLayout.StoreConfiguration(); - oldLayoutConfiguration = LayoutConfiguration.CurrentLayoutName; LayoutConfiguration.CurrentLayoutName = "Debug"; ClearDebugMessages(); + + if (DebugStarting != null) + DebugStarting(null, e); + } + + static void OnDebugStarted(object sender, EventArgs e) + { + if (DebugStarted != null) + DebugStarted(null, e); } static void OnDebugStopped(object sender, EventArgs e) @@ -311,7 +312,6 @@ namespace ICSharpCode.SharpDevelop.Debugging } if (e.InDocument) { - // Query all registered tooltip providers using the AddInTree. // The first one that does not return null will be used. ToolTipInfo ti = null; @@ -335,7 +335,7 @@ namespace ICSharpCode.SharpDevelop.Debugging } } catch (Exception ex) { - ICSharpCode.Core.MessageService.ShowError(ex); + ICSharpCode.Core.MessageService.ShowError(ex, "Error while requesting tooltip for location " + e.LogicalPosition); } finally { if (toolTipControl == null && CanCloseOldToolTip) CloseOldToolTip(); diff --git a/src/Main/Base/Project/Src/Services/Debugger/DefaultDebugger.cs b/src/Main/Base/Project/Src/Services/Debugger/DefaultDebugger.cs index a3becdfb03..3c18ab67c6 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/DefaultDebugger.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/DefaultDebugger.cs @@ -39,6 +39,7 @@ namespace ICSharpCode.SharpDevelop.Debugging return; } + OnDebugStarting(EventArgs.Empty); try { attachedProcess = new Process(); attachedProcess.StartInfo = processStartInfo; @@ -47,6 +48,7 @@ namespace ICSharpCode.SharpDevelop.Debugging attachedProcess.Start(); OnDebugStarted(EventArgs.Empty); } catch (Exception) { + OnDebugStopped(EventArgs.Empty); throw new ApplicationException("Can't execute " + "\"" + processStartInfo.FileName + "\"\n"); } } @@ -161,6 +163,15 @@ namespace ICSharpCode.SharpDevelop.Debugging } } + public event EventHandler DebugStarting; + + protected virtual void OnDebugStarting(EventArgs e) + { + if (DebugStarting != null) { + DebugStarting(this, e); + } + } + public void Dispose() { Stop(); diff --git a/src/Main/Base/Project/Src/Services/Debugger/IDebugger.cs b/src/Main/Base/Project/Src/Services/Debugger/IDebugger.cs index e6693da84b..d1d64429a0 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/IDebugger.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/IDebugger.cs @@ -79,6 +79,11 @@ namespace ICSharpCode.SharpDevelop.Debugging /// True if successful. False otherwise bool SetInstructionPointer(string filename, int line, int column); + /// + /// Ocurrs when the debugger is starting. + /// + event EventHandler DebugStarting; + /// /// Ocurrs after the debugger has started. ///