Browse Source

Show progress running unit tests in status bar.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@6050 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Daniel Grunwald 15 years ago
parent
commit
6cb65113c4
  1. 9
      data/resources/StringResources.de.resx
  2. 3
      data/resources/StringResources.pl.resx
  3. 3
      data/resources/StringResources.resx
  4. 35
      src/AddIns/Analysis/UnitTesting/Src/AbstractRunTestCommands.cs
  5. 4
      src/AddIns/Analysis/UnitTesting/Src/IRunTestCommandContext.cs
  6. 17
      src/AddIns/Analysis/UnitTesting/Src/IUnitTestMessageService.cs
  7. 5
      src/AddIns/Analysis/UnitTesting/Src/NUnitTestDebugger.cs
  8. 10
      src/AddIns/Analysis/UnitTesting/Src/RunTestCommandContext.cs
  9. 7
      src/AddIns/Analysis/UnitTesting/Src/TestDebuggerBase.cs
  10. 20
      src/AddIns/Analysis/UnitTesting/Src/UnitTestMessageService.cs
  11. 2
      src/AddIns/Analysis/UnitTesting/Test/Tree/NoTestsRunWhenNoTestsSelectedTestFixture.cs
  12. 2
      src/AddIns/Analysis/UnitTesting/Test/Tree/NoTestsRunWhenUnitTestPadNotCreatedTestFixture.cs
  13. 8
      src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestCommandBeforeRunTestFixture.cs
  14. 2
      src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestsWithoutUnitTestsPadTestFixture.cs
  15. 1
      src/AddIns/Analysis/UnitTesting/Test/UnitTesting.Tests.csproj
  16. 30
      src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedRunTestCommand.cs
  17. 43
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockMessageService.cs
  18. 7
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestFramework.cs
  19. 8
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockRunTestCommandContext.cs
  20. 35
      src/AddIns/Analysis/UnitTesting/Test/Utils/MockStatusBarService.cs
  21. 22
      src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/DerivedRunTestCommandTestFixture.cs
  22. 2
      src/AddIns/Analysis/UnitTesting/UnitTesting.csproj
  23. 5
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestDebugger.cs
  24. 4
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbench.cs
  25. 4
      src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockWorkbench.cs
  26. 4
      src/AddIns/BackendBindings/WixBinding/Test/Utils/MockWorkbench.cs
  27. 2
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs
  28. 7
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/IncrementalSearch.cs
  29. 6
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockWorkbench.cs
  30. 2
      src/Main/Base/Project/Src/Gui/BrowserDisplayBinding/HtmlViewPane.cs
  31. 20
      src/Main/Base/Project/Src/Gui/Components/StatusBar/SdStatusBar.cs
  32. 5
      src/Main/Base/Project/Src/Gui/IWorkbench.cs
  33. 16
      src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs
  34. 7
      src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs
  35. 24
      src/Main/Base/Project/Src/Project/BuildEngine.cs
  36. 2
      src/Main/Base/Project/Src/Services/ParserService/LoadSolutionProjects.cs
  37. 120
      src/Main/Base/Project/Src/Services/StatusBar/StatusBarService.cs

9
data/resources/StringResources.de.resx

@ -2486,7 +2486,7 @@ Wollen Sie die neue Datei zum Projekt ${CurrentProjectName} hinzufügen?</value>
<value>&amp;Benutzerspezifische Daten mit Dokument laden</value> <value>&amp;Benutzerspezifische Daten mit Dokument laden</value>
</data> </data>
<data name="Dialog.Options.IDEOptions.LoadSaveOptions.MacintoshRadioButton" xml:space="preserve"> <data name="Dialog.Options.IDEOptions.LoadSaveOptions.MacintoshRadioButton" xml:space="preserve">
<value>Macintosh</value> <value>Macintosh (CR)</value>
</data> </data>
<data name="Dialog.Options.IDEOptions.LoadSaveOptions.PanelName" xml:space="preserve"> <data name="Dialog.Options.IDEOptions.LoadSaveOptions.PanelName" xml:space="preserve">
<value>Laden/Speichern</value> <value>Laden/Speichern</value>
@ -2495,13 +2495,13 @@ Wollen Sie die neue Datei zum Projekt ${CurrentProjectName} hinzufügen?</value>
<value>Speichern</value> <value>Speichern</value>
</data> </data>
<data name="Dialog.Options.IDEOptions.LoadSaveOptions.UnixRadioButton" xml:space="preserve"> <data name="Dialog.Options.IDEOptions.LoadSaveOptions.UnixRadioButton" xml:space="preserve">
<value>Unix</value> <value>Unix (LF)</value>
</data> </data>
<data name="Dialog.Options.IDEOptions.LoadSaveOptions.UseRecycleBin" xml:space="preserve"> <data name="Dialog.Options.IDEOptions.LoadSaveOptions.UseRecycleBin" xml:space="preserve">
<value>&amp;Papierkorb zum Löschen von Dateien verwenden</value> <value>&amp;Papierkorb zum Löschen von Dateien verwenden</value>
</data> </data>
<data name="Dialog.Options.IDEOptions.LoadSaveOptions.WindowsRadioButton" xml:space="preserve"> <data name="Dialog.Options.IDEOptions.LoadSaveOptions.WindowsRadioButton" xml:space="preserve">
<value>Windows</value> <value>Windows (CRLF)</value>
</data> </data>
<data name="Dialog.Options.IDEOptions.OutputPanel.Format" xml:space="preserve"> <data name="Dialog.Options.IDEOptions.OutputPanel.Format" xml:space="preserve">
<value>Format</value> <value>Format</value>
@ -3627,6 +3627,9 @@ Bitte einen anderen Dateinamen wählen.</value>
<data name="Hornung.ResourceToolkit.ValueLabel" xml:space="preserve"> <data name="Hornung.ResourceToolkit.ValueLabel" xml:space="preserve">
<value>Ressourceninhalt:</value> <value>Ressourceninhalt:</value>
</data> </data>
<data name="ICSharpCode.AvalonEdit.AddIn.SharpDevelopCompletionWindow.EmptyText" xml:space="preserve">
<value>Drücken Sie Strg+Leertaste, um Elemente aus allen Namespaces anzuzeigen</value>
</data>
<data name="ICSharpCode.BooInterpreter" xml:space="preserve"> <data name="ICSharpCode.BooInterpreter" xml:space="preserve">
<value>Boo-Interpreter</value> <value>Boo-Interpreter</value>
</data> </data>

3
data/resources/StringResources.pl.resx

