Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj =================================================================== diff -u -r3580e5dc953b53657221e6786845377eddb8868b -r88b44f34ed4dd17abbc44d54932215754cfd0601 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 3580e5dc953b53657221e6786845377eddb8868b) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 88b44f34ed4dd17abbc44d54932215754cfd0601) @@ -91,14 +91,14 @@ FailureMechanismContributionView.cs - + UserControl DesignWaterLevelLocationsView.cs - + UserControl @@ -154,7 +154,7 @@ UserControl - + UserControl Fisheye: Tag 88b44f34ed4dd17abbc44d54932215754cfd0601 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationContextRow.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationRow.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationRow.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationRow.cs (revision 88b44f34ed4dd17abbc44d54932215754cfd0601) @@ -0,0 +1,56 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.ComponentModel; +using Core.Common.Base.Data; +using Ringtoets.Common.Forms.TypeConverters; +using Ringtoets.HydraRing.Data; +using Ringtoets.Integration.Forms.PresentationObjects; + +namespace Ringtoets.Integration.Forms.Views +{ + /// + /// This class represents a row of of which the design water + /// level is presented. + /// + public class DesignWaterLevelLocationRow : HydraulicBoundaryLocationRow + { + /// + /// Creates a new instance of . + /// + /// The for this row. + /// Thrown when is null. + public DesignWaterLevelLocationRow(HydraulicBoundaryLocation hydraulicBoundaryLocation) : base(hydraulicBoundaryLocation) { } + + /// + /// Gets the . + /// + [TypeConverter(typeof(NoValueRoundedDoubleConverter))] + public RoundedDouble DesignWaterLevel + { + get + { + return HydraulicBoundaryLocation.DesignWaterLevel; + } + } + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.cs =================================================================== diff -u -r5964d4196c1f7f02df79e98ef4f876a338abef62 -r88b44f34ed4dd17abbc44d54932215754cfd0601 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.cs (.../DesignWaterLevelLocationsView.cs) (revision 5964d4196c1f7f02df79e98ef4f876a338abef62) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.cs (.../DesignWaterLevelLocationsView.cs) (revision 88b44f34ed4dd17abbc44d54932215754cfd0601) @@ -20,8 +20,9 @@ // All rights reserved. using System.Collections.Generic; -using System.Linq; +using Core.Common.Base; using Core.Common.Utils.Reflection; +using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.HydraRing.Data; using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Forms.Properties; @@ -32,25 +33,50 @@ /// /// View for the with . /// - public partial class DesignWaterLevelLocationsView : HydraulicBoundaryLocationsView + public partial class DesignWaterLevelLocationsView : HydraulicBoundaryLocationsView { + private readonly Observer assessmentSectionObserver; + private readonly Observer hydraulicBoundaryDatabaseObserver; + private IAssessmentSection assessmentSection; + /// /// Creates a new instance of . /// public DesignWaterLevelLocationsView() { InitializeComponent(); + + assessmentSectionObserver = new Observer(UpdateHydraulicBoundaryDatabase); + hydraulicBoundaryDatabaseObserver = new Observer(() => dataGridViewControl.RefreshDataGridView()); } - protected override void SetDataSource() + public IAssessmentSection AssessmentSection { - dataGridViewControl.SetDataSource(AssessmentSection != null && AssessmentSection.HydraulicBoundaryDatabase != null - ? AssessmentSection.HydraulicBoundaryDatabase.Locations.Select( - hl => new DesignWaterLevelLocationContextRow( - new DesignWaterLevelLocationContext(AssessmentSection.HydraulicBoundaryDatabase, hl))).ToArray() - : null); + get + { + return assessmentSection; + } + set + { + assessmentSection = value; + + if (assessmentSection != null) + { + assessmentSectionObserver.Observable = assessmentSection; + hydraulicBoundaryDatabaseObserver.Observable = assessmentSection.HydraulicBoundaryDatabase; + } + } } + protected override object CreateSelectedItemFromCurrentRow() + { + var currentRow = dataGridViewControl.CurrentRow; + + return currentRow != null ? + new DesignWaterLevelLocationContext(AssessmentSection.HydraulicBoundaryDatabase, ((HydraulicBoundaryLocationRow) currentRow.DataBoundItem).HydraulicBoundaryLocation) : + null; + } + protected override void HandleCalculateSelectedLocations(IEnumerable locations) { if (AssessmentSection == null || AssessmentSection.HydraulicBoundaryDatabase == null) @@ -63,15 +89,44 @@ AssessmentSection.FailureMechanismContribution.Norm, new DesignWaterLevelCalculationMessageProvider()); if (successfulCalculation) { - AssessmentSection.HydraulicBoundaryDatabase.NotifyObservers(); + AssessmentSection.HydraulicBoundaryDatabase.NotifyObservers(); } } + protected override DesignWaterLevelLocationRow CreateNewRow(HydraulicBoundaryLocation location) + { + return new DesignWaterLevelLocationRow(location); + } + protected override void InitializeDataGridView() { base.InitializeDataGridView(); - dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.DesignWaterLevel), + dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.DesignWaterLevel), Resources.HydraulicBoundaryDatabase_Location_DesignWaterLevel_DisplayName); } + + protected override void Dispose(bool disposing) + { + assessmentSectionObserver.Dispose(); + hydraulicBoundaryDatabaseObserver.Dispose(); + + base.Dispose(disposing); + } + + private void UpdateHydraulicBoundaryDatabase() + { + if (AssessmentSection == null || AssessmentSection.HydraulicBoundaryDatabase == null) + { + hydraulicBoundaryDatabaseObserver.Observable = null; + Data = null; + } + else + { + var hydraulicBoundaryDatabase = AssessmentSection.HydraulicBoundaryDatabase; + hydraulicBoundaryDatabaseObserver.Observable = hydraulicBoundaryDatabase; + Data = hydraulicBoundaryDatabase.Locations; + } + UpdateDataGridViewDataSource(); + } } } \ No newline at end of file Fisheye: Tag 88b44f34ed4dd17abbc44d54932215754cfd0601 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationContextRow.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationRow.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationRow.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationRow.cs (revision 88b44f34ed4dd17abbc44d54932215754cfd0601) @@ -0,0 +1,89 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.Base.Geometry; +using Ringtoets.HydraRing.Data; +using Ringtoets.Integration.Forms.PresentationObjects; + +namespace Ringtoets.Integration.Forms.Views +{ + /// + /// This class represents a row of . + /// + public abstract class HydraulicBoundaryLocationRow + { + /// + /// Creates a new instance of . + /// + /// The for this row. + /// Thrown when is null. + protected HydraulicBoundaryLocationRow(HydraulicBoundaryLocation hydraulicBoundaryLocation) + { + if (hydraulicBoundaryLocation == null) + { + throw new ArgumentNullException("hydraulicBoundaryLocation"); + } + + HydraulicBoundaryLocation = hydraulicBoundaryLocation; + } + + public HydraulicBoundaryLocation HydraulicBoundaryLocation { get; private set; } + + /// + /// Gets or sets whether the is set to be calculated. + /// + public bool ToCalculate { get; set; } + + /// + /// Gets the . + /// + public string Name + { + get + { + return HydraulicBoundaryLocation.Name; + } + } + + /// + /// Gets the . + /// + public long Id + { + get + { + return HydraulicBoundaryLocation.Id; + } + } + + /// + /// Gets the . + /// + public Point2D Location + { + get + { + return HydraulicBoundaryLocation.Location; + } + } + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationsView.Designer.cs =================================================================== diff -u -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a -r88b44f34ed4dd17abbc44d54932215754cfd0601 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationsView.Designer.cs (.../HydraulicBoundaryLocationsView.Designer.cs) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationsView.Designer.cs (.../HydraulicBoundaryLocationsView.Designer.cs) (revision 88b44f34ed4dd17abbc44d54932215754cfd0601) @@ -21,7 +21,7 @@ namespace Ringtoets.Integration.Forms.Views { - partial class HydraulicBoundaryLocationsView + partial class HydraulicBoundaryLocationsView { /// /// Required designer variable. @@ -36,7 +36,6 @@ /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HydraulicBoundaryLocationsView)); this.dataGridViewControl = new Core.Common.Controls.DataGrid.DataGridViewControl(); this.CalculateForSelectedButton = new System.Windows.Forms.Button(); this.DeselectAllButton = new System.Windows.Forms.Button(); @@ -47,29 +46,43 @@ // // dataGridViewControl // - resources.ApplyResources(this.dataGridViewControl, "dataGridViewControl"); + this.dataGridViewControl.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridViewControl.Location = new System.Drawing.Point(0, 0); this.dataGridViewControl.MultiSelect = true; this.dataGridViewControl.Name = "dataGridViewControl"; + this.dataGridViewControl.Padding = new System.Windows.Forms.Padding(0, 0, 0, 5); this.dataGridViewControl.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.RowHeaderSelect; + this.dataGridViewControl.Size = new System.Drawing.Size(533, 85); + this.dataGridViewControl.TabIndex = 2; // // CalculateForSelectedButton // - resources.ApplyResources(this.CalculateForSelectedButton, "CalculateForSelectedButton"); + this.CalculateForSelectedButton.Enabled = false; + this.CalculateForSelectedButton.Location = new System.Drawing.Point(227, 29); this.CalculateForSelectedButton.Name = "CalculateForSelectedButton"; + this.CalculateForSelectedButton.Size = new System.Drawing.Size(207, 23); + this.CalculateForSelectedButton.TabIndex = 2; + this.CalculateForSelectedButton.Text = "Bereken voor geselecteerde locaties"; this.CalculateForSelectedButton.UseVisualStyleBackColor = true; this.CalculateForSelectedButton.Click += new System.EventHandler(this.CalculateForSelectedButton_Click); // // DeselectAllButton // - resources.ApplyResources(this.DeselectAllButton, "DeselectAllButton"); + this.DeselectAllButton.Location = new System.Drawing.Point(110, 29); this.DeselectAllButton.Name = "DeselectAllButton"; + this.DeselectAllButton.Size = new System.Drawing.Size(111, 23); + this.DeselectAllButton.TabIndex = 1; + this.DeselectAllButton.Text = "Deselecteer alles"; this.DeselectAllButton.UseVisualStyleBackColor = true; this.DeselectAllButton.Click += new System.EventHandler(this.DeselectAllButton_Click); // // SelectAllButton // - resources.ApplyResources(this.SelectAllButton, "SelectAllButton"); + this.SelectAllButton.Location = new System.Drawing.Point(6, 29); this.SelectAllButton.Name = "SelectAllButton"; + this.SelectAllButton.Size = new System.Drawing.Size(98, 23); + this.SelectAllButton.TabIndex = 0; + this.SelectAllButton.Text = "Selecteer alles"; this.SelectAllButton.UseVisualStyleBackColor = true; this.SelectAllButton.Click += new System.EventHandler(this.SelectAllButton_Click); // @@ -78,17 +91,25 @@ this.ButtonGroupBox.Controls.Add(this.CalculateForSelectedButton); this.ButtonGroupBox.Controls.Add(this.DeselectAllButton); this.ButtonGroupBox.Controls.Add(this.SelectAllButton); - resources.ApplyResources(this.ButtonGroupBox, "ButtonGroupBox"); + this.ButtonGroupBox.Dock = System.Windows.Forms.DockStyle.Bottom; + this.ButtonGroupBox.Location = new System.Drawing.Point(0, 85); + this.ButtonGroupBox.MinimumSize = new System.Drawing.Size(445, 61); this.ButtonGroupBox.Name = "ButtonGroupBox"; + this.ButtonGroupBox.Size = new System.Drawing.Size(533, 61); + this.ButtonGroupBox.TabIndex = 3; this.ButtonGroupBox.TabStop = false; + this.ButtonGroupBox.Text = "Berekenen"; // // HydraulicBoundaryLocationsView // - resources.ApplyResources(this, "$this"); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoScroll = true; + this.AutoScrollMinSize = new System.Drawing.Size(516, 85); this.Controls.Add(this.dataGridViewControl); this.Controls.Add(this.ButtonGroupBox); this.Name = "HydraulicBoundaryLocationsView"; + this.Size = new System.Drawing.Size(533, 146); this.ButtonGroupBox.ResumeLayout(false); this.ResumeLayout(false); Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationsView.cs =================================================================== diff -u -r915001caffacbbee15c0e3bf449072245bc5f509 -r88b44f34ed4dd17abbc44d54932215754cfd0601 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationsView.cs (.../HydraulicBoundaryLocationsView.cs) (revision 915001caffacbbee15c0e3bf449072245bc5f509) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationsView.cs (.../HydraulicBoundaryLocationsView.cs) (revision 88b44f34ed4dd17abbc44d54932215754cfd0601) @@ -23,15 +23,12 @@ using System.Collections.Generic; using System.Linq; using System.Windows.Forms; -using Core.Common.Base; 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; using Ringtoets.Common.Forms.GuiServices; using Ringtoets.HydraRing.Data; -using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Forms.Properties; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -40,24 +37,20 @@ /// /// Base view for views which should be derived in order to get a consistent look and feel. /// - public abstract partial class HydraulicBoundaryLocationsView : UserControl, ISelectionProvider + /// The type of the row objects which are shown in the data table. + public abstract partial class HydraulicBoundaryLocationsView : UserControl, ISelectionProvider where T : HydraulicBoundaryLocationRow { private const int locationCalculateColumnIndex = 0; - private readonly Observer assessmentSectionObserver; - private readonly Observer hydraulicBoundaryDatabaseObserver; - protected IAssessmentSection AssessmentSection; private bool updatingDataSource; + private IEnumerable locations; /// - /// Creates a new instance of . + /// Creates a new instance of . /// protected HydraulicBoundaryLocationsView() { InitializeComponent(); InitializeEventHandlers(); - - assessmentSectionObserver = new Observer(UpdateDataGridViewDataSource); - hydraulicBoundaryDatabaseObserver = new Observer(() => dataGridViewControl.RefreshDataGridView()); } /// @@ -74,14 +67,12 @@ { get { - return AssessmentSection; + return locations; } set { - AssessmentSection = value as IAssessmentSection; - + locations = value as IEnumerable; UpdateDataGridViewDataSource(); - assessmentSectionObserver.Observable = AssessmentSection; } } @@ -99,66 +90,81 @@ InitializeDataGridView(); } + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + + base.Dispose(disposing); + } + /// + /// Updates the data source of the data table based on the . + /// + protected void UpdateDataGridViewDataSource() + { + updatingDataSource = true; + SetDataSource(); + updatingDataSource = false; + UpdateCalculateForSelectedButton(); + } + + /// /// Initializes the . /// protected virtual void InitializeDataGridView() { - dataGridViewControl.AddCheckBoxColumn(TypeUtils.GetMemberName(row => row.ToCalculate), + dataGridViewControl.AddCheckBoxColumn(TypeUtils.GetMemberName(row => row.ToCalculate), Resources.HydraulicBoundaryLocationsView_Calculate); - dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Name), + dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Name), RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_Location_Name_DisplayName); - dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Id), + dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Id), RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_Location_Id_DisplayName); - dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Location), + dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Location), RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_Location_Coordinates_DisplayName); } - protected override void Dispose(bool disposing) - { - assessmentSectionObserver.Dispose(); - hydraulicBoundaryDatabaseObserver.Dispose(); + /// + /// Creates a new row that is added to the data table. + /// + /// The location for which to create a new row. + /// The newly created row. + protected abstract T CreateNewRow(HydraulicBoundaryLocation location); - if (disposing && (components != null)) - { - components.Dispose(); - } + /// + /// Creates a new object that is used as the object for from + /// the currently selected row in the data table. + /// + /// The newly created object. + protected abstract object CreateSelectedItemFromCurrentRow(); - base.Dispose(disposing); - } - /// - /// Sets the datasource on the . + /// Handles the calculation of the . /// - protected abstract void SetDataSource(); + /// The enumeration of to use in the calculation. + protected abstract void HandleCalculateSelectedLocations(IEnumerable locations); - private IEnumerable GetHydraulicBoundaryLocationContextRows() + private IEnumerable GetHydraulicBoundaryLocationContextRows() { - return dataGridViewControl.Rows.Cast().Select(row => (HydraulicBoundaryLocationContextRow) row.DataBoundItem); + return dataGridViewControl.Rows.Cast().Select(row => (T) row.DataBoundItem); } - private void SetHydraulicBoundaryDatabaseObserver() + /// + /// Sets the datasource on the . + /// + private void SetDataSource() { - hydraulicBoundaryDatabaseObserver.Observable = AssessmentSection != null ? AssessmentSection.HydraulicBoundaryDatabase : null; + dataGridViewControl.SetDataSource(locations != null ? locations.Select(CreateNewRow).ToArray() + : null); } - private void UpdateDataGridViewDataSource() - { - SetHydraulicBoundaryDatabaseObserver(); - - updatingDataSource = true; - SetDataSource(); - updatingDataSource = false; - UpdateCalculateForSelectedButton(); - } - private void UpdateCalculateForSelectedButton() { CalculateForSelectedButton.Enabled = GetHydraulicBoundaryLocationContextRows().Any(r => r.ToCalculate); } - #region Event handling - private void InitializeEventHandlers() { dataGridViewControl.AddCellClickHandler(DataGridViewOnCellClick); @@ -191,32 +197,21 @@ return; } - HydraulicBoundaryLocationContext selection = CreateSelectedItemFromCurrentRow(); + object selection = CreateSelectedItemFromCurrentRow(); if ((ApplicationSelection.Selection == null && selection != null) || (ApplicationSelection.Selection != null && !ReferenceEquals(selection, ApplicationSelection.Selection))) { ApplicationSelection.Selection = selection; } } - private HydraulicBoundaryLocationContext CreateSelectedItemFromCurrentRow() - { - var currentRow = dataGridViewControl.CurrentRow; - - var locationContextRow = currentRow != null - ? (HydraulicBoundaryLocationContextRow) currentRow.DataBoundItem - : null; - - return locationContextRow != null - ? locationContextRow.HydraulicBoundaryLocationContext - : null; - } - private IEnumerable GetSelectedHydraulicBoundaryLocationContext() { - return GetHydraulicBoundaryLocationContextRows().Where(r => r.ToCalculate).Select(r => r.HydraulicBoundaryLocationContext.HydraulicBoundaryLocation); + return GetHydraulicBoundaryLocationContextRows().Where(r => r.ToCalculate).Select(r => r.HydraulicBoundaryLocation); } + #region Event handling + private void SelectAllButton_Click(object sender, EventArgs e) { GetHydraulicBoundaryLocationContextRows().ForEachElementDo(row => row.ToCalculate = true); @@ -237,16 +232,10 @@ { return; } - var locations = GetSelectedHydraulicBoundaryLocationContext(); - HandleCalculateSelectedLocations(locations); + var selectedLocations = GetSelectedHydraulicBoundaryLocationContext(); + HandleCalculateSelectedLocations(selectedLocations); } - /// - /// Handles the calculation of the . - /// - /// The enumeration of to use in the calculation. - protected abstract void HandleCalculateSelectedLocations(IEnumerable locations); - #endregion } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationsView.resx =================================================================== diff -u -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a -r88b44f34ed4dd17abbc44d54932215754cfd0601 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationsView.resx (.../HydraulicBoundaryLocationsView.resx) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationsView.resx (.../HydraulicBoundaryLocationsView.resx) (revision 88b44f34ed4dd17abbc44d54932215754cfd0601) @@ -117,160 +117,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Fill - - - - 0, 0 - - - 0, 0, 0, 5 - - - 533, 85 - - - - 2 - - - dataGridViewControl - - - Core.Common.Controls.DataGrid.DataGridViewControl, Core.Common.Controls, Version=16.1.1.4918, Culture=neutral, PublicKeyToken=null - - - $this - - - 0 - - - False - - - 227, 29 - - - 207, 23 - - - 2 - - - Bereken voor geselecteerde locaties - - - CalculateForSelectedButton - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - ButtonGroupBox - - - 0 - - - 110, 29 - - - 111, 23 - - - 1 - - - Deselecteer alles - - - DeselectAllButton - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - ButtonGroupBox - - - 1 - - - 6, 29 - - - 98, 23 - - - 0 - - - Selecteer alles - - - SelectAllButton - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - ButtonGroupBox - - - 2 - - - Bottom - - - 0, 85 - - - 445, 61 - - - 533, 61 - - - 3 - - - Berekenen - - - ButtonGroupBox - - - System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 1 - - - True - - - 6, 13 - - - True - - - 516, 85 - - - 533, 146 - - - HydraulicBoundaryLocationsView - - - System.Windows.Forms.UserControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - \ No newline at end of file Fisheye: Tag 88b44f34ed4dd17abbc44d54932215754cfd0601 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightLocationContextRow.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightLocationRow.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightLocationRow.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightLocationRow.cs (revision 88b44f34ed4dd17abbc44d54932215754cfd0601) @@ -0,0 +1,56 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.ComponentModel; +using Core.Common.Base.Data; +using Ringtoets.Common.Forms.TypeConverters; +using Ringtoets.HydraRing.Data; +using Ringtoets.Integration.Forms.PresentationObjects; + +namespace Ringtoets.Integration.Forms.Views +{ + /// + /// This class represents a row of of which the wave height + /// is presented. + /// + public class WaveHeightLocationRow : HydraulicBoundaryLocationRow + { + /// + /// Creates a new instance of . + /// + /// The for this row. + /// Thrown when is null. + public WaveHeightLocationRow(HydraulicBoundaryLocation hydraulicBoundaryLocation) : base(hydraulicBoundaryLocation) { } + + /// + /// Gets the . + /// + [TypeConverter(typeof(NoValueRoundedDoubleConverter))] + public RoundedDouble WaveHeight + { + get + { + return HydraulicBoundaryLocation.WaveHeight; + } + } + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightLocationsView.cs =================================================================== diff -u -r5964d4196c1f7f02df79e98ef4f876a338abef62 -r88b44f34ed4dd17abbc44d54932215754cfd0601 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightLocationsView.cs (.../WaveHeightLocationsView.cs) (revision 5964d4196c1f7f02df79e98ef4f876a338abef62) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightLocationsView.cs (.../WaveHeightLocationsView.cs) (revision 88b44f34ed4dd17abbc44d54932215754cfd0601) @@ -20,8 +20,9 @@ // All rights reserved. using System.Collections.Generic; -using System.Linq; +using Core.Common.Base; using Core.Common.Utils.Reflection; +using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.HydraRing.Data; using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Forms.Properties; @@ -32,48 +33,102 @@ /// /// View for the with . /// - public partial class WaveHeightLocationsView : HydraulicBoundaryLocationsView + public partial class WaveHeightLocationsView : HydraulicBoundaryLocationsView { + private readonly Observer assessmentSectionObserver; + private readonly Observer hydraulicBoundaryDatabaseObserver; + private IAssessmentSection assessmentSection; + /// /// Creates a new instance of . /// public WaveHeightLocationsView() { InitializeComponent(); + + assessmentSectionObserver = new Observer(UpdateHydraulicBoundaryDatabase); + hydraulicBoundaryDatabaseObserver = new Observer(() => dataGridViewControl.RefreshDataGridView()); } - protected override void SetDataSource() + public IAssessmentSection AssessmentSection { - dataGridViewControl.SetDataSource(AssessmentSection != null && AssessmentSection.HydraulicBoundaryDatabase != null - ? AssessmentSection.HydraulicBoundaryDatabase.Locations.Select( - hl => new WaveHeightLocationContextRow( - new WaveHeightLocationContext(AssessmentSection.HydraulicBoundaryDatabase, hl))).ToArray() - : null); + get + { + return assessmentSection; + } + set + { + assessmentSection = value; + + if (assessmentSection != null) + { + assessmentSectionObserver.Observable = assessmentSection; + hydraulicBoundaryDatabaseObserver.Observable = assessmentSection.HydraulicBoundaryDatabase; + } + } } + protected override object CreateSelectedItemFromCurrentRow() + { + var currentRow = dataGridViewControl.CurrentRow; + + return currentRow != null ? + new WaveHeightLocationContext(AssessmentSection.HydraulicBoundaryDatabase, ((HydraulicBoundaryLocationRow) currentRow.DataBoundItem).HydraulicBoundaryLocation) : + null; + } + protected override void HandleCalculateSelectedLocations(IEnumerable locations) { if (AssessmentSection == null || AssessmentSection.HydraulicBoundaryDatabase == null) { return; } - + bool successfulCalculation = CalculationGuiService.CalculateWaveHeights(AssessmentSection.HydraulicBoundaryDatabase.FilePath, - locations, - AssessmentSection.Id, - AssessmentSection.FailureMechanismContribution.Norm, new WaveHeightCalculationMessageProvider()); + locations, + AssessmentSection.Id, + AssessmentSection.FailureMechanismContribution.Norm, new WaveHeightCalculationMessageProvider()); if (successfulCalculation) { AssessmentSection.HydraulicBoundaryDatabase.NotifyObservers(); } } + protected override WaveHeightLocationRow CreateNewRow(HydraulicBoundaryLocation location) + { + return new WaveHeightLocationRow(location); + } + protected override void InitializeDataGridView() { base.InitializeDataGridView(); - dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.WaveHeight), + dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.WaveHeight), Resources.HydraulicBoundaryDatabase_Location_WaveHeight_DisplayName); } + + protected override void Dispose(bool disposing) + { + assessmentSectionObserver.Dispose(); + hydraulicBoundaryDatabaseObserver.Dispose(); + + base.Dispose(disposing); + } + + private void UpdateHydraulicBoundaryDatabase() + { + if (AssessmentSection == null || AssessmentSection.HydraulicBoundaryDatabase == null) + { + hydraulicBoundaryDatabaseObserver.Observable = null; + Data = null; + } + else + { + var hydraulicBoundaryDatabase = AssessmentSection.HydraulicBoundaryDatabase; + hydraulicBoundaryDatabaseObserver.Observable = hydraulicBoundaryDatabase; + Data = hydraulicBoundaryDatabase.Locations; + } + UpdateDataGridViewDataSource(); + } } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs =================================================================== diff -u -r172f313c5afd8dafa9756d9d1600c78ea2e9fcf9 -r88b44f34ed4dd17abbc44d54932215754cfd0601 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 172f313c5afd8dafa9756d9d1600c78ea2e9fcf9) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 88b44f34ed4dd17abbc44d54932215754cfd0601) @@ -301,25 +301,41 @@ } }; - yield return new ViewInfo + yield return new ViewInfo, DesignWaterLevelLocationsView> { GetViewName = (v, o) => RingtoetsFormsResources.DesignWaterLevelLocationsContext_DisplayName, - GetViewData = context => context.WrappedData, + GetViewData = context => + { + if (context.WrappedData.HydraulicBoundaryDatabase == null) + { + return null; + } + return context.WrappedData.HydraulicBoundaryDatabase.Locations; + }, Image = RingtoetsCommonFormsResources.GenericInputOutputIcon, AfterCreate = (view, context) => { + view.AssessmentSection = context.WrappedData; view.ApplicationSelection = Gui; view.CalculationGuiService = hydraulicBoundaryLocationCalculationGuiService; } }; - yield return new ViewInfo + yield return new ViewInfo, WaveHeightLocationsView> { GetViewName = (v, o) => RingtoetsFormsResources.WaveHeightLocationsContext_DisplayName, - GetViewData = context => context.WrappedData, + GetViewData = context => + { + if (context.WrappedData.HydraulicBoundaryDatabase == null) + { + return null; + } + return context.WrappedData.HydraulicBoundaryDatabase.Locations; + }, Image = RingtoetsCommonFormsResources.GenericInputOutputIcon, AfterCreate = (view, context) => { + view.AssessmentSection = context.WrappedData; view.ApplicationSelection = Gui; view.CalculationGuiService = hydraulicBoundaryLocationCalculationGuiService; } Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj =================================================================== diff -u -r172f313c5afd8dafa9756d9d1600c78ea2e9fcf9 -r88b44f34ed4dd17abbc44d54932215754cfd0601 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 172f313c5afd8dafa9756d9d1600c78ea2e9fcf9) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 88b44f34ed4dd17abbc44d54932215754cfd0601) @@ -124,7 +124,7 @@ - + @@ -155,7 +155,7 @@ - + Fisheye: Tag 88b44f34ed4dd17abbc44d54932215754cfd0601 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationContextRowTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationRowTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationRowTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationRowTest.cs (revision 88b44f34ed4dd17abbc44d54932215754cfd0601) @@ -0,0 +1,92 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using Core.Common.Utils.Reflection; +using NUnit.Framework; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.TypeConverters; +using Ringtoets.HydraRing.Data; +using Ringtoets.Integration.Forms.Views; + +namespace Ringtoets.Integration.Forms.Test.Views +{ + [TestFixture] + public class DesignWaterLevelLocationRowTest + { + [Test] + public void Constructor_WithoutDesignWaterLevelLocationContext_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new DesignWaterLevelLocationRow(null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("hydraulicBoundaryLocation", paramName); + } + + [Test] + public void Constructor_WithDesignWaterLevelLocationContext_PropertiesFromHydraulicBoundaryLocation() + { + // Setup + const int id = 1; + const string locationname = "LocationName"; + const double coordinateX = 1.0; + const double coordinateY = 2.0; + RoundedDouble designWaterLevel = (RoundedDouble) 3.0; + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(id, locationname, coordinateX, coordinateY) + { + DesignWaterLevel = designWaterLevel + }; + + // Call + var row = new DesignWaterLevelLocationRow(hydraulicBoundaryLocation); + + // Assert + Assert.IsInstanceOf(row); + Assert.AreEqual(id, row.Id); + Assert.AreEqual(locationname, row.Name); + Assert.AreEqual(designWaterLevel, row.DesignWaterLevel, hydraulicBoundaryLocation.DesignWaterLevel.GetAccuracy()); + var expectedPoint2D = new Point2D(coordinateX, coordinateY); + Assert.AreEqual(expectedPoint2D, row.Location); + Assert.AreSame(hydraulicBoundaryLocation, row.HydraulicBoundaryLocation); + Assert.IsFalse(row.ToCalculate); + Assert.IsTrue(TypeUtils.HasTypeConverter(r => r.DesignWaterLevel)); + } + + [Test] + public void Constructor_Property_SetPropertyAsExpected() + { + // Setup + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "LocationName", 1.0, 2.0); + var row = new DesignWaterLevelLocationRow(hydraulicBoundaryLocation); + + // Call + row.ToCalculate = true; + + // Assert + Assert.IsTrue(row.ToCalculate); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs =================================================================== diff -u -r11f0867b39150ae5fac83dc178a89fee46d27611 -r88b44f34ed4dd17abbc44d54932215754cfd0601 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs (.../DesignWaterLevelLocationsViewTest.cs) (revision 11f0867b39150ae5fac83dc178a89fee46d27611) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs (.../DesignWaterLevelLocationsViewTest.cs) (revision 88b44f34ed4dd17abbc44d54932215754cfd0601) @@ -69,7 +69,7 @@ using (var view = new DesignWaterLevelLocationsView()) { // Assert - Assert.IsInstanceOf(view); + Assert.IsInstanceOf>(view); Assert.IsNull(view.Data); } } @@ -150,7 +150,7 @@ { // Setup DesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView(); - IAssessmentSection assessmentSection = (IAssessmentSection) view.Data; + IAssessmentSection assessmentSection = view.AssessmentSection; HydraulicBoundaryDatabase newHydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(10, "10", 10.0, 10.0) { @@ -163,8 +163,9 @@ var rows = dataGridView.Rows; Assert.AreEqual(3, rows.Count); - // Call assessmentSection.HydraulicBoundaryDatabase = newHydraulicBoundaryDatabase; + + // Call assessmentSection.NotifyObservers(); // Assert @@ -183,7 +184,7 @@ { // Setup DesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView(); - IAssessmentSection assessmentSection = (IAssessmentSection) view.Data; + IAssessmentSection assessmentSection = view.AssessmentSection; // Precondition var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; @@ -211,7 +212,7 @@ { // Setup DesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView(); - IAssessmentSection assessmentSection = (IAssessmentSection) view.Data; + IAssessmentSection assessmentSection = view.AssessmentSection; var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; var rows = dataGridView.Rows; rows[0].Cells[locationCalculateColumnIndex].Value = true; @@ -291,7 +292,8 @@ HydraulicBoundaryDatabase = new TestHydraulicBoundaryDatabase() }; - view.Data = assessmentSection; + view.Data = assessmentSection.HydraulicBoundaryDatabase.Locations; + view.AssessmentSection = assessmentSection; return view; } Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/HydraulicBoundaryLocationContextRowTest.cs =================================================================== diff -u -r6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a -r88b44f34ed4dd17abbc44d54932215754cfd0601 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/HydraulicBoundaryLocationContextRowTest.cs (.../HydraulicBoundaryLocationContextRowTest.cs) (revision 6ecd02f5f7c642d5624f1e52f528c51b1bf5ab3a) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/HydraulicBoundaryLocationContextRowTest.cs (.../HydraulicBoundaryLocationContextRowTest.cs) (revision 88b44f34ed4dd17abbc44d54932215754cfd0601) @@ -35,11 +35,11 @@ public void Constructor_WithoutHydraulicBoundaryLocationContext_ThrowsArgumentNullException() { // Call - TestDelegate test = () => new TestHydraulicBoundaryLocationContextRow(null); + TestDelegate test = () => new TestHydraulicBoundaryLocationRow(null); // Assert var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("hydraulicBoundaryLocationContext", paramName); + Assert.AreEqual("hydraulicBoundaryLocation", paramName); } [Test] @@ -51,20 +51,16 @@ const double coordinateX = 1.0; const double coordinateY = 2.0; var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(id, locationname, coordinateX, coordinateY); - var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); - hydraulicBoundaryDatabase.Locations.Add(hydraulicBoundaryLocation); - var context = new TestHydraulicBoundaryLocationContext(hydraulicBoundaryDatabase, hydraulicBoundaryLocation); - // Call - var row = new TestHydraulicBoundaryLocationContextRow(context); + var row = new TestHydraulicBoundaryLocationRow(hydraulicBoundaryLocation); // Assert Assert.AreEqual(id, row.Id); Assert.AreEqual(locationname, row.Name); var expectedPoint2D = new Point2D(coordinateX, coordinateY); Assert.AreEqual(expectedPoint2D, row.Location); - Assert.AreSame(context, row.HydraulicBoundaryLocationContext); + Assert.AreSame(hydraulicBoundaryLocation, row.HydraulicBoundaryLocation); Assert.IsFalse(row.ToCalculate); } @@ -73,12 +69,8 @@ { // Setup var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "LocationName", 1.0, 2.0); - var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); - hydraulicBoundaryDatabase.Locations.Add(hydraulicBoundaryLocation); + var row = new TestHydraulicBoundaryLocationRow(hydraulicBoundaryLocation); - var context = new TestHydraulicBoundaryLocationContext(hydraulicBoundaryDatabase, hydraulicBoundaryLocation); - var row = new TestHydraulicBoundaryLocationContextRow(context); - // Call row.ToCalculate = true; @@ -92,10 +84,10 @@ : base(wrappedData, hydraulicBoundaryLocation) {} } - private class TestHydraulicBoundaryLocationContextRow : HydraulicBoundaryLocationContextRow + private class TestHydraulicBoundaryLocationRow : HydraulicBoundaryLocationRow { - public TestHydraulicBoundaryLocationContextRow(HydraulicBoundaryLocationContext hydraulicBoundaryLocationContext) - : base(hydraulicBoundaryLocationContext) {} + public TestHydraulicBoundaryLocationRow(HydraulicBoundaryLocation hydraulicBoundaryLocation) + : base(hydraulicBoundaryLocation) {} } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/HydraulicBoundaryLocationsViewTest.cs =================================================================== diff -u -r11f0867b39150ae5fac83dc178a89fee46d27611 -r88b44f34ed4dd17abbc44d54932215754cfd0601 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/HydraulicBoundaryLocationsViewTest.cs (.../HydraulicBoundaryLocationsViewTest.cs) (revision 11f0867b39150ae5fac83dc178a89fee46d27611) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/HydraulicBoundaryLocationsViewTest.cs (.../HydraulicBoundaryLocationsViewTest.cs) (revision 88b44f34ed4dd17abbc44d54932215754cfd0601) @@ -123,13 +123,13 @@ // Setup using (var view = new TestHydraulicBoundaryLocationsView()) { - var assessmentSection = new TestAssessmentSection(); + var hydraulicBoundaryLocations = Enumerable.Empty(); // Call - view.Data = assessmentSection; + view.Data = hydraulicBoundaryLocations; // Assert - Assert.AreSame(assessmentSection, view.Data); + Assert.AreSame(hydraulicBoundaryLocations, view.Data); } } @@ -183,51 +183,17 @@ } [Test] - public void HydraulicBoundaryLocationsView_HydraulicBoundaryDatabaseUpdated_DataGridViewCorrectlyUpdated() - { - // Setup - var view = ShowFullyConfiguredTestHydraulicBoundaryLocationsView(); - IAssessmentSection assessmentSection = (IAssessmentSection) view.Data; - HydraulicBoundaryDatabase newHydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); - var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(10, "10", 10.0, 10.0) - { - DesignWaterLevel = (RoundedDouble) 10.23 - }; - newHydraulicBoundaryDatabase.Locations.Add(hydraulicBoundaryLocation); - - // Precondition - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; - var rows = dataGridView.Rows; - Assert.AreEqual(3, rows.Count); - - // Call - assessmentSection.HydraulicBoundaryDatabase = newHydraulicBoundaryDatabase; - assessmentSection.NotifyObservers(); - - // Assert - Assert.AreEqual(1, rows.Count); - var cells = rows[0].Cells; - Assert.AreEqual(4, cells.Count); - Assert.AreEqual(false, cells[locationCalculateColumnIndex].FormattedValue); - Assert.AreEqual("10", cells[locationNameColumnIndex].FormattedValue); - Assert.AreEqual("10", cells[locationIdColumnIndex].FormattedValue); - Assert.AreEqual(new Point2D(10, 10).ToString(), cells[locationColumnIndex].FormattedValue); - } - - [Test] public void HydraulicBoundaryLocationsView_SelectingCellInRow_ApplicationSelectionCorrectlySynced() { // Setup var view = ShowFullyConfiguredTestHydraulicBoundaryLocationsView(); - IAssessmentSection assessmentSection = (IAssessmentSection) view.Data; - var secondHydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.Skip(1).First(); + 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 = new TestHydraulicBoundaryLocationContext( - assessmentSection.HydraulicBoundaryDatabase, - secondHydraulicBoundaryLocation)); + applicationSelectionMock.Expect(asm => asm.Selection = createdSelection); mocks.ReplayAll(); view.ApplicationSelection = applicationSelectionMock; @@ -247,9 +213,7 @@ { // Setup var view = ShowFullyConfiguredTestHydraulicBoundaryLocationsView(); - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; - dataGridView.CurrentCell = dataGridView.Rows[1].Cells[locationCalculateColumnIndex]; var mocks = new MockRepository(); var applicationSelectionMock = mocks.StrictMock(); @@ -267,23 +231,18 @@ } [Test] - [TestCase(0)] - [TestCase(1)] - [TestCase(2)] - public void Selection_Always_ReturnsTheSelectedRowObject(int selectedRow) + public void Selection_Always_ReturnsCreatedSelectionObject() { // Setup var view = ShowFullyConfiguredTestHydraulicBoundaryLocationsView(); - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; - dataGridView.CurrentCell = dataGridView.Rows[selectedRow].Cells[locationCalculateColumnIndex]; + var createdSelection = new object(); + view.CreateForSelection = createdSelection; // Call var selection = view.Selection; // Assert - Assert.IsInstanceOf(selection); - HydraulicBoundaryDatabase hydraulicBoundaryDatabase = ((IAssessmentSection) view.Data).HydraulicBoundaryDatabase; - Assert.AreSame(hydraulicBoundaryDatabase, ((HydraulicBoundaryLocationContext) selection).WrappedData); + Assert.AreSame(createdSelection, selection); } [Test] @@ -382,7 +341,7 @@ // Assert Assert.AreEqual(1, view.LocationsToCalculate.Count()); - HydraulicBoundaryLocation expectedLocation = ((IAssessmentSection) view.Data).HydraulicBoundaryDatabase.Locations.First(); + HydraulicBoundaryLocation expectedLocation = ((IEnumerable) view.Data).First(); Assert.AreEqual(expectedLocation, view.LocationsToCalculate.First()); mockRepository.VerifyAll(); } @@ -425,7 +384,7 @@ HydraulicBoundaryDatabase = new TestHydraulicBoundaryDatabase() }; - view.Data = assessmentSection; + view.Data = assessmentSection.HydraulicBoundaryDatabase.Locations; return view; } @@ -466,36 +425,32 @@ } } - private class TestHydraulicBoundaryLocationContext : HydraulicBoundaryLocationContext + private class TestHydraulicBoundaryLocationRow : HydraulicBoundaryLocationRow { - public TestHydraulicBoundaryLocationContext(HydraulicBoundaryDatabase wrappedData, HydraulicBoundaryLocation hydraulicBoundaryLocation) - : base(wrappedData, hydraulicBoundaryLocation) {} + public TestHydraulicBoundaryLocationRow(HydraulicBoundaryLocation hydraulicBoundaryLocation) + : base(hydraulicBoundaryLocation) {} } - private class TestHydraulicBoundaryLocationContextRow : HydraulicBoundaryLocationContextRow + private sealed class TestHydraulicBoundaryLocationsView : HydraulicBoundaryLocationsView { - public TestHydraulicBoundaryLocationContextRow(HydraulicBoundaryLocationContext hydraulicBoundaryLocationContext) - : base(hydraulicBoundaryLocationContext) {} - } - - private sealed class TestHydraulicBoundaryLocationsView : HydraulicBoundaryLocationsView - { public TestHydraulicBoundaryLocationsView() { LocationsToCalculate = new List(); } public IEnumerable LocationsToCalculate { get; private set; } + public object CreateForSelection { get; set; } - protected override void SetDataSource() + protected override TestHydraulicBoundaryLocationRow CreateNewRow(HydraulicBoundaryLocation location) { - dataGridViewControl.SetDataSource(AssessmentSection != null && AssessmentSection.HydraulicBoundaryDatabase != null - ? AssessmentSection.HydraulicBoundaryDatabase.Locations.Select( - hl => new TestHydraulicBoundaryLocationContextRow( - new TestHydraulicBoundaryLocationContext(AssessmentSection.HydraulicBoundaryDatabase, hl))).ToArray() - : null); + return new TestHydraulicBoundaryLocationRow(location); } + protected override object CreateSelectedItemFromCurrentRow() + { + return CreateForSelection; + } + protected override void HandleCalculateSelectedLocations(IEnumerable locations) { LocationsToCalculate = locations; Fisheye: Tag 88b44f34ed4dd17abbc44d54932215754cfd0601 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationContextRowTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationRowTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationRowTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationRowTest.cs (revision 88b44f34ed4dd17abbc44d54932215754cfd0601) @@ -0,0 +1,92 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using Core.Common.Utils.Reflection; +using NUnit.Framework; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.TypeConverters; +using Ringtoets.HydraRing.Data; +using Ringtoets.Integration.Forms.Views; + +namespace Ringtoets.Integration.Forms.Test.Views +{ + [TestFixture] + public class WaveHeightLocationRowTest + { + [Test] + public void Constructor_WithoutWaveHeightLocationContext_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new WaveHeightLocationRow(null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("hydraulicBoundaryLocation", paramName); + } + + [Test] + public void Constructor_WithWaveHeightLocationContext_PropertiesFromHydraulicBoundaryLocation() + { + // Setup + const int id = 1; + const string locationname = "LocationName"; + const double coordinateX = 1.0; + const double coordinateY = 2.0; + RoundedDouble waveHeight = (RoundedDouble) 3.0; + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(id, locationname, coordinateX, coordinateY) + { + WaveHeight = waveHeight + }; + + // Call + var row = new WaveHeightLocationRow(hydraulicBoundaryLocation); + + // Assert + Assert.IsInstanceOf(row); + Assert.AreEqual(id, row.Id); + Assert.AreEqual(locationname, row.Name); + Assert.AreEqual(waveHeight, row.WaveHeight, hydraulicBoundaryLocation.WaveHeight.GetAccuracy()); + var expectedPoint2D = new Point2D(coordinateX, coordinateY); + Assert.AreEqual(expectedPoint2D, row.Location); + Assert.AreSame(hydraulicBoundaryLocation, row.HydraulicBoundaryLocation); + Assert.IsFalse(row.ToCalculate); + Assert.IsTrue(TypeUtils.HasTypeConverter(r => r.WaveHeight)); + } + + [Test] + public void Constructor_Property_SetPropertyAsExpected() + { + // Setup + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "LocationName", 1.0, 2.0); + var row = new WaveHeightLocationRow(hydraulicBoundaryLocation); + + // Call + row.ToCalculate = true; + + // Assert + Assert.IsTrue(row.ToCalculate); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs =================================================================== diff -u -r11f0867b39150ae5fac83dc178a89fee46d27611 -r88b44f34ed4dd17abbc44d54932215754cfd0601 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs (.../WaveHeightLocationsViewTest.cs) (revision 11f0867b39150ae5fac83dc178a89fee46d27611) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs (.../WaveHeightLocationsViewTest.cs) (revision 88b44f34ed4dd17abbc44d54932215754cfd0601) @@ -67,7 +67,7 @@ using (var view = new WaveHeightLocationsView()) { // Assert - Assert.IsInstanceOf(view); + Assert.IsInstanceOf>(view); Assert.IsNull(view.Data); } } @@ -144,7 +144,7 @@ { // Setup WaveHeightLocationsView view = ShowFullyConfiguredWaveHeightLocationsView(); - IAssessmentSection assessmentSection = (IAssessmentSection) view.Data; + IAssessmentSection assessmentSection = view.AssessmentSection; HydraulicBoundaryDatabase newHydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(10, "10", 10.0, 10.0) { @@ -177,7 +177,7 @@ { // Setup WaveHeightLocationsView view = ShowFullyConfiguredWaveHeightLocationsView(); - IAssessmentSection assessmentSection = (IAssessmentSection) view.Data; + IAssessmentSection assessmentSection = view.AssessmentSection; // Precondition var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; @@ -205,7 +205,7 @@ { // Setup WaveHeightLocationsView view = ShowFullyConfiguredWaveHeightLocationsView(); - IAssessmentSection assessmentSection = (IAssessmentSection) view.Data; + IAssessmentSection assessmentSection = view.AssessmentSection; var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; var rows = dataGridView.Rows; rows[0].Cells[locationCalculateColumnIndex].Value = true; @@ -278,7 +278,8 @@ HydraulicBoundaryDatabase = new TestHydraulicBoundaryDatabase() }; - view.Data = assessmentSection; + view.Data = assessmentSection.HydraulicBoundaryDatabase.Locations; + view.AssessmentSection = assessmentSection; return view; } Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelLocationsViewInfoTest.cs =================================================================== diff -u -r915001caffacbbee15c0e3bf449072245bc5f509 -r88b44f34ed4dd17abbc44d54932215754cfd0601 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelLocationsViewInfoTest.cs (.../DesignWaterLevelLocationsViewInfoTest.cs) (revision 915001caffacbbee15c0e3bf449072245bc5f509) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelLocationsViewInfoTest.cs (.../DesignWaterLevelLocationsViewInfoTest.cs) (revision 88b44f34ed4dd17abbc44d54932215754cfd0601) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Collections.Generic; using System.Linq; using Core.Common.Gui; using Core.Common.Gui.Commands; @@ -40,14 +41,12 @@ [TestFixture] public class DesignWaterLevelLocationsViewInfoTest { - private MockRepository mocks; private RingtoetsPlugin plugin; private ViewInfo info; [SetUp] public void SetUp() { - mocks = new MockRepository(); plugin = new RingtoetsPlugin(); info = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(DesignWaterLevelLocationsView)); } @@ -62,18 +61,14 @@ public void GetViewName_Always_ReturnsViewName() { // Setup - var assessmentSection = mocks.Stub(); - mocks.ReplayAll(); - using (var view = new DesignWaterLevelLocationsView()) { // Call - var viewName = info.GetViewName(view, assessmentSection); + var viewName = info.GetViewName(view, Enumerable.Empty()); // Assert Assert.AreEqual("Toetspeilen", viewName); } - mocks.VerifyAll(); } [Test] @@ -83,7 +78,7 @@ var viewDataType = info.ViewDataType; // Assert - Assert.AreEqual(typeof(IAssessmentSection), viewDataType); + Assert.AreEqual(typeof(IEnumerable), viewDataType); } [Test] @@ -110,6 +105,7 @@ public void GetViewData_Always_ReturnsHydraulicBoundaryDatabase() { // Setup + var mocks = new MockRepository(); var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); var assessmentSection = mocks.Stub(); assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; @@ -120,7 +116,7 @@ var viewData = info.GetViewData(context); // Assert - Assert.AreSame(assessmentSection, viewData); + Assert.AreSame(hydraulicBoundaryDatabase.Locations, viewData); mocks.VerifyAll(); } @@ -129,6 +125,7 @@ public void AfterCreate_WithGuiSet_SetsSpecificPropertiesToView() { // Setup + var mocks = new MockRepository(); var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); var assessmentSection = mocks.Stub(); assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightLocationsViewInfoTest.cs =================================================================== diff -u -r915001caffacbbee15c0e3bf449072245bc5f509 -r88b44f34ed4dd17abbc44d54932215754cfd0601 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightLocationsViewInfoTest.cs (.../WaveHeightLocationsViewInfoTest.cs) (revision 915001caffacbbee15c0e3bf449072245bc5f509) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightLocationsViewInfoTest.cs (.../WaveHeightLocationsViewInfoTest.cs) (revision 88b44f34ed4dd17abbc44d54932215754cfd0601) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Collections.Generic; using System.Linq; using Core.Common.Gui; using Core.Common.Gui.Commands; @@ -40,14 +41,12 @@ [TestFixture] public class WaveHeightLocationsViewInfoTest { - private MockRepository mocks; private RingtoetsPlugin plugin; private ViewInfo info; [SetUp] public void SetUp() { - mocks = new MockRepository(); plugin = new RingtoetsPlugin(); info = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(WaveHeightLocationsView)); } @@ -62,18 +61,14 @@ public void GetViewName_Always_ReturnsViewName() { // Setup - var assessmentSection = mocks.Stub(); - mocks.ReplayAll(); - using (var view = new WaveHeightLocationsView()) { // Call - var viewName = info.GetViewName(view, assessmentSection); + var viewName = info.GetViewName(view, Enumerable.Empty()); // Assert Assert.AreEqual("Golfhoogtes", viewName); } - mocks.VerifyAll(); } [Test] @@ -83,7 +78,7 @@ var viewDataType = info.ViewDataType; // Assert - Assert.AreEqual(typeof(IAssessmentSection), viewDataType); + Assert.AreEqual(typeof(IEnumerable), viewDataType); } [Test] @@ -110,6 +105,7 @@ public void GetViewData_Always_ReturnsHydraulicBoundaryDatabase() { // Setup + var mocks = new MockRepository(); var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); var assessmentSection = mocks.Stub(); assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; @@ -120,7 +116,7 @@ var viewData = info.GetViewData(context); // Assert - Assert.AreSame(assessmentSection, viewData); + Assert.AreSame(hydraulicBoundaryDatabase.Locations, viewData); mocks.VerifyAll(); } @@ -129,6 +125,7 @@ public void AfterCreate_WithGuiSet_SetsSpecificPropertiesToView() { // Setup + var mocks = new MockRepository(); var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); var assessmentSection = mocks.Stub(); assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase;