Index: Core/Common/src/Core.Common.Controls/Views/ISelectionProvider.cs
===================================================================
diff -u -r24da3aa72ccc0776599628c9f971081694048d9a -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Core/Common/src/Core.Common.Controls/Views/ISelectionProvider.cs (.../ISelectionProvider.cs) (revision 24da3aa72ccc0776599628c9f971081694048d9a)
+++ Core/Common/src/Core.Common.Controls/Views/ISelectionProvider.cs (.../ISelectionProvider.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -19,6 +19,8 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
+
namespace Core.Common.Controls.Views
{
///
@@ -27,6 +29,11 @@
public interface ISelectionProvider : IView
{
///
+ /// Fired when the provider's selection has been changed.
+ ///
+ event EventHandler SelectionChanged;
+
+ ///
/// Gets the selected ; or null if nothing is selected.
///
object Selection { get; }
Index: Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj
===================================================================
diff -u -r49c5da81f49a23dd6e66526d264a08bf510e6963 -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision 49c5da81f49a23dd6e66526d264a08bf510e6963)
+++ Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -157,7 +157,6 @@
-
Index: Core/Common/src/Core.Common.Gui/Forms/PropertyGridView/PropertyGridView.cs
===================================================================
diff -u -rf08fd5cc1482a6c706bdb04d46b6482d489b7c5b -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Core/Common/src/Core.Common.Gui/Forms/PropertyGridView/PropertyGridView.cs (.../PropertyGridView.cs) (revision f08fd5cc1482a6c706bdb04d46b6482d489b7c5b)
+++ Core/Common/src/Core.Common.Gui/Forms/PropertyGridView/PropertyGridView.cs (.../PropertyGridView.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -38,7 +38,6 @@
///
public class PropertyGridView : PropertyGrid, IView, IObserver
{
- private readonly IApplicationSelection applicationSelection;
private readonly IPropertyResolver propertyResolver;
private object data;
@@ -75,9 +74,6 @@
PropertySort = PropertySort.Categorized;
this.propertyResolver = propertyResolver;
-
- this.applicationSelection = applicationSelection;
- this.applicationSelection.SelectionChanged += GuiSelectionChanged;
}
public void UpdateObserver()
@@ -106,11 +102,6 @@
protected override void Dispose(bool disposing)
{
- if (applicationSelection != null)
- {
- applicationSelection.SelectionChanged -= GuiSelectionChanged;
- }
-
if (observable != null)
{
observable.Detach(this);
@@ -119,18 +110,6 @@
base.Dispose(disposing);
}
- private void GuiSelectionChanged(object sender, EventArgs e)
- {
- var selection = applicationSelection.Selection;
- if (selection == null)
- {
- Data = null;
- return;
- }
-
- Data = selection;
- }
-
#region IView Members
public object Data
Index: Core/Common/src/Core.Common.Gui/Forms/ViewHost/AvalonDockViewHost.xaml.cs
===================================================================
diff -u -r49c5da81f49a23dd6e66526d264a08bf510e6963 -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Core/Common/src/Core.Common.Gui/Forms/ViewHost/AvalonDockViewHost.xaml.cs (.../AvalonDockViewHost.xaml.cs) (revision 49c5da81f49a23dd6e66526d264a08bf510e6963)
+++ Core/Common/src/Core.Common.Gui/Forms/ViewHost/AvalonDockViewHost.xaml.cs (.../AvalonDockViewHost.xaml.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -48,7 +48,8 @@
public event EventHandler ActiveDocumentViewChanging;
public event EventHandler ActiveDocumentViewChanged;
public event EventHandler ActiveViewChanged;
- public event EventHandler ViewClosed;
+ public event EventHandler ViewOpened;
+ public event EventHandler ViewClosed;
///
/// Creates a new instance of the class.
@@ -136,6 +137,8 @@
layoutDocument.Closing += OnLayoutDocumentClosing;
layoutDocument.Closed += OnLayoutDocumentClosed;
+
+ OnViewOpenedEvent(view);
}
public void AddToolView(IView view, ToolViewLocation toolViewLocation)
@@ -172,6 +175,8 @@
layoutAnchorable.Hiding += OnLayoutAnchorableHiding;
layoutAnchorable.Closing += OnLayoutAnchorableClosing;
+
+ OnViewOpenedEvent(view);
}
public void Remove(IView view)
@@ -265,11 +270,19 @@
}
}
- private void OnViewClosedEvent()
+ private void OnViewOpenedEvent(IView view)
{
+ if (ViewOpened != null)
+ {
+ ViewOpened(this, new ViewChangeEventArgs(view));
+ }
+ }
+
+ private void OnViewClosedEvent(IView view)
+ {
if (ViewClosed != null)
{
- ViewClosed(this, new EventArgs());
+ ViewClosed(this, new ViewChangeEventArgs(view));
}
}
@@ -365,7 +378,7 @@
view.Data = null;
view.Dispose();
- OnViewClosedEvent();
+ OnViewClosedEvent(view);
}
///
Index: Core/Common/src/Core.Common.Gui/Forms/ViewHost/IViewHost.cs
===================================================================
diff -u -re25d2b8b5045ee7549f406cfb8a4ea0f81ec7a7d -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Core/Common/src/Core.Common.Gui/Forms/ViewHost/IViewHost.cs (.../IViewHost.cs) (revision e25d2b8b5045ee7549f406cfb8a4ea0f81ec7a7d)
+++ Core/Common/src/Core.Common.Gui/Forms/ViewHost/IViewHost.cs (.../IViewHost.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -47,9 +47,14 @@
event EventHandler ActiveViewChanged;
///
+ /// Fired when a document view or a tool view has been opened.
+ ///
+ event EventHandler ViewOpened;
+
+ ///
/// Fired when a document view or a tool view has been closed.
///
- event EventHandler ViewClosed;
+ event EventHandler ViewClosed;
///
/// Gets the added document views.
Index: Core/Common/src/Core.Common.Gui/GuiCore.cs
===================================================================
diff -u -r0df7cded06f5afbac08b97e025242ba55c90ec57 -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Core/Common/src/Core.Common.Gui/GuiCore.cs (.../GuiCore.cs) (revision 0df7cded06f5afbac08b97e025242ba55c90ec57)
+++ Core/Common/src/Core.Common.Gui/GuiCore.cs (.../GuiCore.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -42,7 +42,6 @@
using Core.Common.Gui.Forms.ViewHost;
using Core.Common.Gui.Plugin;
using Core.Common.Gui.Properties;
-using Core.Common.Gui.Selection;
using Core.Common.Gui.Settings;
using Core.Common.Utils.Extensions;
using log4net;
@@ -65,11 +64,11 @@
private readonly IProjectFactory projectFactory;
+ private bool isExiting;
+ private bool runFinished;
private SplashScreen splashScreen;
+ private IList selectionProviders = new List();
- private bool runFinished;
- private bool isExiting;
-
///
/// Initializes a new instance of the class.
///
@@ -245,11 +244,18 @@
if (ViewHost != null)
{
ViewHost.Dispose();
+ ViewHost.ViewOpened -= OnViewOpened;
+ ViewHost.ViewClosed -= OnViewClosed;
ViewHost.ViewClosed -= OnActiveDocumentViewChanged;
ViewHost.ActiveDocumentViewChanged -= OnActiveDocumentViewChanged;
ViewHost.ActiveViewChanged -= OnActiveViewChanged;
}
+ foreach (var selectionProvider in selectionProviders)
+ {
+ selectionProvider.SelectionChanged -= OnSelectionChanged;
+ }
+
// Dispose managed resources. TODO: double check if we need to dispose managed resources?
if (mainWindow != null && !mainWindow.IsWindowDisposed)
{
@@ -476,6 +482,8 @@
InitializeMainWindow();
ViewHost = mainWindow.ViewHost;
+ ViewHost.ViewOpened += OnViewOpened;
+ ViewHost.ViewClosed += OnViewClosed;
ViewHost.ViewClosed += OnActiveDocumentViewChanged;
ViewHost.ActiveDocumentViewChanged += OnActiveDocumentViewChanged;
ViewHost.ActiveViewChanged += OnActiveViewChanged;
@@ -492,6 +500,26 @@
UpdateTitle();
}
+ private void OnViewOpened(object sender, ViewChangeEventArgs e)
+ {
+ var selectionProvider = e.View as ISelectionProvider;
+ if (selectionProvider != null)
+ {
+ selectionProviders.Add(selectionProvider);
+ selectionProvider.SelectionChanged += OnSelectionChanged;
+ }
+ }
+
+ private void OnViewClosed(object sender, ViewChangeEventArgs e)
+ {
+ var selectionProvider = e.View as ISelectionProvider;
+ if (selectionProvider != null)
+ {
+ selectionProviders.Remove(selectionProvider);
+ selectionProvider.SelectionChanged -= OnSelectionChanged;
+ }
+ }
+
private void OnActiveDocumentViewChanged(object sender, EventArgs e)
{
if (mainWindow != null && !mainWindow.IsWindowDisposed)
@@ -509,6 +537,15 @@
}
}
+ private void OnSelectionChanged(object sender, EventArgs eventArgs)
+ {
+ var selectionProvider = sender as ISelectionProvider;
+ if (selectionProvider != null)
+ {
+ Selection = selectionProvider.Selection;
+ }
+ }
+
private void InitializePlugins()
{
Plugins.ForEachElementDo(p => p.Gui = this);
@@ -597,10 +634,6 @@
private object selection;
- private bool settingSelection;
-
- public event EventHandler SelectionChanged; // TODO: make it weak
-
public object Selection
{
get
@@ -609,28 +642,24 @@
}
set
{
- if (selection == value || settingSelection)
+ if (selection == value)
{
return;
}
selection = value;
- settingSelection = true;
-
- try
+ if (mainWindow == null)
{
- if (SelectionChanged != null)
- {
- SelectionChanged(selection, new SelectedItemChangedEventArgs(value));
- }
+ return;
}
- finally
+
+ if (mainWindow.PropertyGrid != null)
{
- settingSelection = false;
+ mainWindow.PropertyGrid.Data = selection;
}
- if (!isExiting && mainWindow != null && !mainWindow.IsWindowDisposed)
+ if (!isExiting && !mainWindow.IsWindowDisposed)
{
mainWindow.ValidateItems();
}
Index: Core/Common/src/Core.Common.Gui/Selection/IApplicationSelection.cs
===================================================================
diff -u -r24da3aa72ccc0776599628c9f971081694048d9a -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Core/Common/src/Core.Common.Gui/Selection/IApplicationSelection.cs (.../IApplicationSelection.cs) (revision 24da3aa72ccc0776599628c9f971081694048d9a)
+++ Core/Common/src/Core.Common.Gui/Selection/IApplicationSelection.cs (.../IApplicationSelection.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -19,8 +19,6 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
-using System;
-
namespace Core.Common.Gui.Selection
{
///
@@ -29,11 +27,6 @@
public interface IApplicationSelection
{
///
- /// Fired when the application's selection has been changed.
- ///
- event EventHandler SelectionChanged;
-
- ///
/// Gets or sets current selected object(s) within the application.
///
object Selection { get; set; }
Fisheye: Tag 650277f75faab8d29b4a07b738f0fd2a99ac7ed3 refers to a dead (removed) revision in file `Core/Common/src/Core.Common.Gui/Selection/SelectedItemChangedEventArgs.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj
===================================================================
diff -u -ra4da6760f40992a5db81766eb5c31e8586bad5ae -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision a4da6760f40992a5db81766eb5c31e8586bad5ae)
+++ Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -135,7 +135,6 @@
-
Index: Core/Common/test/Core.Common.Gui.Test/Forms/MainWindow/MainWindowTest.cs
===================================================================
diff -u -re3f9dffa91a0def0b6e6bc7dfabef74cc64745c5 -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Core/Common/test/Core.Common.Gui.Test/Forms/MainWindow/MainWindowTest.cs (.../MainWindowTest.cs) (revision e3f9dffa91a0def0b6e6bc7dfabef74cc64745c5)
+++ Core/Common/test/Core.Common.Gui.Test/Forms/MainWindow/MainWindowTest.cs (.../MainWindowTest.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -295,8 +295,6 @@
gui.Stub(g => g.ViewHost).Return(viewHost);
gui.Selection = selectedObject;
gui.Stub(g => g.PropertyResolver).Return(propertyResolver);
- gui.Stub(g => g.SelectionChanged += null).IgnoreArguments();
- gui.Stub(g => g.SelectionChanged -= null).IgnoreArguments();
mocks.ReplayAll();
using (var mainWindow = new Gui.Forms.MainWindow.MainWindow())
@@ -334,8 +332,6 @@
gui.Stub(g => g.ViewHost).Return(viewHost);
gui.Selection = selectedObject;
gui.Stub(g => g.PropertyResolver).Return(propertyResolver);
- gui.Stub(g => g.SelectionChanged += null).IgnoreArguments();
- gui.Stub(g => g.SelectionChanged -= null).IgnoreArguments();
mocks.ReplayAll();
using (var mainWindow = new Gui.Forms.MainWindow.MainWindow())
@@ -391,8 +387,6 @@
gui.Stub(g => g.ViewHost).Return(viewHost);
gui.Selection = selectedObject;
gui.Stub(g => g.PropertyResolver).Return(propertyResolver);
- gui.Stub(g => g.SelectionChanged += null).IgnoreArguments();
- gui.Stub(g => g.SelectionChanged -= null).IgnoreArguments();
mocks.ReplayAll();
using (var mainWindow = new Gui.Forms.MainWindow.MainWindow())
Index: Core/Common/test/Core.Common.Gui.Test/Forms/ViewHost/AvalonDockViewHostTest.cs
===================================================================
diff -u -r24da3aa72ccc0776599628c9f971081694048d9a -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Core/Common/test/Core.Common.Gui.Test/Forms/ViewHost/AvalonDockViewHostTest.cs (.../AvalonDockViewHostTest.cs) (revision 24da3aa72ccc0776599628c9f971081694048d9a)
+++ Core/Common/test/Core.Common.Gui.Test/Forms/ViewHost/AvalonDockViewHostTest.cs (.../AvalonDockViewHostTest.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -110,7 +110,7 @@
# region Document views
[Test]
- public void AddDocumentView_NonControlView_ViewNotAdded()
+ public void AddDocumentView_NonControlView_ViewNotAddedAndNoViewOpenedEventFired()
{
// Setup
var mocks = new MockRepository();
@@ -119,12 +119,16 @@
using (var avalonDockViewHost = new AvalonDockViewHost())
{
+ var viewOpenedCounter = 0;
+ avalonDockViewHost.ViewOpened += (sender, args) => viewOpenedCounter++;
+
// Call
avalonDockViewHost.AddDocumentView(testView);
// Assert
CollectionAssert.IsEmpty(avalonDockViewHost.DocumentViews);
Assert.IsFalse(IsDocumentViewPresent(avalonDockViewHost, testView));
+ Assert.AreEqual(0, viewOpenedCounter);
}
mocks.VerifyAll();
@@ -133,13 +137,16 @@
[Test]
[TestCase(1)]
[TestCase(5)]
- public void AddDocumentView_MultipleTestViews_ViewsAdded(int numberOfViewsToAdd)
+ public void AddDocumentView_MultipleTestViews_ViewsAddedAndViewOpenedEventsFired(int numberOfViewsToAdd)
{
// Setup
var viewList = new List();
using (var avalonDockViewHost = new AvalonDockViewHost())
{
+ var viewOpenedCounter = 0;
+ avalonDockViewHost.ViewOpened += (sender, args) => viewOpenedCounter++;
+
for (var i = 0; i < numberOfViewsToAdd; i++)
{
var testView = new TestView();
@@ -153,6 +160,7 @@
// Assert
CollectionAssert.AreEqual(viewList, avalonDockViewHost.DocumentViews);
Assert.IsTrue(viewList.All(v => IsDocumentViewPresent(avalonDockViewHost, v)));
+ Assert.AreEqual(numberOfViewsToAdd, viewOpenedCounter);
}
}
@@ -190,7 +198,7 @@
}
[Test]
- public void AddDocumentView_ActiveDocumentViewWasAlreadyAdded_NoDuplicationAndNoActiveDocumentEventsFired()
+ public void AddDocumentView_ActiveDocumentViewWasAlreadyAdded_NoDuplicationNoViewOpenedEventFiredAndNoActiveDocumentEventsFired()
{
// Setup
var testView = new TestView();
@@ -201,6 +209,9 @@
{
avalonDockViewHost.AddDocumentView(testView);
+ var viewOpenedCounter = 0;
+ avalonDockViewHost.ViewOpened += (sender, args) => viewOpenedCounter++;
+
// Precondition
Assert.AreSame(testView, avalonDockViewHost.ActiveDocumentView);
Assert.IsTrue(IsFocussedView(avalonDockViewHost, testView));
@@ -228,11 +239,12 @@
testView
},
avalonDockViewHost.DocumentViews);
+ Assert.AreEqual(0, viewOpenedCounter);
}
}
[Test]
- public void AddDocumentView_NonActiveDocumentViewWasAlreadyAdded_NoDuplicationViewSetAsActiveDocumentViewAndActiveDocumentEventsFired()
+ public void AddDocumentView_NonActiveDocumentViewWasAlreadyAdded_NoDuplicationNoViewOpenedEventFiredViewSetAsActiveDocumentViewAndActiveDocumentEventsFired()
{
// Setup
var testView1 = new TestView();
@@ -245,6 +257,9 @@
avalonDockViewHost.AddDocumentView(testView1);
avalonDockViewHost.AddDocumentView(testView2);
+ var viewOpenedCounter = 0;
+ avalonDockViewHost.ViewOpened += (sender, args) => viewOpenedCounter++;
+
// Precondition
Assert.AreNotSame(testView1, avalonDockViewHost.ActiveDocumentView);
Assert.IsFalse(IsFocussedView(avalonDockViewHost, testView1));
@@ -274,6 +289,7 @@
testView2
},
avalonDockViewHost.DocumentViews);
+ Assert.AreEqual(0, viewOpenedCounter);
}
}
@@ -535,7 +551,7 @@
# region Tool views
[Test]
- public void AddToolView_NonControlView_ViewNotAdded()
+ public void AddToolView_NonControlView_ViewNotAddedAndNoViewOpenedEventFired()
{
// Setup
var mocks = new MockRepository();
@@ -544,12 +560,16 @@
using (var avalonDockViewHost = new AvalonDockViewHost())
{
+ var viewOpenedCounter = 0;
+ avalonDockViewHost.ViewOpened += (sender, args) => viewOpenedCounter++;
+
// Call
avalonDockViewHost.AddToolView(testView, ToolViewLocation.Left);
// Assert
CollectionAssert.IsEmpty(avalonDockViewHost.ToolViews);
Assert.IsFalse(IsToolViewPresent(avalonDockViewHost, testView, ToolViewLocation.Left));
+ Assert.AreEqual(0, viewOpenedCounter);
}
mocks.VerifyAll();
@@ -559,7 +579,7 @@
[TestCase(ToolViewLocation.Left)]
[TestCase(ToolViewLocation.Right)]
[TestCase(ToolViewLocation.Bottom)]
- public void AddToolView_TestViews_ViewAdded(ToolViewLocation toolViewLocation)
+ public void AddToolView_TestViews_ViewAddedAndViewOpenedEventFired(ToolViewLocation toolViewLocation)
{
// Setup
var testView = new TestView();
@@ -572,6 +592,9 @@
using (var avalonDockViewHost = new AvalonDockViewHost())
{
+ var viewOpenedCounter = 0;
+ avalonDockViewHost.ViewOpened += (sender, args) => viewOpenedCounter++;
+
// Call
avalonDockViewHost.AddToolView(testView, toolViewLocation);
@@ -584,6 +607,7 @@
avalonDockViewHost.ToolViews);
Assert.IsTrue(IsToolViewPresent(avalonDockViewHost, testView, toolViewLocation));
Assert.IsFalse(otherToolViewLocations.Any(tvl => IsToolViewPresent(avalonDockViewHost, testView, tvl)));
+ Assert.AreEqual(1, viewOpenedCounter);
}
}
@@ -640,7 +664,7 @@
}
[Test]
- public void AddToolView_ToolViewWasAlreadyAdded_NoDuplicationAndViewFocussed()
+ public void AddToolView_ToolViewWasAlreadyAdded_NoDuplicationNoViewOpenedEventFiredAndViewFocussed()
{
// Setup
var testView1 = new TestView();
@@ -651,6 +675,9 @@
avalonDockViewHost.AddToolView(testView1, ToolViewLocation.Left);
avalonDockViewHost.AddToolView(testView2, ToolViewLocation.Left);
+ var viewOpenedCounter = 0;
+ avalonDockViewHost.ViewOpened += (sender, args) => viewOpenedCounter++;
+
// Precondition
CollectionAssert.AreEqual(
new[]
@@ -673,6 +700,7 @@
},
avalonDockViewHost.ToolViews);
Assert.IsTrue(IsFocussedView(avalonDockViewHost, testView1));
+ Assert.AreEqual(0, viewOpenedCounter);
}
}
Index: Core/Common/test/Core.Common.Gui.Test/GuiCoreTest.cs
===================================================================
diff -u -r24da3aa72ccc0776599628c9f971081694048d9a -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Core/Common/test/Core.Common.Gui.Test/GuiCoreTest.cs (.../GuiCoreTest.cs) (revision 24da3aa72ccc0776599628c9f971081694048d9a)
+++ Core/Common/test/Core.Common.Gui.Test/GuiCoreTest.cs (.../GuiCoreTest.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -27,6 +27,7 @@
using Core.Common.Base.Data;
using Core.Common.Base.Storage;
using Core.Common.Controls.TreeView;
+using Core.Common.Controls.Views;
using Core.Common.Gui.Commands;
using Core.Common.Gui.ContextMenu;
using Core.Common.Gui.Forms.MainWindow;
@@ -35,7 +36,6 @@
using Core.Common.Gui.Forms.ViewHost;
using Core.Common.Gui.Plugin;
using Core.Common.Gui.Settings;
-using Core.Common.Gui.Test.Forms.ViewHost;
using Core.Common.TestUtil;
using log4net;
using log4net.Appender;
@@ -1020,5 +1020,271 @@
}
mocks.VerifyAll();
}
+
+ [Test]
+ [STAThread]
+ public void GivenGuiWithoutSelection_WhenSelectionProviderAdded_ThenSelectionSynced()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var projectStore = mocks.Stub();
+ var projectFactory = mocks.Stub();
+ mocks.ReplayAll();
+
+ var selectionProvider = new TestSelectionProvider();
+
+ using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings()))
+ {
+ gui.Run();
+
+ // Precondition
+ Assert.IsNull(gui.Selection);
+
+ // Call
+ gui.ViewHost.AddDocumentView(selectionProvider);
+
+ // Assert
+ Assert.AreSame(selectionProvider.Selection, gui.Selection);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [STAThread]
+ public void GivenGuiWithRandomSelection_WhenSelectionProviderAdded_ThenSelectionSynced()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var projectStore = mocks.Stub();
+ var projectFactory = mocks.Stub();
+ mocks.ReplayAll();
+
+ var selectionProvider = new TestSelectionProvider();
+
+ using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings()))
+ {
+ gui.Run();
+
+ gui.Selection = new object();
+
+ // Call
+ gui.ViewHost.AddDocumentView(selectionProvider);
+
+ // Assert
+ Assert.AreSame(selectionProvider.Selection, gui.Selection);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [STAThread]
+ public void GivenGuiWithRandomSelection_WhenNonSelectionProviderAdded_ThenSelectionPreserved()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var projectStore = mocks.Stub();
+ var projectFactory = mocks.Stub();
+ mocks.ReplayAll();
+
+ var selection = new object();
+
+ using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings()))
+ {
+ gui.Run();
+
+ gui.Selection = selection;
+
+ // Call
+ gui.ViewHost.AddDocumentView(new TestView());
+
+ // Assert
+ Assert.AreSame(selection, gui.Selection);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [STAThread]
+ public void GivenGuiWithRandomSelection_WhenSelectionChangedOnAddedSelectionProvider_ThenSelectionSynced()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var projectStore = mocks.Stub();
+ var projectFactory = mocks.Stub();
+ mocks.ReplayAll();
+
+ var selectionProvider = new TestSelectionProvider();
+
+ using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings()))
+ {
+ gui.Run();
+ gui.ViewHost.AddDocumentView(selectionProvider);
+
+ gui.Selection = new object();
+
+ // Call
+ selectionProvider.ChangeSelection();
+
+ // Assert
+ Assert.AreSame(selectionProvider.Selection, gui.Selection);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [STAThread]
+ public void GivenGuiWithRandomSelection_WhenSelectionChangedOnRemovedSelectionProvider_ThenSelectionNoLongerSynced()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var projectStore = mocks.Stub();
+ var projectFactory = mocks.Stub();
+ mocks.ReplayAll();
+
+ var selection = new object();
+ var selectionProvider = new TestSelectionProvider();
+
+ using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings()))
+ {
+ gui.Run();
+ gui.ViewHost.AddDocumentView(selectionProvider);
+ gui.ViewHost.Remove(selectionProvider);
+
+ gui.Selection = selection;
+
+ // Call
+ selectionProvider.ChangeSelection();
+
+ // Assert
+ Assert.AreSame(selection, gui.Selection);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [STAThread]
+ public void GivenGuiWithRandomSelection_WhenSelectionProviderBecomesActiveView_ThenSelectionSynced()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var projectStore = mocks.Stub();
+ var projectFactory = mocks.Stub();
+ mocks.ReplayAll();
+
+ var selectionProvider = new TestSelectionProvider();
+
+ using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings()))
+ {
+ gui.Run();
+ gui.ViewHost.AddDocumentView(selectionProvider);
+ gui.ViewHost.AddDocumentView(new TestView());
+
+ gui.Selection = new object();
+
+ // Call
+ gui.ViewHost.SetFocusToView(selectionProvider);
+
+ // Assert
+ Assert.AreSame(selectionProvider.Selection, gui.Selection);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [STAThread]
+ public void GivenGuiWithRandomSelection_WhenNonSelectionProviderBecomesActiveView_ThenSelectionPreserved()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var projectStore = mocks.Stub();
+ var projectFactory = mocks.Stub();
+ mocks.ReplayAll();
+
+ var testView = new TestView();
+ var selection = new object();
+
+ using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings()))
+ {
+ gui.Run();
+ gui.ViewHost.AddDocumentView(testView);
+
+ gui.Selection = selection;
+
+ // Call
+ gui.ViewHost.SetFocusToView(testView);
+
+ // Assert
+ Assert.AreSame(selection, gui.Selection);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [STAThread]
+ public void GivenGuiWithRandomSelection_WhenGuiDisposed_ThenSelectionNoLongerSynced()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var projectStore = mocks.Stub();
+ var projectFactory = mocks.Stub();
+ mocks.ReplayAll();
+
+ var selectionProvider = new TestSelectionProvider();
+
+ using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings()))
+ {
+ gui.Run();
+ gui.ViewHost.AddDocumentView(selectionProvider);
+
+ gui.Dispose();
+
+ // Precondition
+ Assert.IsNull(gui.Selection);
+
+ // Call
+ selectionProvider.ChangeSelection();
+
+ // Assert
+ Assert.IsNull(gui.Selection);
+ }
+ mocks.VerifyAll();
+ }
+
+ private class TestSelectionProvider : Control, ISelectionProvider
+ {
+ private object selection;
+
+ public event EventHandler SelectionChanged;
+
+ public TestSelectionProvider()
+ {
+ selection = new object();
+ }
+
+ public object Data { get; set; }
+
+ public object Selection
+ {
+ get
+ {
+ return selection;
+ }
+ }
+
+ public void ChangeSelection()
+ {
+ selection = new object();
+
+ if (SelectionChanged != null)
+ {
+ SelectionChanged(this, new EventArgs());
+ }
+ }
+ }
+
+ private class TestView : Control, IView
+ {
+ public object Data { get; set; }
+ }
}
}
\ No newline at end of file
Fisheye: Tag 650277f75faab8d29b4a07b738f0fd2a99ac7ed3 refers to a dead (removed) revision in file `Core/Common/test/Core.Common.Gui.Test/Selection/SelectedItemChangedEventArgsTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Core/Plugins/src/Core.Plugins.Map/Legend/MapLegendView.cs
===================================================================
diff -u -ra8bfedc443289dd37ebd3c2304d4c4add4ef7d58 -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Core/Plugins/src/Core.Plugins.Map/Legend/MapLegendView.cs (.../MapLegendView.cs) (revision a8bfedc443289dd37ebd3c2304d4c4add4ef7d58)
+++ Core/Plugins/src/Core.Plugins.Map/Legend/MapLegendView.cs (.../MapLegendView.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -44,13 +44,15 @@
///
/// The view which shows the data that is added to a .
///
- public sealed partial class MapLegendView : UserControl, IView
+ public sealed partial class MapLegendView : UserControl, ISelectionProvider
{
private static readonly ILog log = LogManager.GetLogger(typeof(MapLegendView));
private readonly IContextMenuBuilderProvider contextMenuBuilderProvider;
private readonly IWin32Window parentWindow;
+ public event EventHandler SelectionChanged;
+
///
/// Creates a new instance of .
///
@@ -74,6 +76,8 @@
Text = MapResources.General_Map;
RegisterTreeNodeInfos();
+
+ treeViewControl.SelectedDataChanged += TreeViewControlSelectedDataChanged;
}
public object Data
@@ -88,6 +92,22 @@
}
}
+ public object Selection
+ {
+ get
+ {
+ return treeViewControl.SelectedData;
+ }
+ }
+
+ private void TreeViewControlSelectedDataChanged(object sender, EventArgs e)
+ {
+ if (SelectionChanged != null)
+ {
+ SelectionChanged(this, new EventArgs());
+ }
+ }
+
private void RegisterTreeNodeInfos()
{
treeViewControl.RegisterTreeNodeInfo(new TreeNodeInfo
@@ -200,7 +220,7 @@
}
}
- private void CheckDataFormat(string filePath, string title, MapDataCollection mapDataCollection)
+ private static void CheckDataFormat(string filePath, string title, MapDataCollection mapDataCollection)
{
try
{
@@ -271,7 +291,7 @@
}
}
- private FeatureBasedMapData GetShapeFileData(ShapeFileReaderBase reader, string title)
+ private static FeatureBasedMapData GetShapeFileData(ShapeFileReaderBase reader, string title)
{
return reader.ReadShapeFile(title);
}
Index: Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectExplorer.cs
===================================================================
diff -u -rae99d19be5c1bd59e6cc85669c96a3b9895e660d -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectExplorer.cs (.../ProjectExplorer.cs) (revision ae99d19be5c1bd59e6cc85669c96a3b9895e660d)
+++ Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectExplorer.cs (.../ProjectExplorer.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -25,7 +25,6 @@
using Core.Common.Controls.TreeView;
using Core.Common.Gui.Commands;
using Core.Common.Gui.Forms;
-using Core.Common.Gui.Selection;
using Core.Common.Utils.Events;
using Core.Plugins.ProjectExplorer.Properties;
@@ -37,29 +36,24 @@
///
public sealed partial class ProjectExplorer : UserControl, IProjectExplorer
{
- private readonly IApplicationSelection applicationSelection;
private readonly IViewCommands viewCommands;
+ public event EventHandler SelectionChanged;
+
///
/// Creates a new instance of .
///
- /// The owner of the selection in the application.
/// The provider of view related commands.
/// The of which
/// are used to draw nodes.
/// Thrown when either:
///
- /// - is null,
/// - is null,
/// - is null
///
///
- public ProjectExplorer(IApplicationSelection applicationSelection, IViewCommands viewCommands, IEnumerable treeNodeInfos)
+ public ProjectExplorer(IViewCommands viewCommands, IEnumerable treeNodeInfos)
{
- if (applicationSelection == null)
- {
- throw new ArgumentNullException("applicationSelection");
- }
if (viewCommands == null)
{
throw new ArgumentNullException("viewCommands");
@@ -72,7 +66,6 @@
Text = Resources.General_ProjectExplorer;
- this.applicationSelection = applicationSelection;
this.viewCommands = viewCommands;
RegisterTreeNodeInfos(treeNodeInfos);
@@ -127,7 +120,10 @@
private void TreeViewControlSelectedDataChanged(object sender, EventArgs e)
{
- applicationSelection.Selection = treeViewControl.SelectedData;
+ if (SelectionChanged != null)
+ {
+ SelectionChanged(this, new EventArgs());
+ }
}
private void TreeViewControlDataDoubleClick(object sender, EventArgs e)
Index: Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectExplorerPlugin.cs
===================================================================
diff -u -r49c5da81f49a23dd6e66526d264a08bf510e6963 -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectExplorerPlugin.cs (.../ProjectExplorerPlugin.cs) (revision 49c5da81f49a23dd6e66526d264a08bf510e6963)
+++ Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectExplorerPlugin.cs (.../ProjectExplorerPlugin.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -28,7 +28,6 @@
using Core.Common.Gui.Commands;
using Core.Common.Gui.Forms;
using Core.Common.Gui.Plugin;
-using Core.Common.Gui.Selection;
using Core.Plugins.ProjectExplorer.Commands;
using Core.Plugins.ProjectExplorer.Exceptions;
using ProjectExplorerResources = Core.Plugins.ProjectExplorer.Properties.Resources;
@@ -44,7 +43,6 @@
private ProjectExplorerViewController projectExplorerViewController;
private IViewCommands viewCommands;
private IProjectOwner projectOwner;
- private IApplicationSelection applicationSelection;
private Ribbon ribbonCommandHandler;
private IEnumerable treeNodeInfos;
private bool active;
@@ -71,15 +69,13 @@
{
viewController = value;
projectOwner = value;
- applicationSelection = value;
viewCommands = value.ViewCommands;
treeNodeInfos = value.GetTreeNodeInfos();
}
else
{
viewController = null;
projectOwner = null;
- applicationSelection = null;
viewCommands = null;
treeNodeInfos = null;
}
@@ -103,7 +99,7 @@
base.Activate();
try
{
- projectExplorerViewController = new ProjectExplorerViewController(viewCommands, applicationSelection, viewController, treeNodeInfos);
+ projectExplorerViewController = new ProjectExplorerViewController(viewCommands, viewController, treeNodeInfos);
}
catch (ArgumentNullException e)
{
Index: Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectExplorerViewController.cs
===================================================================
diff -u -re7e22e69b16b23c89c063f18444c82aa818dc176 -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectExplorerViewController.cs (.../ProjectExplorerViewController.cs) (revision e7e22e69b16b23c89c063f18444c82aa818dc176)
+++ Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectExplorerViewController.cs (.../ProjectExplorerViewController.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -27,7 +27,6 @@
using Core.Common.Gui;
using Core.Common.Gui.Commands;
using Core.Common.Gui.Forms.ViewHost;
-using Core.Common.Gui.Selection;
using Core.Plugins.ProjectExplorer.Properties;
namespace Core.Plugins.ProjectExplorer
@@ -39,7 +38,6 @@
{
private readonly IViewController viewController;
private readonly IEnumerable treeNodeInfos;
- private readonly IApplicationSelection applicationSelection;
private readonly IViewCommands viewCommands;
private ProjectExplorer projectExplorer;
@@ -53,28 +51,22 @@
/// Creates a new instance of .
///
/// The provider of view related commands.
- /// The owner of the selection in the application.
/// The provider of view related commands.
/// The of which
/// are used to draw nodes.
/// Thrown when either:
///
/// - is null,
- /// - is null,
/// - is null,
/// - is null
///
///
- public ProjectExplorerViewController(IViewCommands viewCommands, IApplicationSelection applicationSelection, IViewController viewController, IEnumerable treeNodeInfos)
+ public ProjectExplorerViewController(IViewCommands viewCommands, IViewController viewController, IEnumerable treeNodeInfos)
{
if (viewCommands == null)
{
throw new ArgumentNullException("viewCommands");
}
- if (applicationSelection == null)
- {
- throw new ArgumentNullException("applicationSelection");
- }
if (viewController == null)
{
throw new ArgumentNullException("viewController");
@@ -85,7 +77,6 @@
}
this.viewController = viewController;
- this.applicationSelection = applicationSelection;
this.treeNodeInfos = treeNodeInfos;
this.viewCommands = viewCommands;
}
@@ -142,7 +133,7 @@
private void OpenProjectExplorer()
{
- projectExplorer = new ProjectExplorer(applicationSelection, viewCommands, treeNodeInfos);
+ projectExplorer = new ProjectExplorer(viewCommands, treeNodeInfos);
viewController.ViewHost.AddToolView(projectExplorer, ToolViewLocation.Left);
viewController.ViewHost.SetImage(projectExplorer, Resources.ProjectExplorerIcon);
Index: Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapLegendViewTest.cs
===================================================================
diff -u -rce31448a066c084f755439f3e7d453bfb042b291 -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapLegendViewTest.cs (.../MapLegendViewTest.cs) (revision ce31448a066c084f755439f3e7d453bfb042b291)
+++ Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapLegendViewTest.cs (.../MapLegendViewTest.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -205,6 +205,66 @@
}
}
+ [Test]
+ [RequiresSTA]
+ public void Selection_Always_ReturnsSelectedNodeData()
+ {
+ // Setup
+ var mapData = new MapLineData("line data");
+ var mapDataCollection = new MapDataCollection("collection");
+
+ mapDataCollection.Add(mapData);
+
+ using (var view = new MapLegendView(contextMenuBuilderProvider, parentWindow)
+ {
+ Data = mapDataCollection
+ })
+ {
+ var treeViewControl = TypeUtils.GetField(view, "treeViewControl");
+
+ WindowsFormsTestHelper.Show(treeViewControl);
+ treeViewControl.TrySelectNodeForData(mapData);
+
+ // Call
+ var selection = view.Selection;
+
+ // Assert
+ Assert.AreSame(mapData, selection);
+ }
+ WindowsFormsTestHelper.CloseAll();
+ }
+
+ [Test]
+ [RequiresSTA]
+ public void TreeViewSelectedNodeChanged_Always_SelectionChangedFired()
+ {
+ // Setup
+ var mapData = new MapLineData("line data");
+ var mapDataCollection = new MapDataCollection("collection");
+
+ mapDataCollection.Add(mapData);
+
+ using (var view = new MapLegendView(contextMenuBuilderProvider, parentWindow)
+ {
+ Data = mapDataCollection
+ })
+ {
+ var treeViewControl = TypeUtils.GetField(view, "treeViewControl");
+
+ WindowsFormsTestHelper.Show(treeViewControl);
+
+ var selectionChangedCount = 0;
+ view.SelectionChanged += (sender, args) => selectionChangedCount++;
+
+ // Call
+ treeViewControl.TrySelectNodeForData(mapData);
+
+ // Assert
+ Assert.AreEqual(1, selectionChangedCount);
+ }
+ WindowsFormsTestHelper.CloseAll();
+ }
+
private static MapFeature[] CreateFeatures()
{
return new[]
Index: Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/Commands/ToggleProjectExplorerCommandTest.cs
===================================================================
diff -u -rf64dceaa32788bad28dcf09f4a1c3150595f1327 -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/Commands/ToggleProjectExplorerCommandTest.cs (.../ToggleProjectExplorerCommandTest.cs) (revision f64dceaa32788bad28dcf09f4a1c3150595f1327)
+++ Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/Commands/ToggleProjectExplorerCommandTest.cs (.../ToggleProjectExplorerCommandTest.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -28,7 +28,6 @@
using Core.Common.Gui;
using Core.Common.Gui.Commands;
using Core.Common.Gui.Forms.ViewHost;
-using Core.Common.Gui.Selection;
using Core.Plugins.ProjectExplorer.Commands;
using NUnit.Framework;
using Rhino.Mocks;
@@ -53,21 +52,18 @@
{
// Setup
var mocks = new MockRepository();
-
var viewCommands = mocks.StrictMock();
- var applicationSelection = mocks.StrictMock();
-
var viewHost = mocks.StrictMock();
- viewHost.Stub(vm => vm.ToolViews).Return(new List());
-
var viewController = mocks.StrictMock();
+
+ viewHost.Stub(vm => vm.ToolViews).Return(new List());
viewController.Stub(tvc => tvc.ViewHost).Return(viewHost);
mocks.ReplayAll();
var treeNodeInfos = Enumerable.Empty();
- using (var explorerViewController = new ProjectExplorerViewController(viewCommands, applicationSelection, viewController, treeNodeInfos))
+ using (var explorerViewController = new ProjectExplorerViewController(viewCommands, viewController, treeNodeInfos))
{
// Call
var command = new ToggleProjectExplorerCommand(explorerViewController);
@@ -85,13 +81,12 @@
{
// Setup
var mocks = new MockRepository();
-
var viewCommands = mocks.StrictMock();
- var applicationSelection = mocks.Stub();
-
var toolViewList = new List();
var viewHost = mocks.StrictMock();
+
viewHost.Stub(vm => vm.ToolViews).Return(toolViewList);
+
if (isViewOpen)
{
viewHost.Expect(vm => vm.AddToolView(Arg.Matches(c => true),
@@ -108,7 +103,7 @@
var treeNodeInfos = Enumerable.Empty();
- using (var explorerViewController = new ProjectExplorerViewController(viewCommands, applicationSelection, viewController, treeNodeInfos))
+ using (var explorerViewController = new ProjectExplorerViewController(viewCommands, viewController, treeNodeInfos))
{
var command = new ToggleProjectExplorerCommand(explorerViewController);
@@ -134,10 +129,9 @@
// Setup
var mocks = new MockRepository();
var viewCommands = mocks.StrictMock();
- var applicationSelection = mocks.Stub();
-
var toolViewList = new List();
var viewHost = mocks.StrictMock();
+
viewHost.Stub(vm => vm.ToolViews).Return(toolViewList);
viewHost.Expect(vm => vm.AddToolView(Arg.Matches(c => true),
Arg.Matches(vl => vl == ToolViewLocation.Left)))
@@ -153,7 +147,7 @@
var treeNodeInfos = Enumerable.Empty();
- using (var explorerViewController = new ProjectExplorerViewController(viewCommands, applicationSelection, viewController, treeNodeInfos))
+ using (var explorerViewController = new ProjectExplorerViewController(viewCommands, viewController, treeNodeInfos))
{
if (isViewOpen)
{
Index: Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerPluginTest.cs
===================================================================
diff -u -rf64dceaa32788bad28dcf09f4a1c3150595f1327 -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerPluginTest.cs (.../ProjectExplorerPluginTest.cs) (revision f64dceaa32788bad28dcf09f4a1c3150595f1327)
+++ Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerPluginTest.cs (.../ProjectExplorerPluginTest.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -82,8 +82,6 @@
viewHost.Stub(vm => vm.AddToolView(Arg.Is.TypeOf, Arg.Matches(vl => vl == ToolViewLocation.Left)));
viewHost.Stub(vm => vm.SetImage(null, null)).IgnoreArguments();
guiStub.Stub(g => g.ViewHost).Return(viewHost);
- guiStub.Stub(g => g.SelectionChanged += null).IgnoreArguments();
- guiStub.Stub(g => g.SelectionChanged -= null).IgnoreArguments();
guiStub.Expect(g => g.ProjectOpened += null).IgnoreArguments();
guiStub.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
mocks.ReplayAll();
@@ -116,8 +114,6 @@
viewHost.Stub(vm => vm.AddToolView(Arg.Is.TypeOf, Arg.Matches(vl => vl == ToolViewLocation.Left)));
viewHost.Stub(vm => vm.SetImage(null, null)).IgnoreArguments();
guiStub.Stub(g => g.ViewHost).Return(viewHost);
- guiStub.Stub(g => g.SelectionChanged += null).IgnoreArguments();
- guiStub.Stub(g => g.SelectionChanged -= null).IgnoreArguments();
guiStub.Stub(g => g.ProjectOpened += null).IgnoreArguments();
guiStub.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
mocks.ReplayAll();
@@ -155,8 +151,6 @@
viewHost.Stub(vm => vm.AddToolView(Arg.Is.TypeOf, Arg.Matches(vl => vl == ToolViewLocation.Left)));
viewHost.Stub(vm => vm.SetImage(null, null)).IgnoreArguments();
guiStub.Stub(g => g.ViewHost).Return(viewHost);
- guiStub.Stub(g => g.SelectionChanged += null).IgnoreArguments();
- guiStub.Stub(g => g.SelectionChanged -= null).IgnoreArguments();
guiStub.Stub(g => g.ProjectOpened += null).IgnoreArguments();
guiStub.Expect(g => g.ProjectOpened -= null).IgnoreArguments();
Index: Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerTest.cs
===================================================================
diff -u -r7ae9100ff4e61169edcefaeb01b72d492431742f -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerTest.cs (.../ProjectExplorerTest.cs) (revision 7ae9100ff4e61169edcefaeb01b72d492431742f)
+++ Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerTest.cs (.../ProjectExplorerTest.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -27,7 +27,6 @@
using Core.Common.Controls.TreeView;
using Core.Common.Gui.Commands;
using Core.Common.Gui.Forms;
-using Core.Common.Gui.Selection;
using Core.Common.TestUtil;
using Core.Common.Utils.Reflection;
using NUnit.Extensions.Forms;
@@ -42,38 +41,35 @@
[Test]
[TestCase(0)]
[TestCase(1)]
- [TestCase(2)]
public void Constructor_ArgumentsNull_ThrowsArgumentNullException(int paramNullIndex)
{
// Setup
var mocks = new MockRepository();
- IApplicationSelection applicationSelection = paramNullIndex == 0 ? null : mocks.StrictMock();
- IViewCommands viewCommands = paramNullIndex == 1 ? null : mocks.StrictMock();
- IEnumerable treeNodeInfos = paramNullIndex == 2 ? null : Enumerable.Empty();
+ IViewCommands viewCommands = paramNullIndex == 0 ? null : mocks.StrictMock();
+ IEnumerable treeNodeInfos = paramNullIndex == 1 ? null : Enumerable.Empty();
mocks.ReplayAll();
// Call
- TestDelegate test = () => new ProjectExplorer(applicationSelection, viewCommands, treeNodeInfos);
+ TestDelegate test = () => new ProjectExplorer(viewCommands, treeNodeInfos);
// Assert
Assert.Throws(test);
mocks.VerifyAll();
}
[Test]
- public void Constructor_NoNullArguments_CreatesNewInstanceApplicationSelectionEventBound()
+ public void Constructor_NoNullArguments_CreatesNewInstance()
{
// Setup
var mocks = new MockRepository();
- IApplicationSelection applicationSelection = mocks.Stub();
IViewCommands viewCommands = mocks.StrictMock();
IEnumerable treeNodeInfos = Enumerable.Empty();
mocks.ReplayAll();
// Call
- using (var explorer = new ProjectExplorer(applicationSelection, viewCommands, treeNodeInfos))
+ using (var explorer = new ProjectExplorer(viewCommands, treeNodeInfos))
{
// Assert
Assert.IsInstanceOf(explorer);
@@ -89,9 +85,9 @@
{
// Setup
var mocks = new MockRepository();
- IApplicationSelection applicationSelection = mocks.Stub();
IViewCommands viewCommands = mocks.StrictMock();
var projectStub = mocks.Stub();
+
mocks.ReplayAll();
IEnumerable treeNodeInfos = new[]
@@ -102,7 +98,7 @@
}
};
- using (var explorer = new ProjectExplorer(applicationSelection, viewCommands, treeNodeInfos))
+ using (var explorer = new ProjectExplorer(viewCommands, treeNodeInfos))
{
// Call
explorer.Data = projectStub;
@@ -118,9 +114,9 @@
{
// Setup
var mocks = new MockRepository();
- IApplicationSelection applicationSelection = mocks.Stub();
IViewCommands viewCommands = mocks.StrictMock();
var projectStub = mocks.Stub();
+
viewCommands.Expect(vc => vc.RemoveAllViewsForItem(projectStub));
mocks.ReplayAll();
@@ -140,7 +136,7 @@
messageBox.ClickOk();
};
- using (var explorer = new ProjectExplorer(applicationSelection, viewCommands, treeNodeInfos)
+ using (var explorer = new ProjectExplorer(viewCommands, treeNodeInfos)
{
Data = projectStub
})
@@ -154,22 +150,15 @@
[Test]
[RequiresSTA]
- public void TreeViewSelectedNodeChanged_Always_SetsApplicationSelection()
+ public void TreeViewSelectedNodeChanged_Always_SelectionChangedFired()
{
// Setup
var mocks = new MockRepository();
- IApplicationSelection applicationSelection = mocks.StrictMock();
IViewCommands viewCommands = mocks.StrictMock();
var projectStub = mocks.Stub();
var stringA = "testA";
- using (mocks.Ordered())
- {
- applicationSelection.Expect(a => a.Selection = projectStub);
- applicationSelection.Expect(a => a.Selection = stringA);
- }
-
mocks.ReplayAll();
var stringB = "testB";
@@ -191,21 +180,21 @@
}
};
- using (var explorer = new ProjectExplorer(applicationSelection, viewCommands, treeNodeInfos)
+ using (var explorer = new ProjectExplorer(viewCommands, treeNodeInfos)
{
Data = projectStub
})
{
WindowsFormsTestHelper.Show(explorer.TreeViewControl);
- // Precondition
- Assert.AreNotSame(explorer.TreeViewControl.SelectedData, stringA);
+ var selectionChangedCount = 0;
+ explorer.SelectionChanged += (sender, args) => selectionChangedCount++;
// Call
explorer.TreeViewControl.TrySelectNodeForData(stringA);
// Assert
- Assert.AreSame(explorer.TreeViewControl.SelectedData, stringA);
+ Assert.AreEqual(1, selectionChangedCount);
}
WindowsFormsTestHelper.CloseAll();
mocks.VerifyAll();
@@ -219,7 +208,6 @@
var treeIdentifier = "SomeName";
var formIdentifier = "SomeForm";
var mocks = new MockRepository();
- IApplicationSelection applicationSelection = mocks.Stub();
IViewCommands viewCommands = mocks.StrictMock();
var projectStub = mocks.Stub();
@@ -238,7 +226,7 @@
viewCommands.Expect(a => a.OpenViewForSelection());
}
- using (var explorer = new ProjectExplorer(applicationSelection, viewCommands, treeNodeInfos)
+ using (var explorer = new ProjectExplorer(viewCommands, treeNodeInfos)
{
Data = projectStub
})
@@ -270,7 +258,6 @@
{
// Setup
var mocks = new MockRepository();
- IApplicationSelection applicationSelection = mocks.Stub();
IViewCommands viewCommands = mocks.StrictMock();
var projectStub = mocks.Stub();
@@ -296,7 +283,7 @@
}
};
- using (var explorer = new ProjectExplorer(applicationSelection, viewCommands, treeNodeInfos)
+ using (var explorer = new ProjectExplorer(viewCommands, treeNodeInfos)
{
Data = projectStub
})
Index: Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerViewControllerTest.cs
===================================================================
diff -u -rf64dceaa32788bad28dcf09f4a1c3150595f1327 -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerViewControllerTest.cs (.../ProjectExplorerViewControllerTest.cs) (revision f64dceaa32788bad28dcf09f4a1c3150595f1327)
+++ Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerViewControllerTest.cs (.../ProjectExplorerViewControllerTest.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -28,7 +28,6 @@
using Core.Common.Gui;
using Core.Common.Gui.Commands;
using Core.Common.Gui.Forms.ViewHost;
-using Core.Common.Gui.Selection;
using NUnit.Framework;
using Rhino.Mocks;
@@ -41,20 +40,18 @@
[TestCase(1)]
[TestCase(2)]
[TestCase(3)]
- [TestCase(4)]
public void Constructor_ArgumentsNull_ThrowsArgumentNullException(int paramNullIndex)
{
// Setup
var mocks = new MockRepository();
IViewCommands viewCommands = paramNullIndex == 1 ? null : mocks.StrictMock();
- IApplicationSelection applicationSelection = paramNullIndex == 2 ? null : mocks.StrictMock();
- IViewController viewController = paramNullIndex == 3 ? null : mocks.StrictMock();
- IEnumerable treeNodeInfos = paramNullIndex == 4 ? null : Enumerable.Empty();
+ IViewController viewController = paramNullIndex == 2 ? null : mocks.StrictMock();
+ IEnumerable treeNodeInfos = paramNullIndex == 3 ? null : Enumerable.Empty();
mocks.ReplayAll();
// Call
- TestDelegate test = () => new ProjectExplorerViewController(viewCommands, applicationSelection, viewController, treeNodeInfos);
+ TestDelegate test = () => new ProjectExplorerViewController(viewCommands, viewController, treeNodeInfos);
// Assert
Assert.Throws(test);
@@ -67,10 +64,9 @@
// Setup
var mocks = new MockRepository();
IViewCommands viewCommands = mocks.StrictMock();
- IApplicationSelection applicationSelection = mocks.Stub();
-
IViewHost viewHost = mocks.Stub();
var toolViewList = new List();
+
viewHost.Stub(vm => vm.ToolViews).Return(toolViewList);
viewHost.Expect(vm => vm.AddToolView(Arg.Matches(c => true),
Arg.Matches(vl => vl == ToolViewLocation.Left)))
@@ -85,7 +81,7 @@
IEnumerable treeNodeInfos = Enumerable.Empty();
- using (var controller = new ProjectExplorerViewController(viewCommands, applicationSelection, viewController, treeNodeInfos))
+ using (var controller = new ProjectExplorerViewController(viewCommands, viewController, treeNodeInfos))
{
controller.ToggleView();
// Call
@@ -101,9 +97,8 @@
// Setup
var mocks = new MockRepository();
IViewCommands viewCommands = mocks.StrictMock();
- IApplicationSelection applicationSelection = mocks.Stub();
-
IViewHost viewHost = mocks.Stub();
+
viewHost.Stub(vm => vm.ToolViews).Return(new List());
viewHost.Stub(vm => vm.AddToolView(Arg.Is.TypeOf, Arg.Matches(vl => vl == ToolViewLocation.Left)));
viewHost.Expect(vm => vm.SetImage(null, null)).IgnoreArguments();
@@ -115,7 +110,7 @@
IEnumerable treeNodeInfos = Enumerable.Empty();
- using (var controller = new ProjectExplorerViewController(viewCommands, applicationSelection, viewController, treeNodeInfos))
+ using (var controller = new ProjectExplorerViewController(viewCommands, viewController, treeNodeInfos))
{
// Call
controller.ToggleView();
@@ -132,12 +127,10 @@
// Setup
var mocks = new MockRepository();
IViewCommands viewCommands = mocks.StrictMock();
- IApplicationSelection applicationSelection = mocks.Stub();
-
var toolViewList = new List();
var viewHost = mocks.StrictMock();
-
IViewController viewController = mocks.StrictMock();
+
viewController.Stub(tvc => tvc.ViewHost).Return(viewHost);
viewHost.Stub(vm => vm.ToolViews).Return(toolViewList);
@@ -154,7 +147,7 @@
IEnumerable treeNodeInfos = Enumerable.Empty();
- using (var controller = new ProjectExplorerViewController(viewCommands, applicationSelection, viewController, treeNodeInfos))
+ using (var controller = new ProjectExplorerViewController(viewCommands, viewController, treeNodeInfos))
{
if (isOpen)
{
@@ -175,11 +168,9 @@
// Setup
var mocks = new MockRepository();
IViewCommands viewCommands = mocks.StrictMock();
- IApplicationSelection applicationSelection = mocks.Stub();
-
IViewHost viewHost = mocks.Stub();
-
var toolViewList = new List();
+
viewHost.Stub(vm => vm.ToolViews).Return(toolViewList);
viewHost.Expect(vm => vm.AddToolView(Arg.Matches(c => true),
Arg.Matches(vl => vl == ToolViewLocation.Left)))
@@ -201,7 +192,7 @@
}
};
- using (var controller = new ProjectExplorerViewController(viewCommands, applicationSelection, viewController, treeNodeInfos))
+ using (var controller = new ProjectExplorerViewController(viewCommands, viewController, treeNodeInfos))
{
controller.ToggleView();
@@ -221,9 +212,7 @@
// Setup
var mocks = new MockRepository();
IViewCommands viewCommands = mocks.StrictMock();
- IApplicationSelection applicationSelection = mocks.StrictMock();
IViewController viewController = mocks.Stub();
-
var viewHost = mocks.StrictMock();
viewController.Stub(tvc => tvc.ViewHost).Return(viewHost);
@@ -234,7 +223,7 @@
IEnumerable treeNodeInfos = Enumerable.Empty();
- using (var controller = new ProjectExplorerViewController(viewCommands, applicationSelection, viewController, treeNodeInfos))
+ using (var controller = new ProjectExplorerViewController(viewCommands, viewController, treeNodeInfos))
{
// Call
controller.Update(projectStub);
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/HydraulicBoundaryLocationsView.cs
===================================================================
diff -u -r2973c5f790a5131e427bd5f73e2a620044199639 -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/HydraulicBoundaryLocationsView.cs (.../HydraulicBoundaryLocationsView.cs) (revision 2973c5f790a5131e427bd5f73e2a620044199639)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/HydraulicBoundaryLocationsView.cs (.../HydraulicBoundaryLocationsView.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -24,7 +24,6 @@
using System.Linq;
using System.Windows.Forms;
using Core.Common.Controls.Views;
-using Core.Common.Gui.Selection;
using Core.Common.Utils.Extensions;
using Core.Common.Utils.Reflection;
using Ringtoets.Common.Data.AssessmentSection;
@@ -44,6 +43,8 @@
private bool updatingDataSource;
private IEnumerable locations;
+ public event EventHandler SelectionChanged;
+
///
/// Creates a new instance of .
///
@@ -55,11 +56,6 @@
}
///
- /// Gets or sets the .
- ///
- public IApplicationSelection ApplicationSelection { get; set; }
-
- ///
/// Gets or sets the .
///
public IHydraulicBoundaryLocationCalculationGuiService CalculationGuiService { get; set; }
@@ -201,22 +197,15 @@
return;
}
- UpdateApplicationSelection();
+ OnSelectionChanged();
}
- private void UpdateApplicationSelection()
+ private void OnSelectionChanged()
{
- if (ApplicationSelection == null)
+ if (SelectionChanged != null)
{
- return;
+ SelectionChanged(this, new EventArgs());
}
-
- object selection = CreateSelectedItemFromCurrentRow();
- if ((ApplicationSelection.Selection == null && selection != null) ||
- (ApplicationSelection.Selection != null && !ReferenceEquals(selection, ApplicationSelection.Selection)))
- {
- ApplicationSelection.Selection = selection;
- }
}
private IEnumerable GetSelectedHydraulicBoundaryLocationContext()
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/HydraulicBoundaryLocationsViewTest.cs
===================================================================
diff -u -r2973c5f790a5131e427bd5f73e2a620044199639 -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/HydraulicBoundaryLocationsViewTest.cs (.../HydraulicBoundaryLocationsViewTest.cs) (revision 2973c5f790a5131e427bd5f73e2a620044199639)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/HydraulicBoundaryLocationsViewTest.cs (.../HydraulicBoundaryLocationsViewTest.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -27,7 +27,6 @@
using Core.Common.Base.Data;
using Core.Common.Base.Geometry;
using Core.Common.Controls.Views;
-using Core.Common.Gui.Selection;
using NUnit.Extensions.Forms;
using NUnit.Framework;
using Rhino.Mocks;
@@ -182,54 +181,27 @@
}
[Test]
- public void HydraulicBoundaryLocationsView_SelectingCellInRow_ApplicationSelectionCorrectlySynced()
+ public void HydraulicBoundaryLocationsView_SelectingCellInRow_SelectionChangedFired()
{
// Setup
var view = ShowFullyConfiguredTestHydraulicBoundaryLocationsView();
var createdSelection = new object();
view.CreateForSelection = createdSelection;
- var mocks = new MockRepository();
- var applicationSelectionMock = mocks.StrictMock();
- applicationSelectionMock.Stub(asm => asm.Selection).Return(null);
- applicationSelectionMock.Expect(asm => asm.Selection = createdSelection);
- mocks.ReplayAll();
+ var selectionChangedCount = 0;
+ view.SelectionChanged += (sender, args) => selectionChangedCount++;
- view.ApplicationSelection = applicationSelectionMock;
-
var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
// Call
dataGridView.CurrentCell = dataGridView.Rows[1].Cells[locationCalculateColumnIndex];
EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(0, 0));
// Assert
- mocks.VerifyAll();
+ Assert.AreEqual(1, selectionChangedCount);
}
[Test]
- public void HydraulicBoundaryLocationsView_SelectingCellInAlreadySelectedRow_ApplicationSelectionNotSyncedRedundantly()
- {
- // Setup
- var view = ShowFullyConfiguredTestHydraulicBoundaryLocationsView();
- var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
-
- var mocks = new MockRepository();
- var applicationSelectionMock = mocks.StrictMock();
- applicationSelectionMock.Stub(asm => asm.Selection).Return(view.Selection);
- mocks.ReplayAll();
-
- view.ApplicationSelection = applicationSelectionMock;
-
- // Call
- dataGridView.CurrentCell = dataGridView.Rows[1].Cells[locationCalculateColumnIndex];
- EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(locationCalculateColumnIndex, 0));
-
- // Assert
- mocks.VerifyAll();
- }
-
- [Test]
public void Selection_Always_ReturnsCreatedSelectionObject()
{
// Setup
@@ -378,7 +350,7 @@
{
var view = ShowTestHydraulicBoundaryLocationsView();
- var assessmentSection = new TestAssessmentSection()
+ var assessmentSection = new TestAssessmentSection
{
HydraulicBoundaryDatabase = new TestHydraulicBoundaryDatabase()
};
@@ -390,11 +362,17 @@
private class TestAssessmentSection : Observable, IAssessmentSection
{
public string Comments { get; set; }
+
public string Id { get; set; }
+
public string Name { get; set; }
+
public AssessmentSectionComposition Composition { get; private set; }
+
public ReferenceLine ReferenceLine { get; set; }
+
public FailureMechanismContribution FailureMechanismContribution { get; private set; }
+
public HydraulicBoundaryDatabase HydraulicBoundaryDatabase { get; set; }
public IEnumerable GetFailureMechanisms()
@@ -440,6 +418,7 @@
public override IAssessmentSection AssessmentSection { get; set; }
public IEnumerable LocationsToCalculate { get; private set; }
+
public object CreateForSelection { get; set; }
protected override TestHydraulicBoundaryLocationRow CreateNewRow(HydraulicBoundaryLocation location)
Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs
===================================================================
diff -u -rf718135c08ce7b90cc0eaf40bfb83c9af48a1776 -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision f718135c08ce7b90cc0eaf40bfb83c9af48a1776)
+++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -126,7 +126,6 @@
{
view.AssessmentSection = context.AssessmentSection;
view.FailureMechanism = context.FailureMechanism;
- view.ApplicationSelection = Gui;
view.CalculationGuiService = hydraulicBoundaryLocationCalculationGuiService;
},
CloseForData = CloseDesignWaterLevelLocationsViewForData
@@ -145,7 +144,6 @@
{
view.AssessmentSection = context.AssessmentSection;
view.FailureMechanism = context.FailureMechanism;
- view.ApplicationSelection = Gui;
view.CalculationGuiService = hydraulicBoundaryLocationCalculationGuiService;
}
};
Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsDesignWaterLevelLocationsViewInfoTest.cs
===================================================================
diff -u -r2973c5f790a5131e427bd5f73e2a620044199639 -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsDesignWaterLevelLocationsViewInfoTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsViewInfoTest.cs) (revision 2973c5f790a5131e427bd5f73e2a620044199639)
+++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsDesignWaterLevelLocationsViewInfoTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsViewInfoTest.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -119,7 +119,6 @@
// Assert
Assert.AreSame(assessmentSectionStub, view.AssessmentSection);
- Assert.AreSame(guiStub, view.ApplicationSelection);
Assert.AreSame(grassCoverErosionOutwardsFailureMechanism, view.FailureMechanism);
Assert.IsInstanceOf(view.CalculationGuiService);
}
Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsWaveHeightLocationsViewInfoTest.cs
===================================================================
diff -u -r2973c5f790a5131e427bd5f73e2a620044199639 -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsWaveHeightLocationsViewInfoTest.cs (.../GrassCoverErosionOutwardsWaveHeightLocationsViewInfoTest.cs) (revision 2973c5f790a5131e427bd5f73e2a620044199639)
+++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsWaveHeightLocationsViewInfoTest.cs (.../GrassCoverErosionOutwardsWaveHeightLocationsViewInfoTest.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -115,7 +115,6 @@
// Assert
Assert.AreSame(assessmentSectionStub, view.AssessmentSection);
- Assert.AreSame(guiStub, view.ApplicationSelection);
Assert.AreSame(failureMechanism, view.FailureMechanism);
Assert.IsInstanceOf(view.CalculationGuiService);
}
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs
===================================================================
diff -u -r98f01944e8ac182e2a1e9b1ed4deb48a07952529 -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 98f01944e8ac182e2a1e9b1ed4deb48a07952529)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -323,7 +323,6 @@
AfterCreate = (view, context) =>
{
view.AssessmentSection = context.WrappedData;
- view.ApplicationSelection = Gui;
view.CalculationGuiService = hydraulicBoundaryLocationCalculationGuiService;
}
};
@@ -344,7 +343,6 @@
AfterCreate = (view, context) =>
{
view.AssessmentSection = context.WrappedData;
- view.ApplicationSelection = Gui;
view.CalculationGuiService = hydraulicBoundaryLocationCalculationGuiService;
}
};
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelLocationsViewInfoTest.cs
===================================================================
diff -u -rd7e204007a0a9e73fdfec7e570a397d4c41a463b -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelLocationsViewInfoTest.cs (.../DesignWaterLevelLocationsViewInfoTest.cs) (revision d7e204007a0a9e73fdfec7e570a397d4c41a463b)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelLocationsViewInfoTest.cs (.../DesignWaterLevelLocationsViewInfoTest.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -152,7 +152,6 @@
// Assert
Assert.IsInstanceOf(view.CalculationGuiService);
- Assert.AreSame(view.ApplicationSelection, guiStub);
}
mocks.VerifyAll();
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightLocationsViewInfoTest.cs
===================================================================
diff -u -rd7e204007a0a9e73fdfec7e570a397d4c41a463b -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightLocationsViewInfoTest.cs (.../WaveHeightLocationsViewInfoTest.cs) (revision d7e204007a0a9e73fdfec7e570a397d4c41a463b)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightLocationsViewInfoTest.cs (.../WaveHeightLocationsViewInfoTest.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -153,7 +153,6 @@
// Assert
Assert.IsInstanceOf(view.CalculationGuiService);
- Assert.AreSame(view.ApplicationSelection, guiStub);
}
mocks.VerifyAll();
}
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationsView.cs
===================================================================
diff -u -r7ae9100ff4e61169edcefaeb01b72d492431742f -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationsView.cs (.../PipingCalculationsView.cs) (revision 7ae9100ff4e61169edcefaeb01b72d492431742f)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationsView.cs (.../PipingCalculationsView.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -27,7 +27,6 @@
using Core.Common.Base.Geometry;
using Core.Common.Controls.DataGrid;
using Core.Common.Controls.Views;
-using Core.Common.Gui.Selection;
using Core.Common.Utils.Reflection;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.Calculation;
@@ -62,6 +61,8 @@
private bool updatingDataSource;
+ public event EventHandler SelectionChanged;
+
///
/// Creates a new instance of the class.
///
@@ -121,11 +122,6 @@
}
}
- ///
- /// Gets or sets the .
- ///
- public IApplicationSelection ApplicationSelection { get; set; }
-
public object Data
{
get
@@ -497,12 +493,13 @@
return;
}
- UpdateApplicationSelection();
+ OnSelectionChanged();
}
private void ListBoxOnSelectedValueChanged(object sender, EventArgs e)
{
UpdateDataGridViewDataSource();
+ OnSelectionChanged();
}
private void OnGenerateScenariosButtonClick(object sender, EventArgs e)
@@ -549,19 +546,12 @@
}
}
- private void UpdateApplicationSelection()
+ private void OnSelectionChanged()
{
- if (ApplicationSelection == null)
+ if (SelectionChanged != null)
{
- return;
+ SelectionChanged(this, new EventArgs());
}
-
- PipingInputContext selection = CreateSelectedItemFromCurrentRow();
- if ((ApplicationSelection.Selection == null && selection != null) ||
- (ApplicationSelection.Selection != null && !ApplicationSelection.Selection.Equals(selection)))
- {
- ApplicationSelection.Selection = selection;
- }
}
private PipingInputContext CreateSelectedItemFromCurrentRow()
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs
===================================================================
diff -u -r2aeb951ddc6e2137897569a2de4c55c9fb7e2420 -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 2aeb951ddc6e2137897569a2de4c55c9fb7e2420)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -135,7 +135,6 @@
CloseForData = ClosePipingCalculationsViewForData,
AfterCreate = (view, context) =>
{
- view.ApplicationSelection = Gui;
view.AssessmentSection = context.AssessmentSection;
view.PipingFailureMechanism = context.FailureMechanism;
}
@@ -211,7 +210,7 @@
.AddSeparator()
.AddExpandAllItem()
.AddCollapseAllItem()
- .Build(),
+ .Build()
};
yield return new TreeNodeInfo
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs
===================================================================
diff -u -r2973c5f790a5131e427bd5f73e2a620044199639 -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs (.../PipingCalculationsViewTest.cs) (revision 2973c5f790a5131e427bd5f73e2a620044199639)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs (.../PipingCalculationsViewTest.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -28,7 +28,6 @@
using Core.Common.Base.Geometry;
using Core.Common.Controls.DataGrid;
using Core.Common.Controls.Views;
-using Core.Common.Gui.Selection;
using NUnit.Extensions.Forms;
using NUnit.Framework;
using Rhino.Mocks;
@@ -87,7 +86,6 @@
Assert.IsNull(pipingCalculationsView.Data);
Assert.IsNull(pipingCalculationsView.PipingFailureMechanism);
Assert.IsNull(pipingCalculationsView.AssessmentSection);
- Assert.IsNull(pipingCalculationsView.ApplicationSelection);
}
}
@@ -333,28 +331,19 @@
}
[Test]
- public void PipingCalculationsView_SelectingCellInRow_ApplicationSelectionCorrectlySynced()
+ public void PipingCalculationsView_SelectingCellInRow_SelectionChangedFired()
{
// Setup
MockRepository mocks = new MockRepository();
var assessmentSection = mocks.Stub();
var hydraulicBoundaryDatabase = mocks.StrictMock();
var pipingCalculationsView = ShowFullyConfiguredPipingCalculationsView(assessmentSection, hydraulicBoundaryDatabase);
- var secondPipingCalculationItem = ((PipingCalculationScenario) ((CalculationGroup) pipingCalculationsView.Data).Children[1]);
- var secondPipingInputItem = secondPipingCalculationItem.InputParameters;
- var applicationSelectionMock = mocks.StrictMock();
- applicationSelectionMock.Stub(asm => asm.Selection).Return(null);
- applicationSelectionMock.Expect(asm => asm.Selection = new PipingInputContext(secondPipingInputItem,
- secondPipingCalculationItem,
- pipingCalculationsView.PipingFailureMechanism.SurfaceLines,
- pipingCalculationsView.PipingFailureMechanism.StochasticSoilModels,
- pipingCalculationsView.PipingFailureMechanism,
- pipingCalculationsView.AssessmentSection));
mocks.ReplayAll();
- pipingCalculationsView.ApplicationSelection = applicationSelectionMock;
+ var selectionChangedCount = 0;
+ pipingCalculationsView.SelectionChanged += (sender, args) => selectionChangedCount++;
var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
@@ -363,75 +352,40 @@
EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(1, 0));
// Assert
+ Assert.AreEqual(1, selectionChangedCount);
mocks.VerifyAll();
}
[Test]
- public void PipingCalculationsView_SelectingCellInAlreadySelectedRow_ApplicationSelectionNotSyncedRedundantly()
+ public void PipingCalculationsView_ChangingListBoxSelection_DataGridViewCorrectlySyncedAndSelectionChangedFired()
{
// Setup
var mocks = new MockRepository();
- var applicationSelectionMock = mocks.StrictMock();
var assessmentSection = mocks.Stub();
var hydraulicBoundaryDatabase = mocks.StrictMock();
var pipingCalculationsView = ShowFullyConfiguredPipingCalculationsView(assessmentSection, hydraulicBoundaryDatabase);
- var secondPipingCalculationItem = ((PipingCalculationScenario) ((CalculationGroup) pipingCalculationsView.Data).Children[1]);
- var secondPipingInputItem = secondPipingCalculationItem.InputParameters;
- applicationSelectionMock.Stub(asm => asm.Selection)
- .Return(new PipingInputContext(secondPipingInputItem,
- secondPipingCalculationItem,
- pipingCalculationsView.PipingFailureMechanism.SurfaceLines,
- pipingCalculationsView.PipingFailureMechanism.StochasticSoilModels,
- pipingCalculationsView.PipingFailureMechanism,
- pipingCalculationsView.AssessmentSection));
-
mocks.ReplayAll();
- pipingCalculationsView.ApplicationSelection = applicationSelectionMock;
+ var selectionChangedCount = 0;
+ pipingCalculationsView.SelectionChanged += (sender, args) => selectionChangedCount++;
- var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
-
- // Call
- dataGridView.CurrentCell = dataGridView.Rows[1].Cells[0];
- EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(1, 0));
-
- // Assert
- mocks.VerifyAll();
- }
-
- [Test]
- public void PipingCalculationsView_ChangingListBoxSelection_DataGridViewCorrectlySyncedAndApplicationSelectionUpdated()
- {
- // Setup
- var mocks = new MockRepository();
- var assessmentSection = mocks.Stub();
- var hydraulicBoundaryDatabase = mocks.StrictMock();
-
- var pipingCalculationsView = ShowFullyConfiguredPipingCalculationsView(assessmentSection, hydraulicBoundaryDatabase);
- var applicationSelectionMock = mocks.StrictMock();
- applicationSelectionMock.Expect(asm => asm.Selection).Return(null);
-
- mocks.ReplayAll();
-
- pipingCalculationsView.ApplicationSelection = applicationSelectionMock;
-
var listBox = (ListBox) new ControlTester("listBox").TheObject;
var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
// Precondition
Assert.AreEqual(2, dataGridView.Rows.Count);
Assert.AreEqual("Calculation 1", dataGridView.Rows[0].Cells[nameColumnIndex].FormattedValue);
Assert.AreEqual("Calculation 2", dataGridView.Rows[1].Cells[nameColumnIndex].FormattedValue);
- Assert.IsNull(pipingCalculationsView.ApplicationSelection.Selection);
// Call
listBox.SelectedIndex = 1;
// Assert
Assert.AreEqual(1, dataGridView.Rows.Count);
Assert.AreEqual("Calculation 2", dataGridView.Rows[0].Cells[nameColumnIndex].FormattedValue);
+ Assert.AreEqual(1, selectionChangedCount);
mocks.VerifyAll();
}
@@ -530,7 +484,7 @@
SurfaceLines =
{
new RingtoetsPipingSurfaceLine()
- },
+ }
};
var button = (Button) new ButtonTester("buttonGenerateScenarios", testForm).TheObject;
@@ -1263,7 +1217,7 @@
Geometry =
{
new Point2D(0.0, 0.0), new Point2D(5.0, 0.0)
- },
+ }
}
}
};
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ViewInfos/PipingCalculationsViewInfoTest.cs
===================================================================
diff -u -r24da3aa72ccc0776599628c9f971081694048d9a -r650277f75faab8d29b4a07b738f0fd2a99ac7ed3
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ViewInfos/PipingCalculationsViewInfoTest.cs (.../PipingCalculationsViewInfoTest.cs) (revision 24da3aa72ccc0776599628c9f971081694048d9a)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ViewInfos/PipingCalculationsViewInfoTest.cs (.../PipingCalculationsViewInfoTest.cs) (revision 650277f75faab8d29b4a07b738f0fd2a99ac7ed3)
@@ -275,7 +275,6 @@
viewMock.Expect(v => v.AssessmentSection = assessmentSectionMock);
viewMock.Expect(v => v.PipingFailureMechanism = pipingFailureMechanismMock);
- viewMock.Expect(v => v.ApplicationSelection = plugin.Gui);
mocks.ReplayAll();