@ -229,6 +229,9 @@ Pobierz Dodatek z Internetu, potem kliknij "Instaluj Dodatek" i wskaż pobrany
<data name="AddInManager.UnknownFileFormat" xml:space="preserve"> <data name="AddInManager.UnknownFileFormat" xml:space="preserve">
<value>Nieznany format pliku:</value> <value>Nieznany format pliku:</value>
</data> </data>
<data name="AddIns.ClassDiagram.ShowClassDiagram" xml:space="preserve">
<value>Pokaż Diagram Klas</value>
</data>
<data name="AddIns.HtmlHelp2.AddToFavorites" xml:space="preserve"> <data name="AddIns.HtmlHelp2.AddToFavorites" xml:space="preserve">
<value>Dodaj do Ulubionych Pomocy</value> <value>Dodaj do Ulubionych Pomocy</value>
</data> </data>

3
data/resources/StringResources.resx

@ -4826,6 +4826,9 @@ Goto 'Options-&gt;Visual Style' and change the current language ambience.</value
<data name="ICSharpCode.UnitTesting.RunWithDebugger" xml:space="preserve"> <data name="ICSharpCode.UnitTesting.RunWithDebugger" xml:space="preserve">
<value>Run with debugger</value> <value>Run with debugger</value>
</data> </data>
<data name="ICSharpCode.UnitTesting.StatusBarProgressLabel" xml:space="preserve">
<value>Testing ${Name}...</value>
</data>
<data name="ICSharpCode.UnitTesting.TestMenu" xml:space="preserve"> <data name="ICSharpCode.UnitTesting.TestMenu" xml:space="preserve">
<value>&amp;Test</value> <value>&amp;Test</value>
</data> </data>

35
src/AddIns/Analysis/UnitTesting/Src/AbstractRunTestCommands.cs

@ -90,7 +90,7 @@ namespace ICSharpCode.UnitTesting
UpdateUnitTestsPadToolbar(); UpdateUnitTestsPadToolbar();
ResetAllTestResultsInUnitTestsPad(); ResetAllTestResultsInUnitTestsPad();
OnBeforeRunTests(); OnBeforeBuild();
} }
void BuildAndRunTests() void BuildAndRunTests()
@ -132,8 +132,16 @@ namespace ICSharpCode.UnitTesting
} }
/// <summary> /// <summary>
/// Called before all tests are run. If multiple projects are /// Called before the build is started (even if no build needs to be performed).
/// to be tested this is called only once. /// If multiple projects are to be tested this is called only once.
/// </summary>
protected virtual void OnBeforeBuild()
{
}
/// <summary>
/// Called before all tests are run (after the build has finished successfully).
/// If multiple projects are to be tested this is called only once.
/// </summary> /// </summary>
protected virtual void OnBeforeRunTests() protected virtual void OnBeforeRunTests()
{ {
@ -202,6 +210,10 @@ namespace ICSharpCode.UnitTesting
if (selectedTests.HasProjects) { if (selectedTests.HasProjects) {
RunTests(selectedTests); RunTests(selectedTests);
} else { } else {
if (testProgressMonitor != null) {
testProgressMonitor.Dispose();
testProgressMonitor = null;
}
runningTestCommand = null; runningTestCommand = null;
UpdateUnitTestsPadToolbar(); UpdateUnitTestsPadToolbar();
ShowErrorList(); ShowErrorList();
@ -218,6 +230,12 @@ namespace ICSharpCode.UnitTesting
{ {
if (IsTestResultFailureOrIsIgnored(result)) { if (IsTestResultFailureOrIsIgnored(result)) {
AddTaskForTestResult(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); UpdateTestResult(result);
} }
@ -284,8 +302,19 @@ namespace ICSharpCode.UnitTesting
return (results.ErrorCount == 0) && IsRunningTest; return (results.ErrorCount == 0) && IsRunningTest;
} }
IProgressMonitor testProgressMonitor;
int totalProjectCount;
void RunTests(SelectedTests selectedTests) 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); testRunner = CreateTestRunner(selectedTests.Project);
if (testRunner != null) { if (testRunner != null) {
testRunner.MessageReceived += TestRunnerMessageReceived; testRunner.MessageReceived += TestRunnerMessageReceived;

4
src/AddIns/Analysis/UnitTesting/Src/IRunTestCommandContext.cs

@ -6,6 +6,7 @@
// </file> // </file>
using System; using System;
using ICSharpCode.Core.Services;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.UnitTesting namespace ICSharpCode.UnitTesting
@ -19,7 +20,8 @@ namespace ICSharpCode.UnitTesting
IBuildOptions BuildOptions { get; } IBuildOptions BuildOptions { get; }
MessageViewCategory UnitTestCategory { get; } MessageViewCategory UnitTestCategory { get; }
IUnitTestsPad OpenUnitTestsPad { get; } IUnitTestsPad OpenUnitTestsPad { get; }
IUnitTestMessageService MessageService { get; } IMessageService MessageService { get; }
IUnitTestSaveAllFilesCommand SaveAllFilesCommand { get; } IUnitTestSaveAllFilesCommand SaveAllFilesCommand { get; }
IStatusBarService StatusBarService { get; }
} }
} }

17
src/AddIns/Analysis/UnitTesting/Src/IUnitTestMessageService.cs

@ -1,17 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
namespace ICSharpCode.UnitTesting
{
public interface IUnitTestMessageService
{
bool AskQuestion(string question, string caption);
}
}

5
src/AddIns/Analysis/UnitTesting/Src/NUnitTestDebugger.cs

@ -7,6 +7,7 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using ICSharpCode.Core.Services;
using ICSharpCode.SharpDevelop.Debugging; using ICSharpCode.SharpDevelop.Debugging;
namespace ICSharpCode.UnitTesting namespace ICSharpCode.UnitTesting
@ -17,14 +18,14 @@ namespace ICSharpCode.UnitTesting
public NUnitTestDebugger() public NUnitTestDebugger()
: this(new UnitTestDebuggerService(), : this(new UnitTestDebuggerService(),
new UnitTestMessageService(), ServiceManager.Instance.MessageService,
new TestResultsMonitor(), new TestResultsMonitor(),
new UnitTestingOptions()) new UnitTestingOptions())
{ {
} }
public NUnitTestDebugger(IUnitTestDebuggerService debuggerService, public NUnitTestDebugger(IUnitTestDebuggerService debuggerService,
IUnitTestMessageService messageService, IMessageService messageService,
ITestResultsMonitor testResultsMonitor, ITestResultsMonitor testResultsMonitor,
UnitTestingOptions options) UnitTestingOptions options)
: base(debuggerService, messageService, testResultsMonitor) : base(debuggerService, messageService, testResultsMonitor)

10
src/AddIns/Analysis/UnitTesting/Src/RunTestCommandContext.cs

@ -6,6 +6,7 @@
// </file> // </file>
using System; using System;
using ICSharpCode.Core.Services;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.UnitTesting namespace ICSharpCode.UnitTesting
@ -19,8 +20,9 @@ namespace ICSharpCode.UnitTesting
UnitTestBuildProjectFactory buildProjectFactory = new UnitTestBuildProjectFactory(); UnitTestBuildProjectFactory buildProjectFactory = new UnitTestBuildProjectFactory();
UnitTestBuildOptions buildOptions = new UnitTestBuildOptions(); UnitTestBuildOptions buildOptions = new UnitTestBuildOptions();
MessageViewCategory unitTestCategory = TestService.UnitTestMessageView; MessageViewCategory unitTestCategory = TestService.UnitTestMessageView;
UnitTestMessageService messageService = new UnitTestMessageService(); IMessageService messageService = ServiceManager.Instance.MessageService;
UnitTestSaveAllFilesCommand saveAllFilesCommand = new UnitTestSaveAllFilesCommand(); UnitTestSaveAllFilesCommand saveAllFilesCommand = new UnitTestSaveAllFilesCommand();
IStatusBarService statusBarService = WorkbenchSingleton.StatusBar;
public IRegisteredTestFrameworks RegisteredTestFrameworks { public IRegisteredTestFrameworks RegisteredTestFrameworks {
get { return testFrameworks; } get { return testFrameworks; }
@ -50,12 +52,16 @@ namespace ICSharpCode.UnitTesting
get { return UnitTestsPad.Instance; } get { return UnitTestsPad.Instance; }
} }
public IUnitTestMessageService MessageService { public IMessageService MessageService {
get { return messageService; } get { return messageService; }
} }
public IUnitTestSaveAllFilesCommand SaveAllFilesCommand { public IUnitTestSaveAllFilesCommand SaveAllFilesCommand {
get { return saveAllFilesCommand; } get { return saveAllFilesCommand; }
} }
public IStatusBarService StatusBarService {
get { return statusBarService; }
}
} }
} }

