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

3
data/resources/StringResources.pl.resx

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

3
data/resources/StringResources.resx

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

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

@ -90,7 +90,7 @@ namespace ICSharpCode.UnitTesting @@ -90,7 +90,7 @@ namespace ICSharpCode.UnitTesting
UpdateUnitTestsPadToolbar();
ResetAllTestResultsInUnitTestsPad();
OnBeforeRunTests();
OnBeforeBuild();
}
void BuildAndRunTests()
@ -132,8 +132,16 @@ namespace ICSharpCode.UnitTesting @@ -132,8 +132,16 @@ namespace ICSharpCode.UnitTesting
}
/// <summary>
/// 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.
/// </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>
protected virtual void OnBeforeRunTests()
{
@ -202,6 +210,10 @@ namespace ICSharpCode.UnitTesting @@ -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 @@ -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 @@ -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;

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

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
// </file>
using System;
using ICSharpCode.Core.Services;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.UnitTesting
@ -19,7 +20,8 @@ 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; }
}
}

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

@ -1,17 +0,0 @@ @@ -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 @@ @@ -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 @@ -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)

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

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
// </file>
using System;
using ICSharpCode.Core.Services;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.UnitTesting
@ -19,8 +20,9 @@ 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 @@ -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; }
}
}
}

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

@ -7,6 +7,7 @@ @@ -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 @@ -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;

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

@ -1,20 +0,0 @@ @@ -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 @@ -24,7 +24,7 @@ namespace UnitTesting.Tests.Tree
[Test]
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 @@ -36,7 +36,7 @@ namespace UnitTesting.Tests.Tree
public void OnBeforeRunIsNotCalled()
{
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 @@ -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 @@ -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]

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

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

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

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

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

@ -15,10 +15,10 @@ namespace UnitTesting.Tests.Utils @@ -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<NUnitConsoleApplication> helpers = new List<NUnitConsoleApplication>();
List<MockTestRunner> testRunnersCreated = new List<MockTestRunner>();
@ -28,20 +28,20 @@ namespace UnitTesting.Tests.Utils @@ -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 @@ -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 {

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

@ -6,11 +6,12 @@ @@ -6,11 +6,12 @@
// </file>
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 @@ -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();
}
}
}

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

@ -8,6 +8,7 @@ @@ -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 @@ -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 @@ -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 @@ -43,7 +44,7 @@ namespace UnitTesting.Tests.Utils
IUnitTestProcessRunner processRunner,
ITestResultsMonitor testResultsMonitor,
UnitTestingOptions options,
IUnitTestMessageService messageService)
IMessageService messageService)
{
this.debuggerService = debuggerService;
this.processRunner = processRunner;

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

@ -7,6 +7,7 @@ @@ -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 @@ -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 @@ -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 @@ -102,5 +104,9 @@ namespace UnitTesting.Tests.Utils
public MockSaveAllFilesCommand MockSaveAllFilesCommand {
get { return saveAllFilesCommand; }
}
public IStatusBarService StatusBarService {
get { return statusBarService; }
}
}
}

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

@ -0,0 +1,35 @@ @@ -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 @@ -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]

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

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

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

@ -7,6 +7,7 @@ @@ -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 @@ -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 @@ -29,7 +30,7 @@ namespace ICSharpCode.PythonBinding
}
public PythonTestDebugger(IUnitTestDebuggerService debuggerService,
IUnitTestMessageService messageService,
IMessageService messageService,
ITestResultsMonitor testResultsMonitor,
PythonAddInOptions options,
PythonStandardLibraryPath pythonStandardLibraryPath,

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

@ -40,6 +40,10 @@ namespace PythonBinding.Tests.Utils @@ -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();

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

@ -37,6 +37,10 @@ namespace RubyBinding.Tests.Utils @@ -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();

4
src/AddIns/BackendBindings/WixBinding/Test/Utils/MockWorkbench.cs

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

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

@ -178,7 +178,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -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 {

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

@ -6,8 +6,8 @@ @@ -6,8 +6,8 @@
// </file>
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; @@ -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 @@ -145,7 +146,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
}
string fullMessage = incrementalSearchStartMessage + message;
StatusBarService.SetMessage(fullMessage, highlight);
WorkbenchSingleton.StatusBar.SetMessage(fullMessage, highlight);
}
/// <summary>
@ -162,7 +163,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -162,7 +163,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
/// </summary>
void ClearStatusBarMessage()
{
StatusBarService.SetMessage(String.Empty);
WorkbenchSingleton.StatusBar.SetMessage(String.Empty);
}
#endregion

6
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockWorkbench.cs

@ -82,6 +82,12 @@ namespace XmlEditor.Tests.Utils @@ -82,6 +82,12 @@ namespace XmlEditor.Tests.Utils
}
}
public IStatusBarService StatusBar {
get {
throw new NotImplementedException();
}
}
public string Title {
get {
throw new NotImplementedException();

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

@ -151,7 +151,7 @@ namespace ICSharpCode.SharpDevelop.BrowserDisplayBinding @@ -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);
}
}

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

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

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

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

16
src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs

@ -57,6 +57,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -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 @@ -69,12 +70,13 @@ namespace ICSharpCode.SharpDevelop.Gui
}
List<PadDescriptor> padDescriptorCollection = new List<PadDescriptor>();
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 @@ -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 @@ -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 @@ -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 @@ -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));
}
}

7
src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs

@ -57,6 +57,12 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -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 @@ -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();

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

@ -7,10 +7,10 @@ @@ -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 @@ -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 @@ -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 @@ -90,13 +90,19 @@ namespace ICSharpCode.SharpDevelop.Project
/// </summary>
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 @@ -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));
});
}

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

@ -203,7 +203,7 @@ namespace ICSharpCode.SharpDevelop @@ -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));

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

@ -8,45 +8,71 @@ @@ -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; }
/// <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 {
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 @@ -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<ProgressCollector> waitingProgresses = new Stack<ProgressCollector>();
static ProgressCollector currentProgress;
Stack<ProgressCollector> waitingProgresses = new Stack<ProgressCollector>();
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 @@ -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 @@ -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

Loading…
Cancel
Save