Index: Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj
===================================================================
diff -u -r7993dddd622b104506d59a43fd9add82d6ce48ae -r7c8a507ff0aafd03830a7faa8f801c5a3d3c6660
--- Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision 7993dddd622b104506d59a43fd9add82d6ce48ae)
+++ Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision 7c8a507ff0aafd03830a7faa8f801c5a3d3c6660)
@@ -262,6 +262,7 @@
+
Index: Core/Common/src/Core.Common.Gui/GuiCommandHandler.cs
===================================================================
diff -u -r7993dddd622b104506d59a43fd9add82d6ce48ae -r7c8a507ff0aafd03830a7faa8f801c5a3d3c6660
--- Core/Common/src/Core.Common.Gui/GuiCommandHandler.cs (.../GuiCommandHandler.cs) (revision 7993dddd622b104506d59a43fd9add82d6ce48ae)
+++ Core/Common/src/Core.Common.Gui/GuiCommandHandler.cs (.../GuiCommandHandler.cs) (revision 7c8a507ff0aafd03830a7faa8f801c5a3d3c6660)
@@ -14,7 +14,7 @@
namespace Core.Common.Gui
{
- public class GuiCommandHandler : IGuiCommandHandler, IViewCommands
+ public class GuiCommandHandler : IGuiCommandHandler
{
private readonly IGui gui;
@@ -23,19 +23,14 @@
this.gui = gui;
}
- public object GetDataOfActiveView()
- {
- return gui.DocumentViews.ActiveView != null ? gui.DocumentViews.ActiveView.Data : null;
- }
-
///
/// Makes the properties window visible and updates the to the
/// given .
///
/// The object for which to show its properties.
public void ShowPropertiesFor(object obj)
{
- ((MainWindow) gui.MainWindow).InitPropertiesWindowAndActivate();
+ ((MainWindow)gui.MainWindow).InitPropertiesWindowAndActivate();
gui.Selection = obj;
}
@@ -44,31 +39,6 @@
return gui.PropertyResolver.GetObjectProperties(obj) != null;
}
- public bool CanOpenSelectViewDialog()
- {
- return gui.Selection != null && gui.DocumentViewsResolver.GetViewInfosFor(gui.Selection).Count() > 1;
- }
-
- public void OpenSelectViewDialog()
- {
- gui.DocumentViewsResolver.OpenViewForData(gui.Selection, true);
- }
-
- public bool CanOpenViewFor(object obj)
- {
- return gui.DocumentViewsResolver.GetViewInfosFor(obj).Any();
- }
-
- public void OpenView(object dataObject)
- {
- gui.DocumentViewsResolver.OpenViewForData(dataObject);
- }
-
- public void OpenViewForSelection()
- {
- gui.DocumentViewsResolver.OpenViewForData(gui.Selection);
- }
-
public void OpenLogFileExternal()
{
bool logFileOpened = false;
@@ -85,39 +55,13 @@
logFileOpened = true;
}
}
- catch (Exception) {}
+ catch (Exception) { }
if (!logFileOpened)
{
MessageBox.Show(Resources.GuiCommandHandler_OpenLogFileExternal_Unable_to_open_log_file_Opening_log_file_directory_instead, Resources.GuiCommandHandler_OpenLogFileExternal_Unable_to_open_log_file);
Process.Start(SettingsHelper.GetApplicationLocalUserSettingsDirectory());
}
}
-
- ///
- /// Removes all document and tool views that are associated to the dataObject and/or its children.
- ///
- ///
- public void RemoveAllViewsForItem(object dataObject)
- {
- if (dataObject == null || gui == null || gui.DocumentViews == null || gui.DocumentViews.Count == 0)
- {
- return;
- }
- foreach (var data in gui.GetAllDataWithViewDefinitionsRecursively(dataObject))
- {
- gui.DocumentViewsResolver.CloseAllViewsFor(data);
- RemoveViewsAndData(gui.ToolWindowViews.Where(v => v.Data == data).ToArray());
- }
- }
-
- private void RemoveViewsAndData(IEnumerable toolViews)
- {
- // set all tool windows where dataObject was used to null
- foreach (var view in toolViews)
- {
- view.Data = null;
- }
- }
}
}
\ No newline at end of file
Index: Core/Common/src/Core.Common.Gui/RingtoetsGui.cs
===================================================================
diff -u -r7993dddd622b104506d59a43fd9add82d6ce48ae -r7c8a507ff0aafd03830a7faa8f801c5a3d3c6660
--- Core/Common/src/Core.Common.Gui/RingtoetsGui.cs (.../RingtoetsGui.cs) (revision 7993dddd622b104506d59a43fd9add82d6ce48ae)
+++ Core/Common/src/Core.Common.Gui/RingtoetsGui.cs (.../RingtoetsGui.cs) (revision 7c8a507ff0aafd03830a7faa8f801c5a3d3c6660)
@@ -70,7 +70,8 @@
private ApplicationSettingsBase userSettings;
private readonly GuiCommandHandler guiCommandHandler;
private StorageCommandHandler storageCommandHandler;
- private ProjectCommandsHandler projectCommandsHandler;
+ private readonly ViewCommandHandler viewCommandHandler;
+ private readonly ProjectCommandsHandler projectCommandsHandler;
private readonly ExportImportCommandHandler exportImportCommandHandler;
public RingtoetsGui(ApplicationCore applicationCore = null, GuiCoreSettings fixedSettings = null)
@@ -94,7 +95,8 @@
UserSettings = Settings.Default;
guiCommandHandler = new GuiCommandHandler(this);
- storageCommandHandler = new StorageCommandHandler(guiCommandHandler, this);
+ viewCommandHandler = new ViewCommandHandler(this);
+ storageCommandHandler = new StorageCommandHandler(viewCommandHandler, this);
exportImportCommandHandler = new ExportImportCommandHandler(this);
projectCommandsHandler = new ProjectCommandsHandler(this);
@@ -211,7 +213,7 @@
{
get
{
- return guiCommandHandler;
+ return viewCommandHandler;
}
}
Index: Core/Common/src/Core.Common.Gui/ViewCommandHandler.cs
===================================================================
diff -u
--- Core/Common/src/Core.Common.Gui/ViewCommandHandler.cs (revision 0)
+++ Core/Common/src/Core.Common.Gui/ViewCommandHandler.cs (revision 7c8a507ff0aafd03830a7faa8f801c5a3d3c6660)
@@ -0,0 +1,80 @@
+using System.Collections.Generic;
+using System.Linq;
+
+using Core.Common.Controls.Views;
+
+namespace Core.Common.Gui
+{
+ ///
+ /// This class provides concrete implementation of .
+ ///
+ public class ViewCommandHandler : IViewCommands
+ {
+ private readonly IGui gui;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The GUI.
+ public ViewCommandHandler(IGui gui)
+ {
+ this.gui = gui;
+ }
+
+ public object GetDataOfActiveView()
+ {
+ return gui.DocumentViews.ActiveView != null ? gui.DocumentViews.ActiveView.Data : null;
+ }
+
+ public bool CanOpenSelectViewDialog()
+ {
+ return gui.Selection != null && gui.DocumentViewsResolver.GetViewInfosFor(gui.Selection).Count() > 1;
+ }
+
+ public void OpenSelectViewDialog()
+ {
+ gui.DocumentViewsResolver.OpenViewForData(gui.Selection, true);
+ }
+
+ public bool CanOpenViewFor(object obj)
+ {
+ return gui.DocumentViewsResolver.GetViewInfosFor(obj).Any();
+ }
+
+ public void OpenView(object dataObject)
+ {
+ gui.DocumentViewsResolver.OpenViewForData(dataObject);
+ }
+
+ public void OpenViewForSelection()
+ {
+ gui.DocumentViewsResolver.OpenViewForData(gui.Selection);
+ }
+
+ ///
+ /// Removes all document and tool views that are associated to the dataObject and/or its children.
+ ///
+ ///
+ public void RemoveAllViewsForItem(object dataObject)
+ {
+ if (dataObject == null || gui == null || gui.DocumentViews == null || gui.DocumentViews.Count == 0)
+ {
+ return;
+ }
+ foreach (var data in gui.GetAllDataWithViewDefinitionsRecursively(dataObject))
+ {
+ gui.DocumentViewsResolver.CloseAllViewsFor(data);
+ RemoveViewsAndData(gui.ToolWindowViews.Where(v => v.Data == data).ToArray());
+ }
+ }
+
+ private void RemoveViewsAndData(IEnumerable toolViews)
+ {
+ // set all tool windows where dataObject was used to null
+ foreach (var view in toolViews)
+ {
+ view.Data = null;
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj
===================================================================
diff -u -rdabbb3aa0306dcbd00ee3bf340e1d5c4ce1687f0 -r7c8a507ff0aafd03830a7faa8f801c5a3d3c6660
--- Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision dabbb3aa0306dcbd00ee3bf340e1d5c4ce1687f0)
+++ Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision 7c8a507ff0aafd03830a7faa8f801c5a3d3c6660)
@@ -71,6 +71,7 @@
+
Index: Core/Common/test/Core.Common.Gui.Test/GuiCommandHandlerTest.cs
===================================================================
diff -u -r42ca97fdb85a553c6aac3bfdfe57c7be4af90821 -r7c8a507ff0aafd03830a7faa8f801c5a3d3c6660
--- Core/Common/test/Core.Common.Gui.Test/GuiCommandHandlerTest.cs (.../GuiCommandHandlerTest.cs) (revision 42ca97fdb85a553c6aac3bfdfe57c7be4af90821)
+++ Core/Common/test/Core.Common.Gui.Test/GuiCommandHandlerTest.cs (.../GuiCommandHandlerTest.cs) (revision 7c8a507ff0aafd03830a7faa8f801c5a3d3c6660)
@@ -1,7 +1,4 @@
-using System.Collections.Generic;
-
-using Core.Common.Controls.Views;
-using Core.Common.Gui.Forms.PropertyGridView;
+using Core.Common.Gui.Forms.PropertyGridView;
using NUnit.Framework;
using Rhino.Mocks;
@@ -65,70 +62,8 @@
mocks.VerifyAll();
}
- [Test]
- public void RemoveAllViewsForItem_GuiHasDocumentViews_CloseViewForDataAndChildren()
- {
- // Setup
- var data = new object();
- var childData = new object();
+ public class AnObject {}
- var documentViewsResolver = mocks.StrictMock();
- documentViewsResolver.Expect(vr => vr.CloseAllViewsFor(data));
- documentViewsResolver.Expect(vr => vr.CloseAllViewsFor(childData));
-
- var dataView = mocks.Stub();
- dataView.Data = data;
- var childDataView = mocks.Stub();
- childDataView.Data = childData;
-
- var viewsArray = new List
- {
- dataView,
- childDataView
- };
- var toolWindows = mocks.StrictMock();
- toolWindows.Stub(ws => ws.GetEnumerator()).WhenCalled(invocation => invocation.ReturnValue = viewsArray.GetEnumerator()).Return(null);
- toolWindows.Expect(ws => ws.Count).Return(viewsArray.Count);
-
- var gui = mocks.Stub();
- gui.Expect(g => g.GetAllDataWithViewDefinitionsRecursively(data)).Return(new[]
- {
- data,
- childData
- });
- gui.Expect(g => g.DocumentViews).Return(toolWindows).Repeat.AtLeastOnce();
- gui.Expect(g => g.DocumentViewsResolver).Return(documentViewsResolver).Repeat.AtLeastOnce();
- gui.Expect(g => g.ToolWindowViews).Return(toolWindows).Repeat.AtLeastOnce();
- gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
- gui.Stub(g => g.ProjectClosing += null).IgnoreArguments();
- gui.Stub(g => g.MainWindow).Return(null);
- mocks.ReplayAll();
-
- var guiCommandHandler = new GuiCommandHandler(gui);
-
- // Call
- guiCommandHandler.RemoveAllViewsForItem(data);
-
- // Assert
- Assert.IsNull(dataView.Data);
- Assert.IsNull(childDataView.Data);
- mocks.VerifyAll();
- }
+ public class ASubObject : AnObject {}
}
-
- public class TestGuiPlugin : GuiPlugin
- {
- public override IEnumerable GetPropertyInfos()
- {
- yield return new PropertyInfo();
- }
- }
-
- public class AnObjectProperties : IObjectProperties {
- public object Data { get; set; }
- }
-
- public class AnObject {}
-
- public class ASubObject : AnObject { }
}
\ No newline at end of file
Index: Core/Common/test/Core.Common.Gui.Test/ViewCommandHandlerTest.cs
===================================================================
diff -u
--- Core/Common/test/Core.Common.Gui.Test/ViewCommandHandlerTest.cs (revision 0)
+++ Core/Common/test/Core.Common.Gui.Test/ViewCommandHandlerTest.cs (revision 7c8a507ff0aafd03830a7faa8f801c5a3d3c6660)
@@ -0,0 +1,65 @@
+using System.Collections.Generic;
+
+using Core.Common.Controls.Views;
+
+using NUnit.Framework;
+
+using Rhino.Mocks;
+
+namespace Core.Common.Gui.Test
+{
+ [TestFixture]
+ public class ViewCommandHandlerTest
+ {
+ [Test]
+ public void RemoveAllViewsForItem_GuiHasDocumentViews_CloseViewForDataAndChildren()
+ {
+ // Setup
+ var data = new object();
+ var childData = new object();
+
+ var mocks = new MockRepository();
+ var documentViewsResolver = mocks.StrictMock();
+ documentViewsResolver.Expect(vr => vr.CloseAllViewsFor(data));
+ documentViewsResolver.Expect(vr => vr.CloseAllViewsFor(childData));
+
+ var dataView = mocks.Stub();
+ dataView.Data = data;
+ var childDataView = mocks.Stub();
+ childDataView.Data = childData;
+
+ var viewsArray = new List
+ {
+ dataView,
+ childDataView
+ };
+ var toolWindows = mocks.StrictMock();
+ toolWindows.Stub(ws => ws.GetEnumerator()).WhenCalled(invocation => invocation.ReturnValue = viewsArray.GetEnumerator()).Return(null);
+ toolWindows.Expect(ws => ws.Count).Return(viewsArray.Count);
+
+ var gui = mocks.Stub();
+ gui.Expect(g => g.GetAllDataWithViewDefinitionsRecursively(data)).Return(new[]
+ {
+ data,
+ childData
+ });
+ gui.Expect(g => g.DocumentViews).Return(toolWindows).Repeat.AtLeastOnce();
+ gui.Expect(g => g.DocumentViewsResolver).Return(documentViewsResolver).Repeat.AtLeastOnce();
+ gui.Expect(g => g.ToolWindowViews).Return(toolWindows).Repeat.AtLeastOnce();
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectClosing += null).IgnoreArguments();
+ gui.Stub(g => g.MainWindow).Return(null);
+ mocks.ReplayAll();
+
+ var viewCommandHandler = new ViewCommandHandler(gui);
+
+ // Call
+ viewCommandHandler.RemoveAllViewsForItem(data);
+
+ // Assert
+ Assert.IsNull(dataView.Data);
+ Assert.IsNull(childDataView.Data);
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file