7
src/AddIns/Analysis/UnitTesting/Src/TestDebuggerBase.cs

@ -7,6 +7,7 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using ICSharpCode.Core.Services;
using ICSharpCode.SharpDevelop.Debugging; using ICSharpCode.SharpDevelop.Debugging;
namespace ICSharpCode.UnitTesting namespace ICSharpCode.UnitTesting
@ -14,19 +15,19 @@ namespace ICSharpCode.UnitTesting
public abstract class TestDebuggerBase : TestRunnerBase public abstract class TestDebuggerBase : TestRunnerBase
{ {
IUnitTestDebuggerService debuggerService; IUnitTestDebuggerService debuggerService;
IUnitTestMessageService messageService; IMessageService messageService;
IDebugger debugger; IDebugger debugger;
ITestResultsMonitor testResultsMonitor; ITestResultsMonitor testResultsMonitor;
public TestDebuggerBase() public TestDebuggerBase()
: this(new UnitTestDebuggerService(), : this(new UnitTestDebuggerService(),
new UnitTestMessageService(), ServiceManager.Instance.MessageService,
new TestResultsMonitor()) new TestResultsMonitor())
{ {
} }
public TestDebuggerBase(IUnitTestDebuggerService debuggerService, public TestDebuggerBase(IUnitTestDebuggerService debuggerService,
IUnitTestMessageService messageService, IMessageService messageService,
ITestResultsMonitor testResultsMonitor) ITestResultsMonitor testResultsMonitor)
{ {
this.debuggerService = debuggerService; this.debuggerService = debuggerService;

20
src/AddIns/Analysis/UnitTesting/Src/UnitTestMessageService.cs

@ -1,20 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.Core;
namespace ICSharpCode.UnitTesting
{
public class UnitTestMessageService : IUnitTestMessageService
{
public bool AskQuestion(string question, string caption)
{
return MessageService.AskQuestion(question, caption);
}
}
}

2
src/AddIns/Analysis/UnitTesting/Test/Tree/NoTestsRunWhenNoTestsSelectedTestFixture.cs

@ -24,7 +24,7 @@ namespace UnitTesting.Tests.Tree
[Test] [Test]
public void OnBeforeRunIsNotCalled() public void OnBeforeRunIsNotCalled()
{ {
Assert.IsFalse(runTestCommand.IsOnBeforeRunTestsMethodCalled); Assert.IsFalse(runTestCommand.IsOnBeforeBuildMethodCalled);
} }
} }
} }

2
src/AddIns/Analysis/UnitTesting/Test/Tree/NoTestsRunWhenUnitTestPadNotCreatedTestFixture.cs

@ -36,7 +36,7 @@ namespace UnitTesting.Tests.Tree
public void OnBeforeRunIsNotCalled() public void OnBeforeRunIsNotCalled()
{ {
runTestCommand.Run(); runTestCommand.Run();
Assert.IsFalse(runTestCommand.IsOnBeforeRunTestsMethodCalled); Assert.IsFalse(runTestCommand.IsOnBeforeBuildMethodCalled);
} }
} }
} }

8
src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestCommandBeforeRunTestFixture.cs

@ -47,10 +47,10 @@ namespace UnitTesting.Tests.Tree
} }
[Test] [Test]
public void RunCallsOnBeforeRunTestsMethod() public void RunCallsOnBeforeBuildMethod()
{ {
runTestCommand.Run(); runTestCommand.Run();
Assert.IsTrue(runTestCommand.IsOnBeforeRunTestsMethodCalled); Assert.IsTrue(runTestCommand.IsOnBeforeBuildMethodCalled);
} }
[Test] [Test]
@ -132,14 +132,14 @@ namespace UnitTesting.Tests.Tree
public void RunningTestCommandPropertyIsSetToRunningCommandWhenOnBeforeRunIsCalled() public void RunningTestCommandPropertyIsSetToRunningCommandWhenOnBeforeRunIsCalled()
{ {
runTestCommand.Run(); runTestCommand.Run();
Assert.AreEqual(runTestCommand, runTestCommand.RunningTestCommandPropertyWhenOnBeforeRunCalled); Assert.AreEqual(runTestCommand, runTestCommand.RunningTestCommandPropertyWhenOnBeforeBuildCalled);
} }
[Test] [Test]
public void IsRunningTestPropertyReturnsTrueWhenOnBeforeRunIsCalled() public void IsRunningTestPropertyReturnsTrueWhenOnBeforeRunIsCalled()
{ {
runTestCommand.Run(); runTestCommand.Run();
Assert.IsTrue(runTestCommand.IsRunningTestPropertyWhenOnBeforeRunCalled); Assert.IsTrue(runTestCommand.IsRunningTestPropertyWhenOnBeforeBuildCalled);
} }
[Test] [Test]

