diff --git a/data/resources/StringResources.de.resx b/data/resources/StringResources.de.resx index f916814d49..353bfad27e 100644 --- a/data/resources/StringResources.de.resx +++ b/data/resources/StringResources.de.resx @@ -2486,7 +2486,7 @@ Wollen Sie die neue Datei zum Projekt ${CurrentProjectName} hinzufügen? &Benutzerspezifische Daten mit Dokument laden - Macintosh + Macintosh (CR) Laden/Speichern @@ -2495,13 +2495,13 @@ Wollen Sie die neue Datei zum Projekt ${CurrentProjectName} hinzufügen? Speichern - Unix + Unix (LF) &Papierkorb zum Löschen von Dateien verwenden - Windows + Windows (CRLF) Format @@ -3627,6 +3627,9 @@ Bitte einen anderen Dateinamen wählen. Ressourceninhalt: + + Drücken Sie Strg+Leertaste, um Elemente aus allen Namespaces anzuzeigen + Boo-Interpreter diff --git a/data/resources/StringResources.pl.resx b/data/resources/StringResources.pl.resx index 0232a5fd38..494e254b98 100644 --- a/data/resources/StringResources.pl.resx +++ b/data/resources/StringResources.pl.resx @@ -229,6 +229,9 @@ Pobierz Dodatek z Internetu, potem kliknij "Instaluj Dodatek" i wskaż pobrany Nieznany format pliku: + + Pokaż Diagram Klas + Dodaj do Ulubionych Pomocy diff --git a/data/resources/StringResources.resx b/data/resources/StringResources.resx index ebbafad3f1..ab59eabf93 100644 --- a/data/resources/StringResources.resx +++ b/data/resources/StringResources.resx @@ -4826,6 +4826,9 @@ Goto 'Options->Visual Style' and change the current language ambience. Run with debugger + + Testing ${Name}... + &Test diff --git a/src/AddIns/Analysis/UnitTesting/Src/AbstractRunTestCommands.cs b/src/AddIns/Analysis/UnitTesting/Src/AbstractRunTestCommands.cs index d8093e2913..f408859fc9 100644 --- a/src/AddIns/Analysis/UnitTesting/Src/AbstractRunTestCommands.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/AbstractRunTestCommands.cs @@ -90,7 +90,7 @@ namespace ICSharpCode.UnitTesting UpdateUnitTestsPadToolbar(); ResetAllTestResultsInUnitTestsPad(); - OnBeforeRunTests(); + OnBeforeBuild(); } void BuildAndRunTests() @@ -132,8 +132,16 @@ namespace ICSharpCode.UnitTesting } /// - /// Called before all tests are run. If multiple projects are - /// to be tested this is called only once. + /// Called before the build is started (even if no build needs to be performed). + /// If multiple projects are to be tested this is called only once. + /// + protected virtual void OnBeforeBuild() + { + } + + /// + /// Called before all tests are run (after the build has finished successfully). + /// If multiple projects are to be tested this is called only once. /// protected virtual void OnBeforeRunTests() { @@ -202,6 +210,10 @@ namespace ICSharpCode.UnitTesting if (selectedTests.HasProjects) { RunTests(selectedTests); } else { + if (testProgressMonitor != null) { + testProgressMonitor.Dispose(); + testProgressMonitor = null; + } runningTestCommand = null; UpdateUnitTestsPadToolbar(); ShowErrorList(); @@ -218,6 +230,12 @@ namespace ICSharpCode.UnitTesting { if (IsTestResultFailureOrIsIgnored(result)) { AddTaskForTestResult(result); + if (testProgressMonitor != null) { + if (result.IsFailure) + testProgressMonitor.Status = OperationStatus.Error; + else if (result.IsIgnored && testProgressMonitor.Status == OperationStatus.Normal) + testProgressMonitor.Status = OperationStatus.Warning; + } } UpdateTestResult(result); } @@ -284,8 +302,19 @@ namespace ICSharpCode.UnitTesting return (results.ErrorCount == 0) && IsRunningTest; } + IProgressMonitor testProgressMonitor; + int totalProjectCount; + void RunTests(SelectedTests selectedTests) { + if (testProgressMonitor == null) { + testProgressMonitor = context.StatusBarService.CreateProgressMonitor(); + totalProjectCount = selectedTests.Projects.Count; + OnBeforeRunTests(); + } + testProgressMonitor.TaskName = StringParser.Parse("${res:ICSharpCode.UnitTesting.StatusBarProgressLabel}", new StringTagPair("Name", selectedTests.Project.Name)); + testProgressMonitor.Progress = (double)(totalProjectCount-selectedTests.Projects.Count)/totalProjectCount; + testRunner = CreateTestRunner(selectedTests.Project); if (testRunner != null) { testRunner.MessageReceived += TestRunnerMessageReceived; diff --git a/src/AddIns/Analysis/UnitTesting/Src/IRunTestCommandContext.cs b/src/AddIns/Analysis/UnitTesting/Src/IRunTestCommandContext.cs index 3910a83c9f..45d5b165b6 100644 --- a/src/AddIns/Analysis/UnitTesting/Src/IRunTestCommandContext.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/IRunTestCommandContext.cs @@ -6,6 +6,7 @@ // using System; +using ICSharpCode.Core.Services; using ICSharpCode.SharpDevelop.Gui; namespace ICSharpCode.UnitTesting @@ -19,7 +20,8 @@ namespace ICSharpCode.UnitTesting IBuildOptions BuildOptions { get; } MessageViewCategory UnitTestCategory { get; } IUnitTestsPad OpenUnitTestsPad { get; } - IUnitTestMessageService MessageService { get; } + IMessageService MessageService { get; } IUnitTestSaveAllFilesCommand SaveAllFilesCommand { get; } + IStatusBarService StatusBarService { get; } } } diff --git a/src/AddIns/Analysis/UnitTesting/Src/IUnitTestMessageService.cs b/src/AddIns/Analysis/UnitTesting/Src/IUnitTestMessageService.cs deleted file mode 100644 index 169989ebb2..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Src/IUnitTestMessageService.cs +++ /dev/null @@ -1,17 +0,0 @@ -// -// -// -// -// $Revision$ -// - - -using System; - -namespace ICSharpCode.UnitTesting -{ - public interface IUnitTestMessageService - { - bool AskQuestion(string question, string caption); - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Src/NUnitTestDebugger.cs b/src/AddIns/Analysis/UnitTesting/Src/NUnitTestDebugger.cs index a90861f7e9..f800d5a491 100644 --- a/src/AddIns/Analysis/UnitTesting/Src/NUnitTestDebugger.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/NUnitTestDebugger.cs @@ -7,6 +7,7 @@ using System; using System.Diagnostics; +using ICSharpCode.Core.Services; using ICSharpCode.SharpDevelop.Debugging; namespace ICSharpCode.UnitTesting @@ -17,14 +18,14 @@ namespace ICSharpCode.UnitTesting public NUnitTestDebugger() : this(new UnitTestDebuggerService(), - new UnitTestMessageService(), + ServiceManager.Instance.MessageService, new TestResultsMonitor(), new UnitTestingOptions()) { } public NUnitTestDebugger(IUnitTestDebuggerService debuggerService, - IUnitTestMessageService messageService, + IMessageService messageService, ITestResultsMonitor testResultsMonitor, UnitTestingOptions options) : base(debuggerService, messageService, testResultsMonitor) diff --git a/src/AddIns/Analysis/UnitTesting/Src/RunTestCommandContext.cs b/src/AddIns/Analysis/UnitTesting/Src/RunTestCommandContext.cs index 737c517676..1423b361df 100644 --- a/src/AddIns/Analysis/UnitTesting/Src/RunTestCommandContext.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/RunTestCommandContext.cs @@ -6,6 +6,7 @@ // using System; +using ICSharpCode.Core.Services; using ICSharpCode.SharpDevelop.Gui; namespace ICSharpCode.UnitTesting @@ -19,8 +20,9 @@ namespace ICSharpCode.UnitTesting UnitTestBuildProjectFactory buildProjectFactory = new UnitTestBuildProjectFactory(); UnitTestBuildOptions buildOptions = new UnitTestBuildOptions(); MessageViewCategory unitTestCategory = TestService.UnitTestMessageView; - UnitTestMessageService messageService = new UnitTestMessageService(); + IMessageService messageService = ServiceManager.Instance.MessageService; UnitTestSaveAllFilesCommand saveAllFilesCommand = new UnitTestSaveAllFilesCommand(); + IStatusBarService statusBarService = WorkbenchSingleton.StatusBar; public IRegisteredTestFrameworks RegisteredTestFrameworks { get { return testFrameworks; } @@ -50,12 +52,16 @@ namespace ICSharpCode.UnitTesting get { return UnitTestsPad.Instance; } } - public IUnitTestMessageService MessageService { + public IMessageService MessageService { get { return messageService; } } public IUnitTestSaveAllFilesCommand SaveAllFilesCommand { get { return saveAllFilesCommand; } } + + public IStatusBarService StatusBarService { + get { return statusBarService; } + } } } diff --git a/src/AddIns/Analysis/UnitTesting/Src/TestDebuggerBase.cs b/src/AddIns/Analysis/UnitTesting/Src/TestDebuggerBase.cs index 5310545a37..70084f7ae9 100644 --- a/src/AddIns/Analysis/UnitTesting/Src/TestDebuggerBase.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/TestDebuggerBase.cs @@ -7,6 +7,7 @@ using System; using System.Diagnostics; +using ICSharpCode.Core.Services; using ICSharpCode.SharpDevelop.Debugging; namespace ICSharpCode.UnitTesting @@ -14,19 +15,19 @@ namespace ICSharpCode.UnitTesting public abstract class TestDebuggerBase : TestRunnerBase { IUnitTestDebuggerService debuggerService; - IUnitTestMessageService messageService; + IMessageService messageService; IDebugger debugger; ITestResultsMonitor testResultsMonitor; public TestDebuggerBase() : this(new UnitTestDebuggerService(), - new UnitTestMessageService(), + ServiceManager.Instance.MessageService, new TestResultsMonitor()) { } public TestDebuggerBase(IUnitTestDebuggerService debuggerService, - IUnitTestMessageService messageService, + IMessageService messageService, ITestResultsMonitor testResultsMonitor) { this.debuggerService = debuggerService; diff --git a/src/AddIns/Analysis/UnitTesting/Src/UnitTestMessageService.cs b/src/AddIns/Analysis/UnitTesting/Src/UnitTestMessageService.cs deleted file mode 100644 index 9f5eaeb67a..0000000000 --- a/src/AddIns/Analysis/UnitTesting/Src/UnitTestMessageService.cs +++ /dev/null @@ -1,20 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using ICSharpCode.Core; - -namespace ICSharpCode.UnitTesting -{ - public class UnitTestMessageService : IUnitTestMessageService - { - public bool AskQuestion(string question, string caption) - { - return MessageService.AskQuestion(question, caption); - } - } -} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/NoTestsRunWhenNoTestsSelectedTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/NoTestsRunWhenNoTestsSelectedTestFixture.cs index c27d735883..126316d15d 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/NoTestsRunWhenNoTestsSelectedTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/NoTestsRunWhenNoTestsSelectedTestFixture.cs @@ -24,7 +24,7 @@ namespace UnitTesting.Tests.Tree [Test] public void OnBeforeRunIsNotCalled() { - Assert.IsFalse(runTestCommand.IsOnBeforeRunTestsMethodCalled); + Assert.IsFalse(runTestCommand.IsOnBeforeBuildMethodCalled); } } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/NoTestsRunWhenUnitTestPadNotCreatedTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/NoTestsRunWhenUnitTestPadNotCreatedTestFixture.cs index d327f4ed96..ded92a43a5 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/NoTestsRunWhenUnitTestPadNotCreatedTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/NoTestsRunWhenUnitTestPadNotCreatedTestFixture.cs @@ -36,7 +36,7 @@ namespace UnitTesting.Tests.Tree public void OnBeforeRunIsNotCalled() { runTestCommand.Run(); - Assert.IsFalse(runTestCommand.IsOnBeforeRunTestsMethodCalled); + Assert.IsFalse(runTestCommand.IsOnBeforeBuildMethodCalled); } } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestCommandBeforeRunTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestCommandBeforeRunTestFixture.cs index 26e433e09a..0719eb467d 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestCommandBeforeRunTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestCommandBeforeRunTestFixture.cs @@ -47,10 +47,10 @@ namespace UnitTesting.Tests.Tree } [Test] - public void RunCallsOnBeforeRunTestsMethod() + public void RunCallsOnBeforeBuildMethod() { runTestCommand.Run(); - Assert.IsTrue(runTestCommand.IsOnBeforeRunTestsMethodCalled); + Assert.IsTrue(runTestCommand.IsOnBeforeBuildMethodCalled); } [Test] @@ -132,14 +132,14 @@ namespace UnitTesting.Tests.Tree public void RunningTestCommandPropertyIsSetToRunningCommandWhenOnBeforeRunIsCalled() { runTestCommand.Run(); - Assert.AreEqual(runTestCommand, runTestCommand.RunningTestCommandPropertyWhenOnBeforeRunCalled); + Assert.AreEqual(runTestCommand, runTestCommand.RunningTestCommandPropertyWhenOnBeforeBuildCalled); } [Test] public void IsRunningTestPropertyReturnsTrueWhenOnBeforeRunIsCalled() { runTestCommand.Run(); - Assert.IsTrue(runTestCommand.IsRunningTestPropertyWhenOnBeforeRunCalled); + Assert.IsTrue(runTestCommand.IsRunningTestPropertyWhenOnBeforeBuildCalled); } [Test] diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestsWithoutUnitTestsPadTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestsWithoutUnitTestsPadTestFixture.cs index 91f63cedcb..77fbb9d362 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestsWithoutUnitTestsPadTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestsWithoutUnitTestsPadTestFixture.cs @@ -51,7 +51,7 @@ namespace UnitTesting.Tests.Tree [Test] public void OnBeforeTestsRunMethodIsCalled() { - Assert.IsTrue(runTestCommand.IsOnBeforeRunTestsMethodCalled); + Assert.IsTrue(runTestCommand.IsOnBeforeBuildMethodCalled); } } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/UnitTesting.Tests.csproj b/src/AddIns/Analysis/UnitTesting/Test/UnitTesting.Tests.csproj index d5d3b33a42..35aabcfa2d 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/UnitTesting.Tests.csproj +++ b/src/AddIns/Analysis/UnitTesting/Test/UnitTesting.Tests.csproj @@ -162,6 +162,7 @@ + diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedRunTestCommand.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedRunTestCommand.cs index cc42140a5b..f5121d1990 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedRunTestCommand.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedRunTestCommand.cs @@ -15,10 +15,10 @@ namespace UnitTesting.Tests.Utils { public class DerivedRunTestCommand : AbstractRunTestCommand { - bool onBeforeRunTestsMethodCalled; + bool onBeforeBuildMethodCalled; bool onAfterRunTestsMethodCalled; - AbstractRunTestCommand runningTestCommandWhenOnBeforeRunCalled; - bool runningTestWhenOnBeforeRunCalled; + AbstractRunTestCommand runningTestCommandWhenOnBeforeBuildCalled; + bool runningTestWhenOnBeforeBuildCalled; bool onStopMethodCalled; List helpers = new List(); List testRunnersCreated = new List(); @@ -28,20 +28,20 @@ namespace UnitTesting.Tests.Utils { } - public bool IsOnBeforeRunTestsMethodCalled { - get { return onBeforeRunTestsMethodCalled; } + public bool IsOnBeforeBuildMethodCalled { + get { return onBeforeBuildMethodCalled; } } - public void CallOnBeforeRunTestsMethod() + public void CallOnBeforeBuildMethod() { - OnBeforeRunTests(); + OnBeforeBuild(); } - protected override void OnBeforeRunTests() + protected override void OnBeforeBuild() { - onBeforeRunTestsMethodCalled = true; - runningTestCommandWhenOnBeforeRunCalled = AbstractRunTestCommand.RunningTestCommand; - runningTestWhenOnBeforeRunCalled = AbstractRunTestCommand.IsRunningTest; + onBeforeBuildMethodCalled = true; + runningTestCommandWhenOnBeforeBuildCalled = AbstractRunTestCommand.RunningTestCommand; + runningTestWhenOnBeforeBuildCalled = AbstractRunTestCommand.IsRunningTest; } protected override ITestRunner CreateTestRunner(IProject project) @@ -64,12 +64,12 @@ namespace UnitTesting.Tests.Utils get { return helpers; } } - public AbstractRunTestCommand RunningTestCommandPropertyWhenOnBeforeRunCalled { - get { return runningTestCommandWhenOnBeforeRunCalled; } + public AbstractRunTestCommand RunningTestCommandPropertyWhenOnBeforeBuildCalled { + get { return runningTestCommandWhenOnBeforeBuildCalled; } } - public bool IsRunningTestPropertyWhenOnBeforeRunCalled { - get { return runningTestWhenOnBeforeRunCalled; } + public bool IsRunningTestPropertyWhenOnBeforeBuildCalled { + get { return runningTestWhenOnBeforeBuildCalled; } } public bool IsOnStopMethodCalled { diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockMessageService.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockMessageService.cs index 8ce577054c..ed796b5d2f 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockMessageService.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockMessageService.cs @@ -6,11 +6,12 @@ // using System; +using ICSharpCode.Core.Services; using ICSharpCode.UnitTesting; namespace UnitTesting.Tests.Utils { - public class MockMessageService : IUnitTestMessageService + public class MockMessageService : IMessageService { string question; string caption; @@ -35,5 +36,45 @@ namespace UnitTesting.Tests.Utils public string Caption { get { return caption; } } + + void IMessageService.ShowError(string message) + { + throw new NotImplementedException(); + } + + void IMessageService.ShowException(Exception ex, string message) + { + throw new NotImplementedException(); + } + + void IMessageService.ShowWarning(string message) + { + throw new NotImplementedException(); + } + + int IMessageService.ShowCustomDialog(string caption, string dialogText, int acceptButtonIndex, int cancelButtonIndex, params string[] buttontexts) + { + throw new NotImplementedException(); + } + + string IMessageService.ShowInputBox(string caption, string dialogText, string defaultValue) + { + throw new NotImplementedException(); + } + + void IMessageService.ShowMessage(string message, string caption) + { + throw new NotImplementedException(); + } + + void IMessageService.InformSaveError(string fileName, string message, string dialogName, Exception exceptionGot) + { + throw new NotImplementedException(); + } + + ChooseSaveErrorResult IMessageService.ChooseSaveError(string fileName, string message, string dialogName, Exception exceptionGot, bool chooseLocationEnabled) + { + throw new NotImplementedException(); + } } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestFramework.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestFramework.cs index 66c75e5b76..48a7623480 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestFramework.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestFramework.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; using ICSharpCode.Core; +using ICSharpCode.Core.Services; using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; @@ -22,7 +23,7 @@ namespace UnitTesting.Tests.Utils ITestResultsMonitor testResultsMonitor; UnitTestingOptions options; IUnitTestDebuggerService debuggerService; - IUnitTestMessageService messageService; + IMessageService messageService; public MockNUnitTestFramework(IUnitTestProcessRunner processRunner, ITestResultsMonitor testResultsMonitor, @@ -34,7 +35,7 @@ namespace UnitTesting.Tests.Utils public MockNUnitTestFramework(IUnitTestDebuggerService debuggerService, ITestResultsMonitor testResultsMonitor, UnitTestingOptions options, - IUnitTestMessageService messageService) + IMessageService messageService) : this(debuggerService, null, testResultsMonitor, options, messageService) { } @@ -43,7 +44,7 @@ namespace UnitTesting.Tests.Utils IUnitTestProcessRunner processRunner, ITestResultsMonitor testResultsMonitor, UnitTestingOptions options, - IUnitTestMessageService messageService) + IMessageService messageService) { this.debuggerService = debuggerService; this.processRunner = processRunner; diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockRunTestCommandContext.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockRunTestCommandContext.cs index ef246e526c..cebf79d190 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockRunTestCommandContext.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockRunTestCommandContext.cs @@ -7,6 +7,7 @@ using System; using ICSharpCode.Core; +using ICSharpCode.Core.Services; using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.UnitTesting; @@ -25,6 +26,7 @@ namespace UnitTesting.Tests.Utils MockUnitTestsPad unitTestsPad = new MockUnitTestsPad(); MockMessageService messageService = new MockMessageService(); MockSaveAllFilesCommand saveAllFilesCommand = new MockSaveAllFilesCommand(); + MockStatusBarService statusBarService = new MockStatusBarService(); public UnitTestingOptions UnitTestingOptions { get { return options; } @@ -87,7 +89,7 @@ namespace UnitTesting.Tests.Utils set { unitTestsPad = value; } } - public IUnitTestMessageService MessageService { + public IMessageService MessageService { get { return messageService; } } @@ -102,5 +104,9 @@ namespace UnitTesting.Tests.Utils public MockSaveAllFilesCommand MockSaveAllFilesCommand { get { return saveAllFilesCommand; } } + + public IStatusBarService StatusBarService { + get { return statusBarService; } + } } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockStatusBarService.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockStatusBarService.cs new file mode 100644 index 0000000000..ad8b581f2a --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockStatusBarService.cs @@ -0,0 +1,35 @@ +// +// +// +// +// $Revision$ +// +using System; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Gui; + +namespace UnitTesting.Tests.Utils +{ + public class MockStatusBarService : IStatusBarService + { + public void SetCaretPosition(int x, int y, int charOffset) + { + throw new NotImplementedException(); + } + + public void SetMessage(string message, bool highlighted, IImage icon) + { + throw new NotImplementedException(); + } + + public IProgressMonitor CreateProgressMonitor(System.Threading.CancellationToken cancellationToken) + { + return new DummyProgressMonitor(); + } + + public void AddProgress(ProgressCollector progress) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/DerivedRunTestCommandTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/DerivedRunTestCommandTestFixture.cs index 8c37ad3864..31a526f40f 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/DerivedRunTestCommandTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/DerivedRunTestCommandTestFixture.cs @@ -34,46 +34,46 @@ namespace UnitTesting.Tests.Utils.Tests [Test] public void IsOnBeforeRunTestsMethodCalledReturnsFalseByDefault() { - Assert.IsFalse(runTestCommand.IsOnBeforeRunTestsMethodCalled); + Assert.IsFalse(runTestCommand.IsOnBeforeBuildMethodCalled); } [Test] public void IsOnBeforeRunTestsMethodCalledReturnsTrueAfterOnBeforeRunMethodCalled() { - runTestCommand.CallOnBeforeRunTestsMethod(); - Assert.IsTrue(runTestCommand.IsOnBeforeRunTestsMethodCalled); + runTestCommand.CallOnBeforeBuildMethod(); + Assert.IsTrue(runTestCommand.IsOnBeforeBuildMethodCalled); } [Test] public void IsRunningTestPropertyWhenOnBeforeRunCalledReturnsFalseByDefault() { AbstractRunTestCommand.RunningTestCommand = null; - runTestCommand.CallOnBeforeRunTestsMethod(); - Assert.IsFalse(runTestCommand.IsRunningTestPropertyWhenOnBeforeRunCalled); + runTestCommand.CallOnBeforeBuildMethod(); + Assert.IsFalse(runTestCommand.IsRunningTestPropertyWhenOnBeforeBuildCalled); } [Test] public void IsRunningTestPropertyWhenOnBeforeRunCalledReturnsTrueWhenRunningTestCommandIsNonNullWhenOnBeforeRunMethodCalled() { AbstractRunTestCommand.RunningTestCommand = runTestCommand; - runTestCommand.CallOnBeforeRunTestsMethod(); - Assert.IsTrue(runTestCommand.IsRunningTestPropertyWhenOnBeforeRunCalled); + runTestCommand.CallOnBeforeBuildMethod(); + Assert.IsTrue(runTestCommand.IsRunningTestPropertyWhenOnBeforeBuildCalled); } [Test] public void RunningTestCommandPropertyWhenOnBeforeRunCalledReturnsNullByDefault() { AbstractRunTestCommand.RunningTestCommand = null; - runTestCommand.CallOnBeforeRunTestsMethod(); - Assert.IsNull(runTestCommand.RunningTestCommandPropertyWhenOnBeforeRunCalled); + runTestCommand.CallOnBeforeBuildMethod(); + Assert.IsNull(runTestCommand.RunningTestCommandPropertyWhenOnBeforeBuildCalled); } [Test] public void RunningTestCommandPropertyWhenOnBeforeRunCalledReturnsNonNullWhenRunningTestCommandIsNonNullWhenOnBeforeRunMethodCalled() { AbstractRunTestCommand.RunningTestCommand = runTestCommand; - runTestCommand.CallOnBeforeRunTestsMethod(); - Assert.AreEqual(runTestCommand, runTestCommand.RunningTestCommandPropertyWhenOnBeforeRunCalled); + runTestCommand.CallOnBeforeBuildMethod(); + Assert.AreEqual(runTestCommand, runTestCommand.RunningTestCommandPropertyWhenOnBeforeBuildCalled); } [Test] diff --git a/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj b/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj index 191ceb2998..25150b7af0 100644 --- a/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj +++ b/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj @@ -63,7 +63,6 @@ - @@ -86,7 +85,6 @@ - diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestDebugger.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestDebugger.cs index 1adaaf4a15..7965957939 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestDebugger.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestDebugger.cs @@ -7,6 +7,7 @@ using System; using System.Diagnostics; +using ICSharpCode.Core.Services; using ICSharpCode.UnitTesting; namespace ICSharpCode.PythonBinding @@ -20,7 +21,7 @@ namespace ICSharpCode.PythonBinding public PythonTestDebugger() : this(new UnitTestDebuggerService(), - new UnitTestMessageService(), + ServiceManager.Instance.MessageService, new TestResultsMonitor(), new PythonAddInOptions(), new PythonStandardLibraryPath(), @@ -29,7 +30,7 @@ namespace ICSharpCode.PythonBinding } public PythonTestDebugger(IUnitTestDebuggerService debuggerService, - IUnitTestMessageService messageService, + IMessageService messageService, ITestResultsMonitor testResultsMonitor, PythonAddInOptions options, PythonStandardLibraryPath pythonStandardLibraryPath, diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbench.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbench.cs index a461e47415..479a15bcd2 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbench.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbench.cs @@ -40,6 +40,10 @@ namespace PythonBinding.Tests.Utils get { return null; } } + public IStatusBarService StatusBar { + get { throw new NotImplementedException(); } + } + public string Title { get { throw new NotImplementedException(); diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockWorkbench.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockWorkbench.cs index 6f2e9b453e..159821aefd 100644 --- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockWorkbench.cs +++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockWorkbench.cs @@ -37,6 +37,10 @@ namespace RubyBinding.Tests.Utils get { return null; } } + public IStatusBarService StatusBar { + get { throw new NotImplementedException(); } + } + public string Title { get { throw new NotImplementedException(); diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockWorkbench.cs b/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockWorkbench.cs index d19759e62e..7291dec58b 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockWorkbench.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockWorkbench.cs @@ -42,6 +42,10 @@ namespace WixBinding.Tests.Utils } } + public IStatusBarService StatusBar { + get { throw new NotImplementedException(); } + } + public string Title { get { throw new NotImplementedException(); diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs index 8b30bc13ed..02789c7570 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs @@ -178,7 +178,7 @@ namespace ICSharpCode.AvalonEdit.AddIn void CaretChanged(object sender, EventArgs e) { NavigationService.Log(this.BuildNavPoint()); - StatusBarService.SetCaretPosition(this.Column, this.Line, this.Column); + WorkbenchSingleton.StatusBar.SetCaretPosition(this.Column, this.Line, this.Column); } public override bool IsReadOnly { diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/IncrementalSearch.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/IncrementalSearch.cs index f0d6f6c7a6..f65d3bcdf9 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/IncrementalSearch.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/IncrementalSearch.cs @@ -6,8 +6,8 @@ // using System; -using System.Text; using System.Linq; +using System.Text; using System.Windows; using System.Windows.Documents; using System.Windows.Input; @@ -16,6 +16,7 @@ using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.Core; using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Gui; namespace ICSharpCode.AvalonEdit.AddIn { @@ -145,7 +146,7 @@ namespace ICSharpCode.AvalonEdit.AddIn } string fullMessage = incrementalSearchStartMessage + message; - StatusBarService.SetMessage(fullMessage, highlight); + WorkbenchSingleton.StatusBar.SetMessage(fullMessage, highlight); } /// @@ -162,7 +163,7 @@ namespace ICSharpCode.AvalonEdit.AddIn /// void ClearStatusBarMessage() { - StatusBarService.SetMessage(String.Empty); + WorkbenchSingleton.StatusBar.SetMessage(String.Empty); } #endregion diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockWorkbench.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockWorkbench.cs index 4eeb1c08b4..902acf0784 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockWorkbench.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockWorkbench.cs @@ -82,6 +82,12 @@ namespace XmlEditor.Tests.Utils } } + public IStatusBarService StatusBar { + get { + throw new NotImplementedException(); + } + } + public string Title { get { throw new NotImplementedException(); diff --git a/src/Main/Base/Project/Src/Gui/BrowserDisplayBinding/HtmlViewPane.cs b/src/Main/Base/Project/Src/Gui/BrowserDisplayBinding/HtmlViewPane.cs index ab7d4605ba..3d6561c726 100644 --- a/src/Main/Base/Project/Src/Gui/BrowserDisplayBinding/HtmlViewPane.cs +++ b/src/Main/Base/Project/Src/Gui/BrowserDisplayBinding/HtmlViewPane.cs @@ -151,7 +151,7 @@ namespace ICSharpCode.SharpDevelop.BrowserDisplayBinding BrowserPane browser = workbench.ActiveViewContent as BrowserPane; if (browser == null) return; if (browser.HtmlViewPane == this) { - StatusBarService.SetMessage(webBrowser.StatusText); + WorkbenchSingleton.StatusBar.SetMessage(webBrowser.StatusText); } } diff --git a/src/Main/Base/Project/Src/Gui/Components/StatusBar/SdStatusBar.cs b/src/Main/Base/Project/Src/Gui/Components/StatusBar/SdStatusBar.cs index e2894ea88a..d781e66eac 100644 --- a/src/Main/Base/Project/Src/Gui/Components/StatusBar/SdStatusBar.cs +++ b/src/Main/Base/Project/Src/Gui/Components/StatusBar/SdStatusBar.cs @@ -67,21 +67,6 @@ namespace ICSharpCode.SharpDevelop.Gui Items.Add(txtStatusBarPanel); } - public void ShowErrorMessage(string message) - { - SetMessage("Error : " + message); - } - - public void ShowErrorMessage(BitmapSource image, string message) - { - SetMessage(image, "Error : " + message); - } - - public void SetMessage(string message) - { - SetMessage(message, false); - } - public void SetMessage(string message, bool highlighted) { Action setMessageAction = delegate { @@ -100,11 +85,6 @@ namespace ICSharpCode.SharpDevelop.Gui setMessageAction(); } - public void SetMessage(BitmapSource image, string message) - { - SetMessage(message); - } - // Displaying progress bool statusProgressBarIsVisible; diff --git a/src/Main/Base/Project/Src/Gui/IWorkbench.cs b/src/Main/Base/Project/Src/Gui/IWorkbench.cs index 498dba8988..43f083c330 100644 --- a/src/Main/Base/Project/Src/Gui/IWorkbench.cs +++ b/src/Main/Base/Project/Src/Gui/IWorkbench.cs @@ -35,6 +35,11 @@ namespace ICSharpCode.SharpDevelop.Gui /// Window MainWindow { get; } + /// + /// Gets the status bar. + /// + IStatusBarService StatusBar { get; } + /// /// Gets/Sets whether the window is displayed in full-screen mode. /// diff --git a/src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs b/src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs index 61d278c7b3..33b07d9323 100644 --- a/src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs +++ b/src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs @@ -57,6 +57,7 @@ namespace ICSharpCode.SharpDevelop.Gui public System.Windows.Forms.IWin32Window MainWin32Window { get { return this; } } public ISynchronizeInvoke SynchronizingObject { get; private set; } public Window MainWindow { get { return this; } } + public IStatusBarService StatusBar { get; private set; } IntPtr System.Windows.Forms.IWin32Window.Handle { get { @@ -69,12 +70,13 @@ namespace ICSharpCode.SharpDevelop.Gui } List padDescriptorCollection = new List(); - + SdStatusBar statusBar = new SdStatusBar(); ToolBar[] toolBars; public WpfWorkbench() { this.SynchronizingObject = new WpfSynchronizeInvoke(this.Dispatcher); + this.StatusBar = new SdStatusBarService(statusBar); InitializeComponent(); InitFocusTrackingEvents(); } @@ -100,8 +102,8 @@ namespace ICSharpCode.SharpDevelop.Gui DockPanel.SetDock(tb, Dock.Top); dockPanel.Children.Insert(1, tb); } - DockPanel.SetDock(StatusBarService.Control, Dock.Bottom); - dockPanel.Children.Insert(dockPanel.Children.Count - 2, StatusBarService.Control); + DockPanel.SetDock(statusBar, Dock.Bottom); + dockPanel.Children.Insert(dockPanel.Children.Count - 2, statusBar); UpdateMenu(); @@ -119,7 +121,7 @@ namespace ICSharpCode.SharpDevelop.Gui CommandManager.RequerySuggested += requerySuggestedEventHandler; ResourceService.LanguageChanged += OnLanguageChanged; - StatusBarService.SetMessage("${res:MainWindow.StatusBar.ReadyMessage}"); + this.StatusBar.SetMessage("${res:MainWindow.StatusBar.ReadyMessage}"); } // keep a reference to the event handler to prevent it from being garbage collected @@ -663,14 +665,14 @@ namespace ICSharpCode.SharpDevelop.Gui } if (!e.Handled && e.Key == Key.L && e.KeyboardDevice.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt)) { this.UseLayoutRounding = !this.UseLayoutRounding; - StatusBarService.SetMessage("UseLayoutRounding=" + this.UseLayoutRounding); + this.StatusBar.SetMessage("UseLayoutRounding=" + this.UseLayoutRounding); } if (!e.Handled && e.Key == Key.F && e.KeyboardDevice.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt)) { if (TextOptions.GetTextFormattingMode(this) == TextFormattingMode.Display) TextOptions.SetTextFormattingMode(this, TextFormattingMode.Ideal); else TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display); - StatusBarService.SetMessage("TextFormattingMode=" + TextOptions.GetTextFormattingMode(this)); + this.StatusBar.SetMessage("TextFormattingMode=" + TextOptions.GetTextFormattingMode(this)); } if (!e.Handled && e.Key == Key.R && e.KeyboardDevice.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt)) { switch (TextOptions.GetTextRenderingMode(this)) { @@ -685,7 +687,7 @@ namespace ICSharpCode.SharpDevelop.Gui TextOptions.SetTextRenderingMode(this, TextRenderingMode.ClearType); break; } - StatusBarService.SetMessage("TextRenderingMode=" + TextOptions.GetTextRenderingMode(this)); + this.StatusBar.SetMessage("TextRenderingMode=" + TextOptions.GetTextRenderingMode(this)); } } diff --git a/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs b/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs index ec521c0b4a..82470dbb9f 100644 --- a/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs +++ b/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs @@ -57,6 +57,12 @@ namespace ICSharpCode.SharpDevelop.Gui } } + public static IStatusBarService StatusBar { + get { + return workbench != null ? workbench.StatusBar : null; + } + } + public static void InitializeWorkbench(IWorkbench workbench, IWorkbenchLayout layout) { WorkbenchSingleton.workbench = workbench; @@ -64,7 +70,6 @@ namespace ICSharpCode.SharpDevelop.Gui DisplayBindingService.InitializeService(); LayoutConfiguration.LoadLayoutConfiguration(); FileService.InitializeService(); - StatusBarService.Initialize(); DomHostCallback.Register(); // must be called after StatusBarService.Initialize() ParserService.InitializeParserService(); TaskService.Initialize(); diff --git a/src/Main/Base/Project/Src/Project/BuildEngine.cs b/src/Main/Base/Project/Src/Project/BuildEngine.cs index 3947ea7ca5..289c88e257 100644 --- a/src/Main/Base/Project/Src/Project/BuildEngine.cs +++ b/src/Main/Base/Project/Src/Project/BuildEngine.cs @@ -7,10 +7,10 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading; - using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Gui; @@ -44,7 +44,7 @@ namespace ICSharpCode.SharpDevelop.Project WorkbenchSingleton.AssertMainThread(); if (guiBuildCancellation != null) { BuildResults results = new BuildResults(); - StatusBarService.ShowErrorMessage(Core.ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning")); + WorkbenchSingleton.StatusBar.SetMessage(Core.ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning")); BuildError error = new BuildError(null, Core.ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning")); results.Add(error); TaskService.Add(new Task(error)); @@ -54,12 +54,12 @@ namespace ICSharpCode.SharpDevelop.Project } } else { guiBuildCancellation = new CancellationTokenSource(); - IProgressMonitor progressMonitor = StatusBarService.CreateProgressMonitor(guiBuildCancellation.Token); + IProgressMonitor progressMonitor = WorkbenchSingleton.StatusBar.CreateProgressMonitor(guiBuildCancellation.Token); guiBuildTrackedFeature = AnalyticsMonitorService.TrackFeature("Build"); - StatusBarService.SetMessage(StringParser.Parse("${res:MainWindow.CompilerMessages.BuildVerb}...")); + WorkbenchSingleton.StatusBar.SetMessage(StringParser.Parse("${res:MainWindow.CompilerMessages.BuildVerb}...")); ProjectService.RaiseEventBuildStarted(new BuildEventArgs(project, options)); StartBuild(project, options, - new MessageViewSink(TaskService.BuildMessageViewCategory, progressMonitor)); + new MessageViewSink(TaskService.BuildMessageViewCategory, progressMonitor, WorkbenchSingleton.StatusBar)); } } @@ -90,13 +90,19 @@ namespace ICSharpCode.SharpDevelop.Project /// sealed class MessageViewSink : IBuildFeedbackSink { - Gui.MessageViewCategory messageView; - Gui.IProgressMonitor progressMonitor; + MessageViewCategory messageView; + IProgressMonitor progressMonitor; + IStatusBarService statusBarService; - public MessageViewSink(MessageViewCategory messageView, Gui.IProgressMonitor progressMonitor) + public MessageViewSink(MessageViewCategory messageView, IProgressMonitor progressMonitor, IStatusBarService statusBarService) { + Debug.Assert(messageView != null); + Debug.Assert(progressMonitor != null); + Debug.Assert(statusBarService != null); + this.messageView = messageView; this.progressMonitor = progressMonitor; + this.statusBarService = statusBarService; } public IProgressMonitor ProgressMonitor { @@ -144,7 +150,7 @@ namespace ICSharpCode.SharpDevelop.Project if (results.WarningCount > 0) message += " " + results.WarningCount + " warning(s)"; } - StatusBarService.SetMessage(StringParser.Parse(message)); + statusBarService.SetMessage(message); ProjectService.RaiseEventBuildFinished(new BuildEventArgs(buildable, options, results)); }); } diff --git a/src/Main/Base/Project/Src/Services/ParserService/LoadSolutionProjects.cs b/src/Main/Base/Project/Src/Services/ParserService/LoadSolutionProjects.cs index 398f004e6f..6880dd3691 100644 --- a/src/Main/Base/Project/Src/Services/ParserService/LoadSolutionProjects.cs +++ b/src/Main/Base/Project/Src/Services/ParserService/LoadSolutionProjects.cs @@ -203,7 +203,7 @@ namespace ICSharpCode.SharpDevelop if (!this.threadIsRunning && this.actions.Count > 0) { this.threadIsRunning = true; - progressMonitor = StatusBarService.CreateProgressMonitor(cancellationSource.Token); + progressMonitor = WorkbenchSingleton.StatusBar.CreateProgressMonitor(cancellationSource.Token); progressMonitor.TaskName = this.actions.Peek().name; Thread thread = new Thread(new ThreadStart(RunThread)); diff --git a/src/Main/Base/Project/Src/Services/StatusBar/StatusBarService.cs b/src/Main/Base/Project/Src/Services/StatusBar/StatusBarService.cs index db82f1f01c..6340f4e446 100644 --- a/src/Main/Base/Project/Src/Services/StatusBar/StatusBarService.cs +++ b/src/Main/Base/Project/Src/Services/StatusBar/StatusBarService.cs @@ -8,45 +8,71 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Drawing; -using System.Linq; using System.Threading; using System.Windows; -using System.Windows.Media.Imaging; using ICSharpCode.Core; -using ICSharpCode.SharpDevelop.Gui; -namespace ICSharpCode.SharpDevelop +namespace ICSharpCode.SharpDevelop.Gui { - public static class StatusBarService + public interface IStatusBarService { - static SdStatusBar statusBar = null; + //bool Visible { get; set; } + + /// + /// Sets the caret position shown in the status bar. + /// + /// column number + /// line number + /// character number + void SetCaretPosition(int x, int y, int charOffset); + //void SetInsertMode(bool insertMode); + + /// + /// Sets the message shown in the left-most pane in the status bar. + /// + /// The message text. + /// Whether to highlight the text + /// Icon to show next to the text + void SetMessage(string message, bool highlighted = false, IImage icon = null); + + /// + /// Creates a new that can be used to report + /// progress to the status bar. + /// + /// Cancellation token to use for + /// + /// The new IProgressMonitor instance. This return value must be disposed + /// once the background task has completed. + IProgressMonitor CreateProgressMonitor(CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Shows progress for the specified ProgressCollector in the status bar. + /// + void AddProgress(ProgressCollector progress); + } + + sealed class SdStatusBarService : IStatusBarService + { + readonly SdStatusBar statusBar; - internal static void Initialize() + public SdStatusBarService(SdStatusBar statusBar) { - statusBar = new SdStatusBar(); + if (statusBar == null) + throw new ArgumentNullException("statusBar"); + this.statusBar = statusBar; } - public static bool Visible { + public bool Visible { get { - System.Diagnostics.Debug.Assert(statusBar != null); return statusBar.Visibility == Visibility.Visible; } set { - System.Diagnostics.Debug.Assert(statusBar != null); statusBar.Visibility = value ? Visibility.Visible : Visibility.Collapsed; } } - internal static SdStatusBar Control { - get { - System.Diagnostics.Debug.Assert(statusBar != null); - return statusBar; - } - } - - public static void SetCaretPosition(int x, int y, int charOffset) + public void SetCaretPosition(int x, int y, int charOffset) { statusBar.CursorStatusBarPanel.Content = StringParser.Parse( "${res:StatusBarService.CursorStatusBarPanelText}", @@ -57,65 +83,31 @@ namespace ICSharpCode.SharpDevelop }); } - public static void SetInsertMode(bool insertMode) + public void SetInsertMode(bool insertMode) { statusBar.ModeStatusBarPanel.Content = insertMode ? StringParser.Parse("${res:StatusBarService.CaretModes.Insert}") : StringParser.Parse("${res:StatusBarService.CaretModes.Overwrite}"); } - public static void ShowErrorMessage(string message) + public void SetMessage(string message, bool highlighted, IImage icon) { - System.Diagnostics.Debug.Assert(statusBar != null); - statusBar.ShowErrorMessage(StringParser.Parse(message)); - } - - public static void SetMessage(string message) - { - System.Diagnostics.Debug.Assert(statusBar != null); - lastMessage = message; - statusBar.SetMessage(StringParser.Parse(message)); - } - - public static void SetMessage(BitmapSource image, string message) - { - System.Diagnostics.Debug.Assert(statusBar != null); - statusBar.SetMessage(image, StringParser.Parse(message)); - } - - public static void SetMessage(string message, bool highlighted) - { - statusBar.SetMessage(message, highlighted); - } - - static bool wasError = false; - static string lastMessage = ""; - - public static void RedrawStatusbar() - { - if (wasError) { - ShowErrorMessage(lastMessage); - } else { - SetMessage(lastMessage); - } - - Visible = PropertyService.Get("ICSharpCode.SharpDevelop.Gui.StatusBarVisible", true); + statusBar.SetMessage(StringParser.Parse(message), highlighted); } #region Progress Monitor - static Stack waitingProgresses = new Stack(); - static ProgressCollector currentProgress; + Stack waitingProgresses = new Stack(); + ProgressCollector currentProgress; - public static IProgressMonitor CreateProgressMonitor(CancellationToken cancellationToken) + public IProgressMonitor CreateProgressMonitor(CancellationToken cancellationToken = default(CancellationToken)) { ProgressCollector progress = new ProgressCollector(WorkbenchSingleton.Workbench.SynchronizingObject, cancellationToken); AddProgress(progress); return progress.ProgressMonitor; } - public static void AddProgress(ProgressCollector progress) + public void AddProgress(ProgressCollector progress) { if (progress == null) throw new ArgumentNullException("progress"); - System.Diagnostics.Debug.Assert(statusBar != null); WorkbenchSingleton.AssertMainThread(); if (currentProgress != null) { currentProgress.ProgressMonitorDisposed -= progress_ProgressMonitorDisposed; @@ -125,7 +117,7 @@ namespace ICSharpCode.SharpDevelop SetActiveProgress(progress); } - static void SetActiveProgress(ProgressCollector progress) + void SetActiveProgress(ProgressCollector progress) { WorkbenchSingleton.AssertMainThread(); currentProgress = progress; @@ -142,13 +134,13 @@ namespace ICSharpCode.SharpDevelop progress.PropertyChanged += progress_PropertyChanged; } - static void progress_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + void progress_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { Debug.Assert(sender == currentProgress); statusBar.DisplayProgress(currentProgress.TaskName, currentProgress.Progress, currentProgress.Status); } - static void progress_ProgressMonitorDisposed(object sender, EventArgs e) + void progress_ProgressMonitorDisposed(object sender, EventArgs e) { Debug.Assert(sender == currentProgress); SetActiveProgress(waitingProgresses.Pop()); // stack is never empty: we push null as first element