2
src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestsWithoutUnitTestsPadTestFixture.cs

@ -51,7 +51,7 @@ namespace UnitTesting.Tests.Tree
[Test] [Test]
public void OnBeforeTestsRunMethodIsCalled() public void OnBeforeTestsRunMethodIsCalled()
{ {
Assert.IsTrue(runTestCommand.IsOnBeforeRunTestsMethodCalled); Assert.IsTrue(runTestCommand.IsOnBeforeBuildMethodCalled);
} }
} }
} }

1
src/AddIns/Analysis/UnitTesting/Test/UnitTesting.Tests.csproj

@ -162,6 +162,7 @@
<Compile Include="Utils\MockRegisteredTestFrameworks.cs" /> <Compile Include="Utils\MockRegisteredTestFrameworks.cs" />
<Compile Include="Utils\MockRunTestCommandContext.cs" /> <Compile Include="Utils\MockRunTestCommandContext.cs" />
<Compile Include="Utils\MockSaveAllFilesCommand.cs" /> <Compile Include="Utils\MockSaveAllFilesCommand.cs" />
<Compile Include="Utils\MockStatusBarService.cs" />
<Compile Include="Utils\MockTaskService.cs" /> <Compile Include="Utils\MockTaskService.cs" />
<Compile Include="Utils\MockTestFixture.cs" /> <Compile Include="Utils\MockTestFixture.cs" />
<Compile Include="Utils\MockTestFramework.cs" /> <Compile Include="Utils\MockTestFramework.cs" />

30
src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedRunTestCommand.cs

@ -15,10 +15,10 @@ namespace UnitTesting.Tests.Utils
{ {
public class DerivedRunTestCommand : AbstractRunTestCommand public class DerivedRunTestCommand : AbstractRunTestCommand
{ {
bool onBeforeRunTestsMethodCalled; bool onBeforeBuildMethodCalled;
bool onAfterRunTestsMethodCalled; bool onAfterRunTestsMethodCalled;
AbstractRunTestCommand runningTestCommandWhenOnBeforeRunCalled; AbstractRunTestCommand runningTestCommandWhenOnBeforeBuildCalled;
bool runningTestWhenOnBeforeRunCalled; bool runningTestWhenOnBeforeBuildCalled;
bool onStopMethodCalled; bool onStopMethodCalled;
List<NUnitConsoleApplication> helpers = new List<NUnitConsoleApplication>(); List<NUnitConsoleApplication> helpers = new List<NUnitConsoleApplication>();
List<MockTestRunner> testRunnersCreated = new List<MockTestRunner>(); List<MockTestRunner> testRunnersCreated = new List<MockTestRunner>();
@ -28,20 +28,20 @@ namespace UnitTesting.Tests.Utils
{ {
} }
public bool IsOnBeforeRunTestsMethodCalled { public bool IsOnBeforeBuildMethodCalled {
get { return onBeforeRunTestsMethodCalled; } get { return onBeforeBuildMethodCalled; }
} }
public void CallOnBeforeRunTestsMethod() public void CallOnBeforeBuildMethod()
{ {
OnBeforeRunTests(); OnBeforeBuild();
} }
protected override void OnBeforeRunTests() protected override void OnBeforeBuild()
{ {
onBeforeRunTestsMethodCalled = true; onBeforeBuildMethodCalled = true;
runningTestCommandWhenOnBeforeRunCalled = AbstractRunTestCommand.RunningTestCommand; runningTestCommandWhenOnBeforeBuildCalled = AbstractRunTestCommand.RunningTestCommand;
runningTestWhenOnBeforeRunCalled = AbstractRunTestCommand.IsRunningTest; runningTestWhenOnBeforeBuildCalled = AbstractRunTestCommand.IsRunningTest;
} }
protected override ITestRunner CreateTestRunner(IProject project) protected override ITestRunner CreateTestRunner(IProject project)
@ -64,12 +64,12 @@ namespace UnitTesting.Tests.Utils
get { return helpers; } get { return helpers; }
} }
public AbstractRunTestCommand RunningTestCommandPropertyWhenOnBeforeRunCalled { public AbstractRunTestCommand RunningTestCommandPropertyWhenOnBeforeBuildCalled {
get { return runningTestCommandWhenOnBeforeRunCalled; } get { return runningTestCommandWhenOnBeforeBuildCalled; }
} }
public bool IsRunningTestPropertyWhenOnBeforeRunCalled { public bool IsRunningTestPropertyWhenOnBeforeBuildCalled {
get { return runningTestWhenOnBeforeRunCalled; } get { return runningTestWhenOnBeforeBuildCalled; }
} }
public bool IsOnStopMethodCalled { public bool IsOnStopMethodCalled {

43
src/AddIns/Analysis/UnitTesting/Test/Utils/MockMessageService.cs

@ -6,11 +6,12 @@
// </file> // </file>
using System; using System;
using ICSharpCode.Core.Services;
using ICSharpCode.UnitTesting; using ICSharpCode.UnitTesting;
namespace UnitTesting.Tests.Utils namespace UnitTesting.Tests.Utils
{ {
public class MockMessageService : IUnitTestMessageService public class MockMessageService : IMessageService
{ {
string question; string question;
string caption; string caption;
@ -35,5 +36,45 @@ namespace UnitTesting.Tests.Utils
public string Caption { public string Caption {
get { return 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();
}
} }
} }

7
src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestFramework.cs

@ -8,6 +8,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Core.Services;
using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.UnitTesting; using ICSharpCode.UnitTesting;
@ -22,7 +23,7 @@ namespace UnitTesting.Tests.Utils
ITestResultsMonitor testResultsMonitor; ITestResultsMonitor testResultsMonitor;
UnitTestingOptions options; UnitTestingOptions options;
IUnitTestDebuggerService debuggerService; IUnitTestDebuggerService debuggerService;
IUnitTestMessageService messageService; IMessageService messageService;
public MockNUnitTestFramework(IUnitTestProcessRunner processRunner, public MockNUnitTestFramework(IUnitTestProcessRunner processRunner,
ITestResultsMonitor testResultsMonitor, ITestResultsMonitor testResultsMonitor,
@ -34,7 +35,7 @@ namespace UnitTesting.Tests.Utils
public MockNUnitTestFramework(IUnitTestDebuggerService debuggerService, public MockNUnitTestFramework(IUnitTestDebuggerService debuggerService,
ITestResultsMonitor testResultsMonitor, ITestResultsMonitor testResultsMonitor,
UnitTestingOptions options, UnitTestingOptions options,
IUnitTestMessageService messageService) IMessageService messageService)
: this(debuggerService, null, testResultsMonitor, options, messageService) : this(debuggerService, null, testResultsMonitor, options, messageService)
{ {
} }
@ -43,7 +44,7 @@ namespace UnitTesting.Tests.Utils
IUnitTestProcessRunner processRunner, IUnitTestProcessRunner processRunner,
ITestResultsMonitor testResultsMonitor, ITestResultsMonitor testResultsMonitor,
UnitTestingOptions options, UnitTestingOptions options,
IUnitTestMessageService messageService) IMessageService messageService)
{ {
this.debuggerService = debuggerService; this.debuggerService = debuggerService;
this.processRunner = processRunner; this.processRunner = processRunner;

8
src/AddIns/Analysis/UnitTesting/Test/Utils/MockRunTestCommandContext.cs

@ -7,6 +7,7 @@
using System; using System;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Core.Services;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.UnitTesting; using ICSharpCode.UnitTesting;
@ -25,6 +26,7 @@ namespace UnitTesting.Tests.Utils
MockUnitTestsPad unitTestsPad = new MockUnitTestsPad(); MockUnitTestsPad unitTestsPad = new MockUnitTestsPad();
MockMessageService messageService = new MockMessageService(); MockMessageService messageService = new MockMessageService();
MockSaveAllFilesCommand saveAllFilesCommand = new MockSaveAllFilesCommand(); MockSaveAllFilesCommand saveAllFilesCommand = new MockSaveAllFilesCommand();
MockStatusBarService statusBarService = new MockStatusBarService();
public UnitTestingOptions UnitTestingOptions { public UnitTestingOptions UnitTestingOptions {
get { return options; } get { return options; }
@ -87,7 +89,7 @@ namespace UnitTesting.Tests.Utils
set { unitTestsPad = value; } set { unitTestsPad = value; }
} }
public IUnitTestMessageService MessageService { public IMessageService MessageService {
get { return messageService; } get { return messageService; }
} }
@ -102,5 +104,9 @@ namespace UnitTesting.Tests.Utils
public MockSaveAllFilesCommand MockSaveAllFilesCommand { public MockSaveAllFilesCommand MockSaveAllFilesCommand {
get { return saveAllFilesCommand; } get { return saveAllFilesCommand; }
} }
public IStatusBarService StatusBarService {
get { return statusBarService; }
}
} }
} }

35
src/AddIns/Analysis/UnitTesting/Test/Utils/MockStatusBarService.cs

@ -0,0 +1,35 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <author name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
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();
}
}
}

22
src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/DerivedRunTestCommandTestFixture.cs

@ -34,46 +34,46 @@ namespace UnitTesting.Tests.Utils.Tests
[Test] [Test]
public void IsOnBeforeRunTestsMethodCalledReturnsFalseByDefault() public void IsOnBeforeRunTestsMethodCalledReturnsFalseByDefault()
{ {
Assert.IsFalse(runTestCommand.IsOnBeforeRunTestsMethodCalled); Assert.IsFalse(runTestCommand.IsOnBeforeBuildMethodCalled);
} }
[Test] [Test]
public void IsOnBeforeRunTestsMethodCalledReturnsTrueAfterOnBeforeRunMethodCalled() public void IsOnBeforeRunTestsMethodCalledReturnsTrueAfterOnBeforeRunMethodCalled()
{ {
runTestCommand.CallOnBeforeRunTestsMethod(); runTestCommand.CallOnBeforeBuildMethod();
Assert.IsTrue(runTestCommand.IsOnBeforeRunTestsMethodCalled); Assert.IsTrue(runTestCommand.IsOnBeforeBuildMethodCalled);
} }
[Test] [Test]
public void IsRunningTestPropertyWhenOnBeforeRunCalledReturnsFalseByDefault() public void IsRunningTestPropertyWhenOnBeforeRunCalledReturnsFalseByDefault()
{ {
AbstractRunTestCommand.RunningTestCommand = null; AbstractRunTestCommand.RunningTestCommand = null;
runTestCommand.CallOnBeforeRunTestsMethod(); runTestCommand.CallOnBeforeBuildMethod();
Assert.IsFalse(runTestCommand.IsRunningTestPropertyWhenOnBeforeRunCalled); Assert.IsFalse(runTestCommand.IsRunningTestPropertyWhenOnBeforeBuildCalled);
} }
[Test] [Test]
public void IsRunningTestPropertyWhenOnBeforeRunCalledReturnsTrueWhenRunningTestCommandIsNonNullWhenOnBeforeRunMethodCalled() public void IsRunningTestPropertyWhenOnBeforeRunCalledReturnsTrueWhenRunningTestCommandIsNonNullWhenOnBeforeRunMethodCalled()
{ {
AbstractRunTestCommand.RunningTestCommand = runTestCommand; AbstractRunTestCommand.RunningTestCommand = runTestCommand;
runTestCommand.CallOnBeforeRunTestsMethod(); runTestCommand.CallOnBeforeBuildMethod();
Assert.IsTrue(runTestCommand.IsRunningTestPropertyWhenOnBeforeRunCalled); Assert.IsTrue(runTestCommand.IsRunningTestPropertyWhenOnBeforeBuildCalled);
} }
[Test] [Test]
public void RunningTestCommandPropertyWhenOnBeforeRunCalledReturnsNullByDefault() public void RunningTestCommandPropertyWhenOnBeforeRunCalledReturnsNullByDefault()
{ {
AbstractRunTestCommand.RunningTestCommand = null; AbstractRunTestCommand.RunningTestCommand = null;
runTestCommand.CallOnBeforeRunTestsMethod(); runTestCommand.CallOnBeforeBuildMethod();
Assert.IsNull(runTestCommand.RunningTestCommandPropertyWhenOnBeforeRunCalled); Assert.IsNull(runTestCommand.RunningTestCommandPropertyWhenOnBeforeBuildCalled);
} }
[Test] [Test]
public void RunningTestCommandPropertyWhenOnBeforeRunCalledReturnsNonNullWhenRunningTestCommandIsNonNullWhenOnBeforeRunMethodCalled() public void RunningTestCommandPropertyWhenOnBeforeRunCalledReturnsNonNullWhenRunningTestCommandIsNonNullWhenOnBeforeRunMethodCalled()
{ {
AbstractRunTestCommand.RunningTestCommand = runTestCommand; AbstractRunTestCommand.RunningTestCommand = runTestCommand;
runTestCommand.CallOnBeforeRunTestsMethod(); runTestCommand.CallOnBeforeBuildMethod();
Assert.AreEqual(runTestCommand, runTestCommand.RunningTestCommandPropertyWhenOnBeforeRunCalled); Assert.AreEqual(runTestCommand, runTestCommand.RunningTestCommandPropertyWhenOnBeforeBuildCalled);
} }
[Test] [Test]

2
src/AddIns/Analysis/UnitTesting/UnitTesting.csproj

@ -63,7 +63,6 @@
<Compile Include="Src\UnitTestBuildProjectFactory.cs" /> <Compile Include="Src\UnitTestBuildProjectFactory.cs" />
<Compile Include="Src\UnitTestDebuggerService.cs" /> <Compile Include="Src\UnitTestDebuggerService.cs" />
<Compile Include="Src\UnitTestFileService.cs" /> <Compile Include="Src\UnitTestFileService.cs" />
<Compile Include="Src\UnitTestMessageService.cs" />
<Compile Include="Src\UnitTestProcessRunner.cs" /> <Compile Include="Src\UnitTestProcessRunner.cs" />
<Compile Include="Src\UnitTestSaveAllFilesCommand.cs" /> <Compile Include="Src\UnitTestSaveAllFilesCommand.cs" />
<Compile Include="Src\UnitTestTaskService.cs" /> <Compile Include="Src\UnitTestTaskService.cs" />
@ -86,7 +85,6 @@
<Compile Include="Src\ITestRunner.cs" /> <Compile Include="Src\ITestRunner.cs" />
<Compile Include="Src\IUnitTestDebuggerService.cs" /> <Compile Include="Src\IUnitTestDebuggerService.cs" />
<Compile Include="Src\IUnitTestFileService.cs" /> <Compile Include="Src\IUnitTestFileService.cs" />
<Compile Include="Src\IUnitTestMessageService.cs" />
<Compile Include="Src\IUnitTestProcessRunner.cs" /> <Compile Include="Src\IUnitTestProcessRunner.cs" />
<Compile Include="Src\IUnitTestSaveAllFilesCommand.cs" /> <Compile Include="Src\IUnitTestSaveAllFilesCommand.cs" />
<Compile Include="Src\IUnitTestsPad.cs" /> <Compile Include="Src\IUnitTestsPad.cs" />

5
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestDebugger.cs

@ -7,6 +7,7 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using ICSharpCode.Core.Services;
using ICSharpCode.UnitTesting; using ICSharpCode.UnitTesting;
namespace ICSharpCode.PythonBinding namespace ICSharpCode.PythonBinding
@ -20,7 +21,7 @@ namespace ICSharpCode.PythonBinding
public PythonTestDebugger() public PythonTestDebugger()
: this(new UnitTestDebuggerService(), : this(new UnitTestDebuggerService(),
new UnitTestMessageService(), ServiceManager.Instance.MessageService,
new TestResultsMonitor(), new TestResultsMonitor(),
new PythonAddInOptions(), new PythonAddInOptions(),
new PythonStandardLibraryPath(), new PythonStandardLibraryPath(),
@ -29,7 +30,7 @@ namespace ICSharpCode.PythonBinding
} }
public PythonTestDebugger(IUnitTestDebuggerService debuggerService, public PythonTestDebugger(IUnitTestDebuggerService debuggerService,
IUnitTestMessageService messageService, IMessageService messageService,
ITestResultsMonitor testResultsMonitor, ITestResultsMonitor testResultsMonitor,
PythonAddInOptions options, PythonAddInOptions options,
PythonStandardLibraryPath pythonStandardLibraryPath, PythonStandardLibraryPath pythonStandardLibraryPath,

4
src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbench.cs

@ -40,6 +40,10 @@ namespace PythonBinding.Tests.Utils
get { return null; } get { return null; }
} }
public IStatusBarService StatusBar {
get { throw new NotImplementedException(); }
}
public string Title { public string Title {
get { get {
throw new NotImplementedException(); throw new NotImplementedException();

4
src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Utils/MockWorkbench.cs

@ -37,6 +37,10 @@ namespace RubyBinding.Tests.Utils
get { return null; } get { return null; }
} }
public IStatusBarService StatusBar {
get { throw new NotImplementedException(); }
}
public string Title { public string Title {
get { get {
throw new NotImplementedException(); throw new NotImplementedException();

4
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 { public string Title {
get { get {
throw new NotImplementedException(); throw new NotImplementedException();

2
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs

@ -178,7 +178,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
void CaretChanged(object sender, EventArgs e) void CaretChanged(object sender, EventArgs e)
{ {
NavigationService.Log(this.BuildNavPoint()); 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 { public override bool IsReadOnly {

7
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/IncrementalSearch.cs

@ -6,8 +6,8 @@
// </file> // </file>
using System; using System;
using System.Text;
using System.Linq; using System.Linq;
using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Input; using System.Windows.Input;
@ -16,6 +16,7 @@ using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.AvalonEdit.AddIn namespace ICSharpCode.AvalonEdit.AddIn
{ {
@ -145,7 +146,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
} }
string fullMessage = incrementalSearchStartMessage + message; string fullMessage = incrementalSearchStartMessage + message;
StatusBarService.SetMessage(fullMessage, highlight); WorkbenchSingleton.StatusBar.SetMessage(fullMessage, highlight);
} }
/// <summary> /// <summary>
@ -162,7 +163,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
/// </summary> /// </summary>
void ClearStatusBarMessage() void ClearStatusBarMessage()
{ {
StatusBarService.SetMessage(String.Empty); WorkbenchSingleton.StatusBar.SetMessage(String.Empty);
} }
#endregion #endregion

6
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 { public string Title {
get { get {
throw new NotImplementedException(); throw new NotImplementedException();

2
src/Main/Base/Project/Src/Gui/BrowserDisplayBinding/HtmlViewPane.cs

@ -151,7 +151,7 @@ namespace ICSharpCode.SharpDevelop.BrowserDisplayBinding
BrowserPane browser = workbench.ActiveViewContent as BrowserPane; BrowserPane browser = workbench.ActiveViewContent as BrowserPane;
if (browser == null) return; if (browser == null) return;
if (browser.HtmlViewPane == this) { if (browser.HtmlViewPane == this) {
StatusBarService.SetMessage(webBrowser.StatusText); WorkbenchSingleton.StatusBar.SetMessage(webBrowser.StatusText);
} }
} }

20
src/Main/Base/Project/Src/Gui/Components/StatusBar/SdStatusBar.cs

@ -67,21 +67,6 @@ namespace ICSharpCode.SharpDevelop.Gui
Items.Add(txtStatusBarPanel); 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) public void SetMessage(string message, bool highlighted)
{ {
Action setMessageAction = delegate { Action setMessageAction = delegate {
@ -100,11 +85,6 @@ namespace ICSharpCode.SharpDevelop.Gui
setMessageAction(); setMessageAction();
} }
public void SetMessage(BitmapSource image, string message)
{
SetMessage(message);
}
// Displaying progress // Displaying progress
bool statusProgressBarIsVisible; bool statusProgressBarIsVisible;

5
src/Main/Base/Project/Src/Gui/IWorkbench.cs

@ -35,6 +35,11 @@ namespace ICSharpCode.SharpDevelop.Gui
/// </summary> /// </summary>
Window MainWindow { get; } Window MainWindow { get; }
/// <summary>
/// Gets the status bar.
/// </summary>
IStatusBarService StatusBar { get; }
/// <summary> /// <summary>
/// Gets/Sets whether the window is displayed in full-screen mode. /// Gets/Sets whether the window is displayed in full-screen mode.
/// </summary> /// </summary>

16
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 System.Windows.Forms.IWin32Window MainWin32Window { get { return this; } }
public ISynchronizeInvoke SynchronizingObject { get; private set; } public ISynchronizeInvoke SynchronizingObject { get; private set; }
public Window MainWindow { get { return this; } } public Window MainWindow { get { return this; } }
public IStatusBarService StatusBar { get; private set; }
IntPtr System.Windows.Forms.IWin32Window.Handle { IntPtr System.Windows.Forms.IWin32Window.Handle {
get { get {
@ -69,12 +70,13 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
List<PadDescriptor> padDescriptorCollection = new List<PadDescriptor>(); List<PadDescriptor> padDescriptorCollection = new List<PadDescriptor>();
SdStatusBar statusBar = new SdStatusBar();
ToolBar[] toolBars; ToolBar[] toolBars;
public WpfWorkbench() public WpfWorkbench()
{ {
this.SynchronizingObject = new WpfSynchronizeInvoke(this.Dispatcher); this.SynchronizingObject = new WpfSynchronizeInvoke(this.Dispatcher);
this.StatusBar = new SdStatusBarService(statusBar);
InitializeComponent(); InitializeComponent();
InitFocusTrackingEvents(); InitFocusTrackingEvents();
} }
@ -100,8 +102,8 @@ namespace ICSharpCode.SharpDevelop.Gui
DockPanel.SetDock(tb, Dock.Top); DockPanel.SetDock(tb, Dock.Top);
dockPanel.Children.Insert(1, tb); dockPanel.Children.Insert(1, tb);
} }
DockPanel.SetDock(StatusBarService.Control, Dock.Bottom); DockPanel.SetDock(statusBar, Dock.Bottom);
dockPanel.Children.Insert(dockPanel.Children.Count - 2, StatusBarService.Control); dockPanel.Children.Insert(dockPanel.Children.Count - 2, statusBar);
UpdateMenu(); UpdateMenu();
@ -119,7 +121,7 @@ namespace ICSharpCode.SharpDevelop.Gui
CommandManager.RequerySuggested += requerySuggestedEventHandler; CommandManager.RequerySuggested += requerySuggestedEventHandler;
ResourceService.LanguageChanged += OnLanguageChanged; 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 // 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)) { if (!e.Handled && e.Key == Key.L && e.KeyboardDevice.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt)) {
this.UseLayoutRounding = !this.UseLayoutRounding; 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 (!e.Handled && e.Key == Key.F && e.KeyboardDevice.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt)) {
if (TextOptions.GetTextFormattingMode(this) == TextFormattingMode.Display) if (TextOptions.GetTextFormattingMode(this) == TextFormattingMode.Display)
TextOptions.SetTextFormattingMode(this, TextFormattingMode.Ideal); TextOptions.SetTextFormattingMode(this, TextFormattingMode.Ideal);
else else
TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display); 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)) { if (!e.Handled && e.Key == Key.R && e.KeyboardDevice.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt)) {
switch (TextOptions.GetTextRenderingMode(this)) { switch (TextOptions.GetTextRenderingMode(this)) {
@ -685,7 +687,7 @@ namespace ICSharpCode.SharpDevelop.Gui
TextOptions.SetTextRenderingMode(this, TextRenderingMode.ClearType); TextOptions.SetTextRenderingMode(this, TextRenderingMode.ClearType);
break; break;
} }
StatusBarService.SetMessage("TextRenderingMode=" + TextOptions.GetTextRenderingMode(this)); this.StatusBar.SetMessage("TextRenderingMode=" + TextOptions.GetTextRenderingMode(this));
} }
} }

7
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) public static void InitializeWorkbench(IWorkbench workbench, IWorkbenchLayout layout)
{ {
WorkbenchSingleton.workbench = workbench; WorkbenchSingleton.workbench = workbench;
@ -64,7 +70,6 @@ namespace ICSharpCode.SharpDevelop.Gui
DisplayBindingService.InitializeService(); DisplayBindingService.InitializeService();
LayoutConfiguration.LoadLayoutConfiguration(); LayoutConfiguration.LoadLayoutConfiguration();
FileService.InitializeService(); FileService.InitializeService();
StatusBarService.Initialize();
DomHostCallback.Register(); // must be called after StatusBarService.Initialize() DomHostCallback.Register(); // must be called after StatusBarService.Initialize()
ParserService.InitializeParserService(); ParserService.InitializeParserService();
TaskService.Initialize(); TaskService.Initialize();

24
src/Main/Base/Project/Src/Project/BuildEngine.cs

@ -7,10 +7,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
@ -44,7 +44,7 @@ namespace ICSharpCode.SharpDevelop.Project
WorkbenchSingleton.AssertMainThread(); WorkbenchSingleton.AssertMainThread();
if (guiBuildCancellation != null) { if (guiBuildCancellation != null) {
BuildResults results = new BuildResults(); 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")); BuildError error = new BuildError(null, Core.ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning"));
results.Add(error); results.Add(error);
TaskService.Add(new Task(error)); TaskService.Add(new Task(error));
@ -54,12 +54,12 @@ namespace ICSharpCode.SharpDevelop.Project
} }
} else { } else {
guiBuildCancellation = new CancellationTokenSource(); guiBuildCancellation = new CancellationTokenSource();
IProgressMonitor progressMonitor = StatusBarService.CreateProgressMonitor(guiBuildCancellation.Token); IProgressMonitor progressMonitor = WorkbenchSingleton.StatusBar.CreateProgressMonitor(guiBuildCancellation.Token);
guiBuildTrackedFeature = AnalyticsMonitorService.TrackFeature("Build"); 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)); ProjectService.RaiseEventBuildStarted(new BuildEventArgs(project, options));
StartBuild(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
/// </summary> /// </summary>
sealed class MessageViewSink : IBuildFeedbackSink sealed class MessageViewSink : IBuildFeedbackSink
{ {
Gui.MessageViewCategory messageView; MessageViewCategory messageView;
Gui.IProgressMonitor progressMonitor; 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.messageView = messageView;
this.progressMonitor = progressMonitor; this.progressMonitor = progressMonitor;
this.statusBarService = statusBarService;
} }
public IProgressMonitor ProgressMonitor { public IProgressMonitor ProgressMonitor {
@ -144,7 +150,7 @@ namespace ICSharpCode.SharpDevelop.Project
if (results.WarningCount > 0) if (results.WarningCount > 0)
message += " " + results.WarningCount + " warning(s)"; message += " " + results.WarningCount + " warning(s)";
} }
StatusBarService.SetMessage(StringParser.Parse(message)); statusBarService.SetMessage(message);
ProjectService.RaiseEventBuildFinished(new BuildEventArgs(buildable, options, results)); ProjectService.RaiseEventBuildFinished(new BuildEventArgs(buildable, options, results));
}); });
} }

2
src/Main/Base/Project/Src/Services/ParserService/LoadSolutionProjects.cs

@ -203,7 +203,7 @@ namespace ICSharpCode.SharpDevelop
if (!this.threadIsRunning && this.actions.Count > 0) { if (!this.threadIsRunning && this.actions.Count > 0) {
this.threadIsRunning = true; this.threadIsRunning = true;
progressMonitor = StatusBarService.CreateProgressMonitor(cancellationSource.Token); progressMonitor = WorkbenchSingleton.StatusBar.CreateProgressMonitor(cancellationSource.Token);
progressMonitor.TaskName = this.actions.Peek().name; progressMonitor.TaskName = this.actions.Peek().name;
Thread thread = new Thread(new ThreadStart(RunThread)); Thread thread = new Thread(new ThreadStart(RunThread));

120
src/Main/Base/Project/Src/Services/StatusBar/StatusBarService.cs

@ -8,45 +8,71 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Threading; using System.Threading;
using System.Windows; using System.Windows;
using System.Windows.Media.Imaging;
using ICSharpCode.Core; 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; }
/// <summary>
/// Sets the caret position shown in the status bar.
/// </summary>
/// <param name="x">column number</param>
/// <param name="y">line number</param>
/// <param name="charOffset">character number</param>
void SetCaretPosition(int x, int y, int charOffset);
//void SetInsertMode(bool insertMode);
/// <summary>
/// Sets the message shown in the left-most pane in the status bar.
/// </summary>
/// <param name="message">The message text.</param>
/// <param name="highlighted">Whether to highlight the text</param>
/// <param name="icon">Icon to show next to the text</param>
void SetMessage(string message, bool highlighted = false, IImage icon = null);
/// <summary>
/// Creates a new <see cref="IProgressMonitor"/> that can be used to report
/// progress to the status bar.
/// </summary>
/// <param name="cancellationToken">Cancellation token to use for
/// <see cref="IProgressMonitor.CancellationToken"/></param>
/// <returns>The new IProgressMonitor instance. This return value must be disposed
/// once the background task has completed.</returns>
IProgressMonitor CreateProgressMonitor(CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Shows progress for the specified ProgressCollector in the status bar.
/// </summary>
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 { get {
System.Diagnostics.Debug.Assert(statusBar != null);
return statusBar.Visibility == Visibility.Visible; return statusBar.Visibility == Visibility.Visible;
} }
set { set {
System.Diagnostics.Debug.Assert(statusBar != null);
statusBar.Visibility = value ? Visibility.Visible : Visibility.Collapsed; statusBar.Visibility = value ? Visibility.Visible : Visibility.Collapsed;
} }
} }
internal static SdStatusBar Control { public void SetCaretPosition(int x, int y, int charOffset)
get {
System.Diagnostics.Debug.Assert(statusBar != null);
return statusBar;
}
}
public static void SetCaretPosition(int x, int y, int charOffset)
{ {
statusBar.CursorStatusBarPanel.Content = StringParser.Parse( statusBar.CursorStatusBarPanel.Content = StringParser.Parse(
"${res:StatusBarService.CursorStatusBarPanelText}", "${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}"); 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); statusBar.SetMessage(StringParser.Parse(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);
} }
#region Progress Monitor #region Progress Monitor
static Stack<ProgressCollector> waitingProgresses = new Stack<ProgressCollector>(); Stack<ProgressCollector> waitingProgresses = new Stack<ProgressCollector>();
static ProgressCollector currentProgress; ProgressCollector currentProgress;
public static IProgressMonitor CreateProgressMonitor(CancellationToken cancellationToken) public IProgressMonitor CreateProgressMonitor(CancellationToken cancellationToken = default(CancellationToken))
{ {
ProgressCollector progress = new ProgressCollector(WorkbenchSingleton.Workbench.SynchronizingObject, cancellationToken); ProgressCollector progress = new ProgressCollector(WorkbenchSingleton.Workbench.SynchronizingObject, cancellationToken);
AddProgress(progress); AddProgress(progress);
return progress.ProgressMonitor; return progress.ProgressMonitor;
} }
public static void AddProgress(ProgressCollector progress) public void AddProgress(ProgressCollector progress)
{ {
if (progress == null) if (progress == null)
throw new ArgumentNullException("progress"); throw new ArgumentNullException("progress");
System.Diagnostics.Debug.Assert(statusBar != null);
WorkbenchSingleton.AssertMainThread(); WorkbenchSingleton.AssertMainThread();
if (currentProgress != null) { if (currentProgress != null) {
currentProgress.ProgressMonitorDisposed -= progress_ProgressMonitorDisposed; currentProgress.ProgressMonitorDisposed -= progress_ProgressMonitorDisposed;
@ -125,7 +117,7 @@ namespace ICSharpCode.SharpDevelop
SetActiveProgress(progress); SetActiveProgress(progress);
} }
static void SetActiveProgress(ProgressCollector progress) void SetActiveProgress(ProgressCollector progress)
{ {
WorkbenchSingleton.AssertMainThread(); WorkbenchSingleton.AssertMainThread();
currentProgress = progress; currentProgress = progress;
@ -142,13 +134,13 @@ namespace ICSharpCode.SharpDevelop
progress.PropertyChanged += progress_PropertyChanged; 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); Debug.Assert(sender == currentProgress);
statusBar.DisplayProgress(currentProgress.TaskName, currentProgress.Progress, currentProgress.Status); 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); Debug.Assert(sender == currentProgress);
SetActiveProgress(waitingProgresses.Pop()); // stack is never empty: we push null as first element SetActiveProgress(waitingProgresses.Pop()); // stack is never empty: we push null as first element

Loading…
Cancel
Save