Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Properties/Resources.Designer.cs
===================================================================
diff -u -re4313e642aa3af2d1f1ced4c397c421579cfb36d -rd4f6782b27a8e239562812f1482c1e8cb4843e64
--- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision e4313e642aa3af2d1f1ced4c397c421579cfb36d)
+++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision d4f6782b27a8e239562812f1482c1e8cb4843e64)
@@ -289,5 +289,23 @@
return ResourceManager.GetString("WaveConditionsOutput_Columns_DisplayName", resourceCulture);
}
}
+
+ ///
+ /// Looks up a localized string similar to Hydraulische randvoorwaardenlocatie.
+ ///
+ public static string StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog_Location_Name {
+ get {
+ return ResourceManager.GetString("StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog_Location_Name", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Gebruik.
+ ///
+ public static string StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog_Select_Location {
+ get {
+ return ResourceManager.GetString("StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog_Select_Location", resourceCulture);
+ }
+ }
}
}
Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Properties/Resources.resx
===================================================================
diff -u -re4313e642aa3af2d1f1ced4c397c421579cfb36d -rd4f6782b27a8e239562812f1482c1e8cb4843e64
--- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Properties/Resources.resx (.../Resources.resx) (revision e4313e642aa3af2d1f1ced4c397c421579cfb36d)
+++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Properties/Resources.resx (.../Resources.resx) (revision d4f6782b27a8e239562812f1482c1e8cb4843e64)
@@ -184,4 +184,10 @@
Zuilen
+
+ Gebruik
+
+
+ Hydraulische randvoorwaardenlocatie
+
\ No newline at end of file
Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Ringtoets.StabilityStoneCover.Forms.csproj
===================================================================
diff -u -re4313e642aa3af2d1f1ced4c397c421579cfb36d -rd4f6782b27a8e239562812f1482c1e8cb4843e64
--- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Ringtoets.StabilityStoneCover.Forms.csproj (.../Ringtoets.StabilityStoneCover.Forms.csproj) (revision e4313e642aa3af2d1f1ced4c397c421579cfb36d)
+++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Ringtoets.StabilityStoneCover.Forms.csproj (.../Ringtoets.StabilityStoneCover.Forms.csproj) (revision d4f6782b27a8e239562812f1482c1e8cb4843e64)
@@ -34,8 +34,10 @@
+
+
@@ -55,6 +57,12 @@
+
+ Form
+
+
+ StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.cs
+
@@ -130,6 +138,9 @@
Resources.Designer.cs
Designer
+
+ StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.cs
+
Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.Designer.cs
===================================================================
diff -u
--- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.Designer.cs (revision 0)
+++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.Designer.cs (revision d4f6782b27a8e239562812f1482c1e8cb4843e64)
@@ -0,0 +1,148 @@
+// 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.
+
+namespace Ringtoets.StabilityStoneCover.Forms
+{
+ partial class StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog));
+ this.dataGridViewControl = new Core.Common.Controls.DataGrid.DataGridViewControl();
+ this.ButtonGroupBox = new System.Windows.Forms.GroupBox();
+ this.panel2 = new System.Windows.Forms.Panel();
+ this.SelectAllButton = new System.Windows.Forms.Button();
+ this.DeselectAllButton = new System.Windows.Forms.Button();
+ this.GenerateForSelectedButton = new System.Windows.Forms.Button();
+ this.CustomCancelButton = new System.Windows.Forms.Button();
+ this.panel1 = new System.Windows.Forms.Panel();
+ this.ButtonGroupBox.SuspendLayout();
+ this.panel2.SuspendLayout();
+ this.panel1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // dataGridViewControl
+ //
+ resources.ApplyResources(this.dataGridViewControl, "dataGridViewControl");
+ this.dataGridViewControl.MultiSelect = true;
+ this.dataGridViewControl.Name = "dataGridViewControl";
+ this.dataGridViewControl.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.RowHeaderSelect;
+ //
+ // ButtonGroupBox
+ //
+ this.ButtonGroupBox.Controls.Add(this.dataGridViewControl);
+ this.ButtonGroupBox.Controls.Add(this.panel2);
+ resources.ApplyResources(this.ButtonGroupBox, "ButtonGroupBox");
+ this.ButtonGroupBox.Name = "ButtonGroupBox";
+ this.ButtonGroupBox.TabStop = false;
+ //
+ // panel2
+ //
+ this.panel2.Controls.Add(this.SelectAllButton);
+ this.panel2.Controls.Add(this.DeselectAllButton);
+ resources.ApplyResources(this.panel2, "panel2");
+ this.panel2.Name = "panel2";
+ //
+ // SelectAllButton
+ //
+ resources.ApplyResources(this.SelectAllButton, "SelectAllButton");
+ this.SelectAllButton.Name = "SelectAllButton";
+ this.SelectAllButton.UseVisualStyleBackColor = true;
+ this.SelectAllButton.Click += new System.EventHandler(this.SelectAllButton_Click);
+ //
+ // DeselectAllButton
+ //
+ resources.ApplyResources(this.DeselectAllButton, "DeselectAllButton");
+ this.DeselectAllButton.Name = "DeselectAllButton";
+ this.DeselectAllButton.UseVisualStyleBackColor = true;
+ this.DeselectAllButton.Click += new System.EventHandler(this.DeselectAllButton_Click);
+ //
+ // GenerateForSelectedButton
+ //
+ resources.ApplyResources(this.GenerateForSelectedButton, "GenerateForSelectedButton");
+ this.GenerateForSelectedButton.Name = "GenerateForSelectedButton";
+ this.GenerateForSelectedButton.UseVisualStyleBackColor = true;
+ this.GenerateForSelectedButton.Click += new System.EventHandler(this.GenerateForSelectedButton_Click);
+ //
+ // CustomCancelButton
+ //
+ resources.ApplyResources(this.CustomCancelButton, "CustomCancelButton");
+ this.CustomCancelButton.Name = "CustomCancelButton";
+ this.CustomCancelButton.UseVisualStyleBackColor = true;
+ this.CustomCancelButton.Click += new System.EventHandler(this.CancelButton_Click);
+ //
+ // panel1
+ //
+ this.panel1.Controls.Add(this.GenerateForSelectedButton);
+ this.panel1.Controls.Add(this.CustomCancelButton);
+ resources.ApplyResources(this.panel1, "panel1");
+ this.panel1.Name = "panel1";
+ //
+ // StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog
+ //
+ resources.ApplyResources(this, "$this");
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.ButtonGroupBox);
+ this.Controls.Add(this.panel1);
+ this.Name = "StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog";
+ this.ButtonGroupBox.ResumeLayout(false);
+ this.panel2.ResumeLayout(false);
+ this.panel1.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private Core.Common.Controls.DataGrid.DataGridViewControl dataGridViewControl;
+ private System.Windows.Forms.GroupBox ButtonGroupBox;
+ private System.Windows.Forms.Button GenerateForSelectedButton;
+ private System.Windows.Forms.Button DeselectAllButton;
+ private System.Windows.Forms.Button CustomCancelButton;
+ private System.Windows.Forms.Button SelectAllButton;
+ private System.Windows.Forms.Panel panel1;
+ private System.Windows.Forms.Panel panel2;
+ }
+}
\ No newline at end of file
Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.cs
===================================================================
diff -u
--- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.cs (revision 0)
+++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.cs (revision d4f6782b27a8e239562812f1482c1e8cb4843e64)
@@ -0,0 +1,171 @@
+// 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.Collections.Generic;
+using System.Linq;
+using System.Windows.Forms;
+using Core.Common.Controls.Dialogs;
+using Core.Common.Utils.Extensions;
+using Core.Common.Utils.Reflection;
+using Ringtoets.HydraRing.Data;
+using Ringtoets.StabilityStoneCover.Forms.Properties;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.StabilityStoneCover.Forms
+{
+ ///
+ /// A dialog which allows the user to make a selection form a given set of . Upon
+ /// closing of the dialog, the selected can be obtained.
+ ///
+ public partial class StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog : DialogBase
+ {
+ private const int locationCalculateColumnIndex = 0;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The parent of the dialog.
+ /// The collection of to show in the dialog.
+ public StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(IWin32Window dialogParent,
+ IEnumerable hydraulicBoundaryLocations)
+ : base(dialogParent, RingtoetsCommonFormsResources.GenerateScenariosIcon, 370, 550)
+ {
+ if (hydraulicBoundaryLocations == null)
+ {
+ throw new ArgumentNullException("hydraulicBoundaryLocations");
+ }
+
+ InitializeComponent();
+ InitializeEventHandlers();
+ InitializeDataGridView();
+
+ SetDataSource(hydraulicBoundaryLocations);
+ SelectedLocations = new List();
+ }
+
+ ///
+ /// Gets a collection of selected if they were selected
+ /// in the dialog and a confirmation was given. If no confirmation was given or no
+ /// was selected an empty collection is returned.
+ ///
+ public IEnumerable SelectedLocations { get; private set; }
+
+ protected override Button GetCancelButton()
+ {
+ return CustomCancelButton;
+ }
+
+ ///
+ /// Gets the currently selected hydraulic boundary locations from the data grid view.
+ ///
+ /// A of
+ /// which were selected in the view.
+ private IEnumerable GetSelectedLocations()
+ {
+ return GetHydraulicBoundaryLocationContextRows().Where(row => row.Selected).Select(row => row.Location).ToArray();
+ }
+
+ private void SetDataSource(IEnumerable hydraulicBoundaryLocations)
+ {
+ dataGridViewControl.SetDataSource(hydraulicBoundaryLocations.Select(loc => new HydraulicBoundaryLocationContextRow(loc)).ToArray());
+ }
+
+ ///
+ /// Initializes the .
+ ///
+ private void InitializeDataGridView()
+ {
+ dataGridViewControl.AddCheckBoxColumn(TypeUtils.GetMemberName(row => row.Selected),
+ Resources.StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog_Select_Location);
+ dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Name),
+ Resources.StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog_Location_Name,
+ false, DataGridViewAutoSizeColumnMode.Fill);
+ }
+
+ private IEnumerable GetHydraulicBoundaryLocationContextRows()
+ {
+ return dataGridViewControl.Rows.Cast().Select(row => (HydraulicBoundaryLocationContextRow) row.DataBoundItem);
+ }
+
+ private void UpdateGenerateForSelectedButton()
+ {
+ GenerateForSelectedButton.Enabled = GetHydraulicBoundaryLocationContextRows().Any(r => r.Selected);
+ }
+
+ private class HydraulicBoundaryLocationContextRow
+ {
+ public HydraulicBoundaryLocationContextRow(IHydraulicBoundaryLocation location)
+ {
+ Selected = false;
+ Name = location.Name;
+ Location = location;
+ }
+
+ public bool Selected { get; set; }
+ public string Name { get; private set; }
+ public IHydraulicBoundaryLocation Location { get; private set; }
+ }
+
+ #region Event handling
+
+ private void SelectAllButton_Click(object sender, EventArgs e)
+ {
+ GetHydraulicBoundaryLocationContextRows().ForEachElementDo(row => row.Selected = true);
+ dataGridViewControl.RefreshDataGridView();
+ UpdateGenerateForSelectedButton();
+ }
+
+ private void DeselectAllButton_Click(object sender, EventArgs e)
+ {
+ GetHydraulicBoundaryLocationContextRows().ForEachElementDo(row => row.Selected = false);
+ dataGridViewControl.RefreshDataGridView();
+ UpdateGenerateForSelectedButton();
+ }
+
+ private void InitializeEventHandlers()
+ {
+ dataGridViewControl.AddCellValueChangedHandler(DataGridViewCellValueChanged);
+ }
+
+ private void DataGridViewCellValueChanged(object sender, DataGridViewCellEventArgs e)
+ {
+ if (e.ColumnIndex != locationCalculateColumnIndex)
+ {
+ return;
+ }
+ UpdateGenerateForSelectedButton();
+ }
+
+ private void GenerateForSelectedButton_Click(object sender, EventArgs e)
+ {
+ SelectedLocations = GetSelectedLocations();
+ Close();
+ }
+
+ private void CancelButton_Click(object sender, EventArgs e)
+ {
+ Close();
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.resx
===================================================================
diff -u
--- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.resx (revision 0)
+++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog.resx (revision d4f6782b27a8e239562812f1482c1e8cb4843e64)
@@ -0,0 +1,363 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+
+ Fill
+
+
+
+ 3, 16
+
+
+ 0, 0, 0, 5
+
+
+ 261, 66
+
+
+
+ 0
+
+
+ dataGridViewControl
+
+
+ Core.Common.Controls.DataGrid.DataGridViewControl, Core.Common.Controls, Version=16.2.1.5098, Culture=neutral, PublicKeyToken=null
+
+
+ ButtonGroupBox
+
+
+ 0
+
+
+ NoControl
+
+
+ 9, 6
+
+
+ 111, 23
+
+
+ 5
+
+
+ Selecteer alles
+
+
+ SelectAllButton
+
+
+ System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ panel2
+
+
+ 0
+
+
+ NoControl
+
+
+ 126, 6
+
+
+ 111, 23
+
+
+ 4
+
+
+ Deselecteer alles
+
+
+ DeselectAllButton
+
+
+ System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ panel2
+
+
+ 1
+
+
+ Bottom
+
+
+ 3, 82
+
+
+ 261, 39
+
+
+ 6
+
+
+ panel2
+
+
+ System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ ButtonGroupBox
+
+
+ 1
+
+
+ Fill
+
+
+ 0, 0
+
+
+ 267, 124
+
+
+ 1
+
+
+ ButtonGroupBox
+
+
+ System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ $this
+
+
+ 0
+
+
+ Top, Right
+
+
+ False
+
+
+ NoControl
+
+
+ 80, 6
+
+
+ 86, 23
+
+
+ 3
+
+
+ Genereren
+
+
+ GenerateForSelectedButton
+
+
+ System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ panel1
+
+
+ 0
+
+
+ Top, Right
+
+
+ NoControl
+
+
+ 172, 6
+
+
+ 86, 23
+
+
+ 6
+
+
+ Annuleren
+
+
+ CustomCancelButton
+
+
+ System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ panel1
+
+
+ 1
+
+
+ Bottom
+
+
+ 0, 124
+
+
+ 267, 35
+
+
+ 6
+
+
+ panel1
+
+
+ System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ $this
+
+
+ 1
+
+
+ True
+
+
+ 6, 13
+
+
+ True
+
+
+ 240, 90
+
+
+ 267, 159
+
+
+ Selecteer hydraulische randvoorwaardenlocaties
+
+
+ StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog
+
+
+ Core.Common.Controls.Dialogs.DialogBase, Core.Common.Controls, Version=16.2.1.5098, Culture=neutral, PublicKeyToken=null
+
+
\ No newline at end of file
Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/Properties/Resources.Designer.cs
===================================================================
diff -u -r0d98073e4ba2bdc6b69b7f875508488d1fa0148a -rd4f6782b27a8e239562812f1482c1e8cb4843e64
--- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 0d98073e4ba2bdc6b69b7f875508488d1fa0148a)
+++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision d4f6782b27a8e239562812f1482c1e8cb4843e64)
@@ -22,7 +22,7 @@
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
-// Runtime Version:4.0.30319.18444
+// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -82,6 +82,15 @@
}
///
+ /// Looks up a localized string similar to Er is geen hydraulische randvoorwaardendatabase beschikbaar om de randvoorwaardenberekeningen aan te maken..
+ ///
+ internal static string StabilityStoneCover_WaveConditions_No_HRD_To_Calculate {
+ get {
+ return ResourceManager.GetString("StabilityStoneCover_WaveConditions_No_HRD_To_Calculate", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Genereer randvoorwaardenberekeningen..
///
internal static string StabilityStoneCoverPlugin_CreateGenerateHydraulicBoundaryCalculationsItem_ToolTip {
Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/Properties/Resources.resx
===================================================================
diff -u -r0d98073e4ba2bdc6b69b7f875508488d1fa0148a -rd4f6782b27a8e239562812f1482c1e8cb4843e64
--- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 0d98073e4ba2bdc6b69b7f875508488d1fa0148a)
+++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/Properties/Resources.resx (.../Resources.resx) (revision d4f6782b27a8e239562812f1482c1e8cb4843e64)
@@ -120,4 +120,7 @@
Genereer randvoorwaardenberekeningen.
+
+ Er is geen hydraulische randvoorwaardendatabase beschikbaar om de randvoorwaardenberekeningen aan te maken.
+
\ No newline at end of file
Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/Ringtoets.StabilityStoneCover.Plugin.csproj
===================================================================
diff -u -r6b330f8e7c1df6bc70f6de1e4251f69cd6865a81 -rd4f6782b27a8e239562812f1482c1e8cb4843e64
--- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/Ringtoets.StabilityStoneCover.Plugin.csproj (.../Ringtoets.StabilityStoneCover.Plugin.csproj) (revision 6b330f8e7c1df6bc70f6de1e4251f69cd6865a81)
+++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/Ringtoets.StabilityStoneCover.Plugin.csproj (.../Ringtoets.StabilityStoneCover.Plugin.csproj) (revision d4f6782b27a8e239562812f1482c1e8cb4843e64)
@@ -139,6 +139,7 @@
ResXFileCodeGenerator
Resources.Designer.cs
+ Designer
Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs
===================================================================
diff -u -re4313e642aa3af2d1f1ced4c397c421579cfb36d -rd4f6782b27a8e239562812f1482c1e8cb4843e64
--- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs (.../StabilityStoneCoverPlugin.cs) (revision e4313e642aa3af2d1f1ced4c397c421579cfb36d)
+++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs (.../StabilityStoneCoverPlugin.cs) (revision d4f6782b27a8e239562812f1482c1e8cb4843e64)
@@ -39,6 +39,7 @@
using Ringtoets.HydraRing.IO;
using Ringtoets.Revetment.Service;
using Ringtoets.StabilityStoneCover.Data;
+using Ringtoets.StabilityStoneCover.Forms;
using Ringtoets.StabilityStoneCover.Forms.PresentationObjects;
using Ringtoets.StabilityStoneCover.Forms.PropertyClasses;
using Ringtoets.StabilityStoneCover.Forms.Views;
@@ -235,7 +236,7 @@
#endregion
- #region StabilityStoneCoverWaveCibdutuibsCalculationGroupContext
+ #region StabilityStoneCoverWaveConditionsCalculationGroupContext
private object[] WaveConditionsCalculationGroupContextChildNodeObjects(StabilityStoneCoverWaveConditionsCalculationGroupContext nodeData)
{
@@ -350,18 +351,40 @@
private StrictContextMenuItem CreateGenerateWaveConditionsCalculationsItem(StabilityStoneCoverWaveConditionsCalculationGroupContext nodeData)
{
+ HydraulicBoundaryDatabase hydraulicBoundaryDatabase = nodeData.AssessmentSection.HydraulicBoundaryDatabase;
+ bool locationsAvailable = hydraulicBoundaryDatabase != null && hydraulicBoundaryDatabase.Locations.Any();
+
+ string stabilityStoneCoverWaveConditionsCalculationGroupContextToolTip = locationsAvailable
+ ? Resources.StabilityStoneCoverPlugin_CreateGenerateHydraulicBoundaryCalculationsItem_ToolTip
+ : Resources.StabilityStoneCover_WaveConditions_No_HRD_To_Calculate;
+
return new StrictContextMenuItem(RingtoetsCommonFormsResources.CalculationsGroup_Generate_calculations,
- Resources.StabilityStoneCoverPlugin_CreateGenerateHydraulicBoundaryCalculationsItem_ToolTip,
+ stabilityStoneCoverWaveConditionsCalculationGroupContextToolTip,
RingtoetsCommonFormsResources.GenerateScenariosIcon,
- (sender, args) =>
- {
- /* TODO: Implement for WTI-733 */
- })
+ (sender, args) => { ShowStabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(nodeData); })
{
- Enabled = false
+ Enabled = locationsAvailable
};
}
+ private void ShowStabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(StabilityStoneCoverWaveConditionsCalculationGroupContext nodeData)
+ {
+ using (var dialog = new StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(Gui.MainWindow,
+ nodeData.AssessmentSection.HydraulicBoundaryDatabase.Locations))
+ {
+ dialog.ShowDialog();
+ foreach (IHydraulicBoundaryLocation location in dialog.SelectedLocations)
+ {
+ nodeData.WrappedData.Children.Add(new StabilityStoneCoverWaveConditionsCalculation());
+ }
+
+ if (dialog.SelectedLocations.Any())
+ {
+ nodeData.NotifyObservers();
+ }
+ }
+ }
+
private void AddWaveConditionsCalculation(StabilityStoneCoverWaveConditionsCalculationGroupContext nodeData)
{
var calculation = new StabilityStoneCoverWaveConditionsCalculation
@@ -451,7 +474,10 @@
return builder.AddValidateCalculationItem(nodeData,
c => ValidateAll(
- new [] { c.WrappedData },
+ new[]
+ {
+ c.WrappedData
+ },
c.FailureMechanism.GeneralInput,
c.AssessmentSection.FailureMechanismContribution.Norm,
c.AssessmentSection.HydraulicBoundaryDatabase),
Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Ringtoets.StabilityStoneCover.Forms.Test.csproj
===================================================================
diff -u -re4313e642aa3af2d1f1ced4c397c421579cfb36d -rd4f6782b27a8e239562812f1482c1e8cb4843e64
--- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Ringtoets.StabilityStoneCover.Forms.Test.csproj (.../Ringtoets.StabilityStoneCover.Forms.Test.csproj) (revision e4313e642aa3af2d1f1ced4c397c421579cfb36d)
+++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Ringtoets.StabilityStoneCover.Forms.Test.csproj (.../Ringtoets.StabilityStoneCover.Forms.Test.csproj) (revision d4f6782b27a8e239562812f1482c1e8cb4843e64)
@@ -76,6 +76,7 @@
+
Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/StabilityStoneCoverHydraulicBoundaryLocationSelectionDialogTest.cs
===================================================================
diff -u
--- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/StabilityStoneCoverHydraulicBoundaryLocationSelectionDialogTest.cs (revision 0)
+++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/StabilityStoneCoverHydraulicBoundaryLocationSelectionDialogTest.cs (revision d4f6782b27a8e239562812f1482c1e8cb4843e64)
@@ -0,0 +1,332 @@
+// 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.Linq;
+using System.Windows.Forms;
+using Core.Common.Controls.DataGrid;
+using Core.Common.Controls.Dialogs;
+using NUnit.Extensions.Forms;
+using NUnit.Framework;
+using Ringtoets.HydraRing.Data;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.StabilityStoneCover.Forms.Test
+{
+ [TestFixture]
+ public class StabilityStoneCoverHydraulicBoundaryLocationSelectionDialogTest
+ {
+ private const int locationSelectionColumnIndex = 0;
+ private const int locationColumnIndex = 1;
+
+ [Test]
+ public void Constructor_WithoutParent_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => new StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(null, Enumerable.Empty());
+
+ // Assert
+ string parameter = Assert.Throws(test).ParamName;
+ Assert.AreEqual("dialogParent", parameter);
+ }
+
+ [Test]
+ public void Constructor_WithoutHydraulicBoundaryLocations_ThrowsArgumentNullException()
+ {
+ // Setup
+ using (var viewParent = new Form())
+ {
+ // Call
+ TestDelegate test = () => new StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(viewParent, null);
+
+ // Assert
+ string parameter = Assert.Throws(test).ParamName;
+ Assert.AreEqual("hydraulicBoundaryLocations", parameter);
+ }
+ }
+
+ [Test]
+ public void Constructor_WithParentAndLocations_DefaultProperties()
+ {
+ // Setup
+ using (var viewParent = new Form())
+ {
+ // Call
+ using (var dialog = new StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(viewParent, Enumerable.Empty()))
+ {
+ // Assert
+ Assert.IsInstanceOf(dialog);
+ Assert.IsEmpty(dialog.SelectedLocations);
+ Assert.AreEqual("Selecteer hydraulische randvoorwaardenlocaties", dialog.Text);
+
+ var dataGridViewControl = (DataGridViewControl) new ControlTester("dataGridViewControl", dialog).TheObject;
+ var dataGridView = dataGridViewControl.Controls.OfType().First();
+ Assert.AreEqual(2, dataGridView.ColumnCount);
+
+ var locationCalculateColumn = (DataGridViewCheckBoxColumn) dataGridView.Columns[locationSelectionColumnIndex];
+ const string expectedLocationCalculateHeaderText = "Gebruik";
+ Assert.AreEqual(expectedLocationCalculateHeaderText, locationCalculateColumn.HeaderText);
+ Assert.AreEqual("Selected", locationCalculateColumn.DataPropertyName);
+ Assert.IsFalse(locationCalculateColumn.ReadOnly);
+
+ var locationColumn = (DataGridViewTextBoxColumn) dataGridView.Columns[locationColumnIndex];
+ const string expectedLocationHeaderText = "Hydraulische randvoorwaardenlocatie";
+ Assert.AreEqual(expectedLocationHeaderText, locationColumn.HeaderText);
+ Assert.AreEqual("Name", locationColumn.DataPropertyName);
+ Assert.AreEqual(DataGridViewAutoSizeColumnMode.Fill, locationColumn.AutoSizeMode);
+ Assert.IsTrue(locationColumn.ReadOnly);
+
+ var buttonTester = new ButtonTester("GenerateForSelectedButton", dialog);
+ var button = (Button) buttonTester.TheObject;
+ Assert.IsFalse(button.Enabled);
+ }
+ }
+ }
+
+ [Test]
+ public void OnLoad_Always_SetMinimumSize()
+ {
+ // Setup
+ using (var viewParent = new Form())
+ using (var dialog = new StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(viewParent, Enumerable.Empty()))
+ {
+ // Call
+ dialog.Show();
+
+ // Assert
+ Assert.AreEqual(370, dialog.MinimumSize.Width);
+ Assert.AreEqual(550, dialog.MinimumSize.Height);
+ }
+ }
+
+ [Test]
+ public void GivenDialogWithSelectedLocations_WhenCloseWithoutConfirmation_ThenReturnsEmptyCollection()
+ {
+ // Given
+ var locations = new[]
+ {
+ new HydraulicBoundaryLocation(1, "1", 1, 1),
+ new HydraulicBoundaryLocation(2, "2", 2, 2)
+ };
+
+ using (var viewParent = new Form())
+ using (var dialog = new StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(viewParent, locations))
+ {
+ var selectionView = (DataGridViewControl) new ControlTester("dataGridViewControl", dialog).TheObject;
+
+ dialog.Show();
+ selectionView.Rows[0].Cells[0].Value = true;
+
+ // When
+ dialog.Close();
+
+ // Then
+ Assert.IsEmpty(dialog.SelectedLocations);
+ }
+ }
+
+ [Test]
+ public void GivenDialogWithSelectedLocations_WhenCancelButtonClicked_ThenReturnsSelectedCollection()
+ {
+ // Given
+ var selectedLocation = new HydraulicBoundaryLocation(1, "1", 1, 1);
+ var locations = new[]
+ {
+ selectedLocation,
+ new HydraulicBoundaryLocation(2, "2", 2, 2)
+ };
+
+ using (var viewParent = new Form())
+ {
+ using (var dialog = new StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(viewParent, locations))
+ {
+ var selectionView = (DataGridViewControl) new ControlTester("dataGridViewControl", dialog).TheObject;
+
+ dialog.Show();
+ selectionView.Rows[0].Cells[0].Value = true;
+
+ // When
+ var cancelButton = new ButtonTester("CustomCancelButton", dialog);
+ cancelButton.Click();
+
+ // Then
+ Assert.IsEmpty(dialog.SelectedLocations);
+ }
+ }
+ }
+
+ [Test]
+ public void GivenDialogWithSelectedLocations_WhenGenerateButtonClicked_ThenReturnsSelectedCollection()
+ {
+ // Given
+ var selectedLocation = new HydraulicBoundaryLocation(1, "1", 1, 1);
+ var locations = new[]
+ {
+ selectedLocation,
+ new HydraulicBoundaryLocation(2, "2", 2, 2)
+ };
+
+ using (var viewParent = new Form())
+ using (var dialog = new StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(viewParent, locations))
+ {
+ var selectionView = (DataGridViewControl) new ControlTester("dataGridViewControl", dialog).TheObject;
+
+ dialog.Show();
+ selectionView.Rows[0].Cells[0].Value = true;
+
+ // When
+ var generateButton = new ButtonTester("GenerateForSelectedButton", dialog);
+ generateButton.Click();
+
+ // Then
+ var result = dialog.SelectedLocations;
+
+ CollectionAssert.AreEqual(new[]
+ {
+ selectedLocation
+ }, result);
+ }
+ }
+
+ [Test]
+ public void SelectAllButton_SelectAllButtonClicked_AllLocationsSelected()
+ {
+ // Setup
+ var locations = new[]
+ {
+ new HydraulicBoundaryLocation(1, "1", 1, 1),
+ new HydraulicBoundaryLocation(2, "2", 2, 2)
+ };
+
+ using (var viewParent = new Form())
+ using (var dialog = new StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(viewParent, locations))
+ {
+ dialog.Show();
+
+ var dataGridView = (DataGridViewControl) new ControlTester("dataGridViewControl", dialog).TheObject;
+ var rows = dataGridView.Rows;
+ var button = new ButtonTester("SelectAllButton", dialog);
+
+ // Precondition
+ Assert.IsFalse((bool) rows[0].Cells[locationSelectionColumnIndex].Value);
+ Assert.IsFalse((bool) rows[1].Cells[locationSelectionColumnIndex].Value);
+
+ // Call
+ button.Click();
+
+ // Assert
+ Assert.IsTrue((bool) rows[0].Cells[locationSelectionColumnIndex].Value);
+ Assert.IsTrue((bool) rows[1].Cells[locationSelectionColumnIndex].Value);
+ }
+ }
+
+ [Test]
+ public void DeselectAllButton_AllLocationsSelectedDeselectAllButtonClicked_AllLocationsNotSelected()
+ {
+ // Setup
+ var locations = new[]
+ {
+ new HydraulicBoundaryLocation(1, "1", 1, 1),
+ new HydraulicBoundaryLocation(2, "2", 2, 2)
+ };
+
+ using (var viewParent = new Form())
+ using (var dialog = new StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(viewParent, locations))
+ {
+ dialog.Show();
+
+ var dataGridView = (DataGridViewControl) new ControlTester("dataGridViewControl", dialog).TheObject;
+ var rows = dataGridView.Rows;
+ var button = new ButtonTester("DeselectAllButton", dialog);
+
+ foreach (DataGridViewRow row in rows)
+ {
+ row.Cells[locationSelectionColumnIndex].Value = true;
+ }
+
+ // Precondition
+ Assert.IsTrue((bool) rows[0].Cells[locationSelectionColumnIndex].Value);
+ Assert.IsTrue((bool) rows[1].Cells[locationSelectionColumnIndex].Value);
+
+ // Call
+ button.Click();
+
+ // Assert
+ Assert.IsFalse((bool) rows[0].Cells[locationSelectionColumnIndex].Value);
+ Assert.IsFalse((bool) rows[1].Cells[locationSelectionColumnIndex].Value);
+ }
+ }
+
+ [Test]
+ public void GenerateForSelectedButton_NoneSelected_GenerateForSelectedButtonDisabled()
+ {
+ // Setup
+ var locations = new[]
+ {
+ new HydraulicBoundaryLocation(1, "1", 1, 1),
+ new HydraulicBoundaryLocation(2, "2", 2, 2)
+ };
+
+ using (var viewParent = new Form())
+ using (var dialog = new StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(viewParent, locations))
+ {
+ dialog.Show();
+ var buttonTester = new ButtonTester("GenerateForSelectedButton", dialog);
+
+ // Call
+ var button = (Button) buttonTester.TheObject;
+
+ // Assert
+ Assert.IsFalse(button.Enabled);
+ Assert.IsEmpty(dialog.SelectedLocations);
+ }
+ }
+
+ [Test]
+ public void GenerateForSelectedButton_OneSelected_ReturnsSelectedLocations()
+ {
+ // Setup
+ var selectedLocation = new HydraulicBoundaryLocation(1, "1", 1, 1);
+ var locations = new[]
+ {
+ selectedLocation,
+ new HydraulicBoundaryLocation(2, "2", 2, 2)
+ };
+
+ using (var viewParent = new Form())
+ using (var dialog = new StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog(viewParent, locations))
+ {
+ dialog.Show();
+ var dataGridView = (DataGridViewControl) new ControlTester("dataGridViewControl", dialog).TheObject;
+ var rows = dataGridView.Rows;
+ rows[0].Cells[locationSelectionColumnIndex].Value = true;
+ var buttonTester = new ButtonTester("GenerateForSelectedButton", dialog);
+
+ // Call
+ buttonTester.Click();
+
+ // Assert
+ Assert.AreEqual(1, dialog.SelectedLocations.Count());
+ Assert.AreEqual(selectedLocation, dialog.SelectedLocations.First());
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs
===================================================================
diff -u -r731e20a3ce93ea0d4b51edd15975f61b732a4399 -rd4f6782b27a8e239562812f1482c1e8cb4843e64
--- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 731e20a3ce93ea0d4b51edd15975f61b732a4399)
+++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision d4f6782b27a8e239562812f1482c1e8cb4843e64)
@@ -27,6 +27,7 @@
using Core.Common.Base;
using Core.Common.Base.Data;
using Core.Common.Base.Geometry;
+using Core.Common.Controls.DataGrid;
using Core.Common.Controls.TreeView;
using Core.Common.Gui;
using Core.Common.Gui.Commands;
@@ -73,6 +74,7 @@
private const int contextMenuCalculateAllIndexNestedGroup = 4;
private const int contextMenuClearOutputNestedGroupIndex = 5;
+ private const int customOnlyContextMenuAddGenerateCalculationsIndex = 0;
private const int customOnlyContextMenuRemoveAllChildrenIndex = 5;
private MockRepository mocks;
private StabilityStoneCoverPlugin plugin;
@@ -306,7 +308,7 @@
}
[Test]
- public void ContextMenuStrip_WithoutParentNodeDefaultBehavior_ReturnContextMenuWithoutRenameRemove()
+ public void ContextMenuStrip_WithoutParentNodeWithoutHydraulicLocationsDefaultBehavior_ReturnContextMenuWithoutRenameRemove()
{
// Setup
var assessmentSection = mocks.Stub();
@@ -342,6 +344,10 @@
{
// Assert
Assert.AreEqual(15, menu.Items.Count);
+ TestHelper.AssertContextMenuStripContainsItem(menu, customOnlyContextMenuAddGenerateCalculationsIndex,
+ RingtoetsCommonFormsResources.CalculationsGroup_Generate_calculations,
+ "Er is geen hydraulische randvoorwaardendatabase beschikbaar om de randvoorwaardenberekeningen aan te maken.",
+ RingtoetsCommonFormsResources.GenerateScenariosIcon, false);
TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndexRootGroup,
RingtoetsCommonFormsResources.CalculationGroup_Add_CalculationGroup,
"Voeg een nieuwe berekeningsmap toe aan deze berekeningsmap.",
@@ -402,6 +408,112 @@
}
[Test]
+ public void ContextMenuStrip_WithoutParentNodeWithHydraulicLocationsDefaultBehavior_ReturnContextMenuWithoutRenameRemove()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
+ {
+ Locations =
+ {
+ new HydraulicBoundaryLocation(1, "1", 1, 1)
+ }
+ };
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+
+ var nodeData = new StabilityStoneCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup,
+ failureMechanism,
+ assessmentSection);
+
+ var applicationFeatureCommandHandler = mocks.Stub();
+ var importHandlerMock = mocks.StrictMock();
+ var exportHandlerMock = mocks.StrictMock();
+ var viewCommandsHandler = mocks.StrictMock();
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler,
+ importHandlerMock,
+ exportHandlerMock,
+ viewCommandsHandler,
+ nodeData,
+ treeViewControl);
+
+ var gui = mocks.Stub();
+ gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder);
+ gui.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ // Call
+ using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl))
+ {
+ // Assert
+ Assert.AreEqual(15, menu.Items.Count);
+ TestHelper.AssertContextMenuStripContainsItem(menu, customOnlyContextMenuAddGenerateCalculationsIndex,
+ RingtoetsCommonFormsResources.CalculationsGroup_Generate_calculations,
+ "Genereer randvoorwaardenberekeningen.",
+ RingtoetsCommonFormsResources.GenerateScenariosIcon);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndexRootGroup,
+ RingtoetsCommonFormsResources.CalculationGroup_Add_CalculationGroup,
+ "Voeg een nieuwe berekeningsmap toe aan deze berekeningsmap.",
+ RingtoetsCommonFormsResources.AddFolderIcon);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationIndexRootGroup,
+ RingtoetsCommonFormsResources.CalculationGroup_Add_Calculation,
+ "Voeg een nieuwe berekening toe aan deze berekeningsmap.",
+ RingtoetsCommonFormsResources.FailureMechanismIcon);
+
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRemoveAllChildrenIndexRootGroup,
+ RingtoetsCommonFormsResources.CalculationGroup_RemoveAllChildrenFromGroup_Remove_all,
+ "Er zijn geen berekeningen of mappen om te verwijderen.",
+ RingtoetsCommonFormsResources.RemoveAllIcon,
+ false);
+
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup,
+ RingtoetsCommonFormsResources.Validate_all,
+ "Er zijn geen berekeningen om te valideren.",
+ RingtoetsCommonFormsResources.ValidateAllIcon,
+ false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndexRootGroup,
+ RingtoetsCommonFormsResources.Calculate_all,
+ "Er zijn geen berekeningen om uit te voeren.",
+ RingtoetsCommonFormsResources.CalculateAllIcon,
+ false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearOutputIndexRootGroup,
+ "&Wis alle uitvoer...",
+ "Er zijn geen berekeningen met uitvoer om te wissen.",
+ RingtoetsCommonFormsResources.ClearIcon,
+ false);
+
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuExpandAllIndexRootGroup,
+ CoreCommonGuiResources.Expand_all,
+ CoreCommonGuiResources.Expand_all_ToolTip,
+ CoreCommonGuiResources.ExpandAllIcon,
+ false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCollapseAllIndexRootGroup,
+ CoreCommonGuiResources.Collapse_all,
+ CoreCommonGuiResources.Collapse_all_ToolTip,
+ CoreCommonGuiResources.CollapseAllIcon,
+ false);
+
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuPropertiesIndexRootGroup,
+ CoreCommonGuiResources.Properties,
+ CoreCommonGuiResources.Properties_ToolTip,
+ CoreCommonGuiResources.PropertiesHS,
+ false);
+ CollectionAssert.AllItemsAreInstancesOfType(new[]
+ {
+ menu.Items[1],
+ menu.Items[4],
+ menu.Items[6],
+ menu.Items[10],
+ menu.Items[13]
+ }, typeof(ToolStripSeparator));
+ }
+ }
+ }
+
+ [Test]
public void ContextMenuStrip_NestedCalculationGroupWithNoCalculations_ValidateAndCalculateAllDisabled()
{
// Setup
@@ -489,7 +601,10 @@
using (var treeViewControl = new TreeViewControl())
{
var failureMechanism = new StabilityStoneCoverFailureMechanism();
- failureMechanism.AddSection(new FailureMechanismSection("", new [] {new Point2D(0,0)}));
+ failureMechanism.AddSection(new FailureMechanismSection("", new[]
+ {
+ new Point2D(0, 0)
+ }));
var group = new CalculationGroup();
group.Children.Add(new StabilityStoneCoverWaveConditionsCalculation());
failureMechanism.WaveConditionsCalculationGroup.Children.Add(group);
@@ -531,7 +646,10 @@
using (var treeViewControl = new TreeViewControl())
{
var failureMechanism = new StabilityStoneCoverFailureMechanism();
- failureMechanism.AddSection(new FailureMechanismSection("", new [] {new Point2D(0,0)}));
+ failureMechanism.AddSection(new FailureMechanismSection("", new[]
+ {
+ new Point2D(0, 0)
+ }));
var group = new CalculationGroup();
group.Children.Add(new StabilityStoneCoverWaveConditionsCalculation());
failureMechanism.WaveConditionsCalculationGroup.Children.Add(group);
@@ -589,7 +707,10 @@
group.Children.Add(new StabilityStoneCoverWaveConditionsCalculation());
var failureMechanism = new StabilityStoneCoverFailureMechanism();
- failureMechanism.AddSection(new FailureMechanismSection("", new[] { new Point2D(0, 0) }));
+ failureMechanism.AddSection(new FailureMechanismSection("", new[]
+ {
+ new Point2D(0, 0)
+ }));
failureMechanism.WaveConditionsCalculationGroup.Children.Add(group);
var nodeData = new StabilityStoneCoverWaveConditionsCalculationGroupContext(group,
failureMechanism,
@@ -603,7 +724,6 @@
// Setup
using (var treeViewControl = new TreeViewControl())
{
-
var gui = mocks.Stub();
gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder);
@@ -658,7 +778,10 @@
group.Children.Add(calculationB);
var failureMechanism = new StabilityStoneCoverFailureMechanism();
- failureMechanism.AddSection(new FailureMechanismSection("", new[] { new Point2D(0, 0) }));
+ failureMechanism.AddSection(new FailureMechanismSection("", new[]
+ {
+ new Point2D(0, 0)
+ }));
failureMechanism.WaveConditionsCalculationGroup.Children.Add(group);
var nodeData = new StabilityStoneCoverWaveConditionsCalculationGroupContext(group,
failureMechanism,
@@ -677,7 +800,6 @@
// Setup
using (var treeViewControl = new TreeViewControl())
{
-
var mainWindow = mocks.Stub();
var gui = mocks.Stub();
@@ -728,7 +850,10 @@
var group = new CalculationGroup();
var failureMechanism = new StabilityStoneCoverFailureMechanism();
- failureMechanism.AddSection(new FailureMechanismSection("", new[] { new Point2D(0, 0) }));
+ failureMechanism.AddSection(new FailureMechanismSection("", new[]
+ {
+ new Point2D(0, 0)
+ }));
failureMechanism.WaveConditionsCalculationGroup.Children.Add(group);
var nodeData = new StabilityStoneCoverWaveConditionsCalculationGroupContext(group,
failureMechanism,
@@ -742,7 +867,6 @@
// Setup
using (var treeViewControl = new TreeViewControl())
{
-
var mainWindow = mocks.Stub();
var gui = mocks.Stub();
@@ -787,7 +911,10 @@
group.Children.Add(calculationB);
var failureMechanism = new StabilityStoneCoverFailureMechanism();
- failureMechanism.AddSection(new FailureMechanismSection("", new[] { new Point2D(0, 0) }));
+ failureMechanism.AddSection(new FailureMechanismSection("", new[]
+ {
+ new Point2D(0, 0)
+ }));
failureMechanism.WaveConditionsCalculationGroup.Children.Add(group);
var nodeData = new StabilityStoneCoverWaveConditionsCalculationGroupContext(group,
failureMechanism,
@@ -801,7 +928,6 @@
// Setup
using (var treeViewControl = new TreeViewControl())
{
-
var mainWindow = mocks.Stub();
var gui = mocks.Stub();
@@ -864,7 +990,10 @@
calculationB.Attach(observerB);
var failureMechanism = new StabilityStoneCoverFailureMechanism();
- failureMechanism.AddSection(new FailureMechanismSection("", new[] { new Point2D(0, 0) }));
+ failureMechanism.AddSection(new FailureMechanismSection("", new[]
+ {
+ new Point2D(0, 0)
+ }));
failureMechanism.WaveConditionsCalculationGroup.Children.Add(group);
var nodeData = new StabilityStoneCoverWaveConditionsCalculationGroupContext(group,
failureMechanism,
@@ -1126,15 +1255,197 @@
contextMenu.Items[contextMenuRemoveAllChildrenIndexRootGroup].PerformClick();
// Assert
- Assert.AreEqual(new [] { calculation }, failureMechanism.WaveConditionsCalculationGroup.Children);
+ Assert.AreEqual(new[]
+ {
+ calculation
+ }, failureMechanism.WaveConditionsCalculationGroup.Children);
}
}
}
[Test]
- public void OnNodeRemoved_ParentIsPipingCalculationGroupContainingGroup_RemoveGroupAndNotifyObservers()
+ public void ContextMenuStrip_ClickOnGenerateCalculations_ShowStabilityStoneCoverHydraulicBoundaryLocationSelectionDialog()
{
// Setup
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var assessmentSection = mocks.Stub();
+ assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
+ {
+ Locations =
+ {
+ new HydraulicBoundaryLocation(1, "1", 1, 1)
+ }
+ };
+ var observerMock = mocks.StrictMock();
+ var nodeData = new StabilityStoneCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup,
+ failureMechanism,
+ assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+ var mainWindow = mocks.Stub();
+ var viewCommandsMock = mocks.StrictMock();
+
+ var gui = mocks.Stub();
+ gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder);
+ gui.Expect(cmp => cmp.MainWindow).Return(mainWindow);
+ gui.Stub(cmp => cmp.ViewCommands).Return(viewCommandsMock);
+
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+ nodeData.Attach(observerMock);
+
+ StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog dialog = null;
+ DataGridViewControl grid = null;
+ int rowCount = 0;
+ DialogBoxHandler = (name, wnd) =>
+ {
+ dialog = (StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog) new FormTester(name).TheObject;
+ grid = (DataGridViewControl) new ControlTester("dataGridViewControl", dialog).TheObject;
+ rowCount = grid.Rows.Count;
+ new ButtonTester("CustomCancelButton", dialog).Click();
+ };
+
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl))
+ {
+ // Call
+ contextMenu.Items[customOnlyContextMenuAddGenerateCalculationsIndex].PerformClick();
+ }
+
+ // Assert
+ Assert.NotNull(dialog);
+ Assert.NotNull(grid);
+ Assert.AreEqual(1, rowCount);
+ }
+ }
+
+ [Test]
+ public void GivenDialogGenerateCalculationButtonClicked_WhenCalculationSelectedAndDialogClosed_ThenUpdateCalculationGroup()
+ {
+ // Given
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var group = new CalculationGroup();
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var assessmentSection = mocks.Stub();
+ assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
+ {
+ Locations =
+ {
+ new HydraulicBoundaryLocation(1, "1", 1, 1),
+ new HydraulicBoundaryLocation(2, "2", 2, 2)
+ }
+ };
+
+ var observerMock = mocks.StrictMock();
+ observerMock.Expect(o => o.UpdateObserver());
+ var nodeData = new StabilityStoneCoverWaveConditionsCalculationGroupContext(group,
+ failureMechanism,
+ assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+ var mainWindow = mocks.Stub();
+ var viewCommandsMock = mocks.StrictMock();
+
+ var gui = mocks.Stub();
+ gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder);
+ gui.Expect(cmp => cmp.MainWindow).Return(mainWindow);
+ gui.Stub(cmp => cmp.ViewCommands).Return(viewCommandsMock);
+
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+ nodeData.Attach(observerMock);
+
+ StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog dialog = null;
+ DataGridViewControl grid = null;
+ DialogBoxHandler = (name, wnd) =>
+ {
+ dialog = (StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog) new FormTester(name).TheObject;
+ grid = (DataGridViewControl) new ControlTester("dataGridViewControl", dialog).TheObject;
+ grid.Rows[0].Cells[0].Value = true;
+ grid.Rows[1].Cells[0].Value = true;
+ new ButtonTester("GenerateForSelectedButton", dialog).Click();
+ };
+
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl))
+ {
+ // Call
+ contextMenu.Items[customOnlyContextMenuAddGenerateCalculationsIndex].PerformClick();
+ }
+
+ // Assert
+ Assert.AreEqual(2, group.Children.Count);
+ Assert.NotNull(dialog);
+ Assert.NotNull(grid);
+ }
+ }
+
+ [Test]
+ public void GivenDialogGenerateCalculationButtonClicked_WhenCancelButtonClickedAndDialogClosed_ThenCalculationGroupNotUpdated()
+ {
+ // Given
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var group = new CalculationGroup();
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var assessmentSectionMock = mocks.Stub();
+ assessmentSectionMock.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
+ {
+ Locations =
+ {
+ new HydraulicBoundaryLocation(1, "1", 1, 1)
+ }
+ };
+
+ var observerMock = mocks.StrictMock();
+ var nodeData = new StabilityStoneCoverWaveConditionsCalculationGroupContext(group,
+ failureMechanism,
+ assessmentSectionMock);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+ var mainWindow = mocks.Stub();
+ var viewCommandsMock = mocks.StrictMock();
+
+ var gui = mocks.Stub();
+ gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder);
+ gui.Expect(cmp => cmp.MainWindow).Return(mainWindow);
+ gui.Stub(cmp => cmp.ViewCommands).Return(viewCommandsMock);
+
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+ nodeData.Attach(observerMock);
+
+ StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog dialog = null;
+ DataGridViewControl grid = null;
+ DialogBoxHandler = (name, wnd) =>
+ {
+ dialog = (StabilityStoneCoverHydraulicBoundaryLocationSelectionDialog) new FormTester(name).TheObject;
+ grid = (DataGridViewControl) new ControlTester("dataGridViewControl", dialog).TheObject;
+ grid.Rows[0].Cells[0].Value = true;
+ new ButtonTester("CustomCancelButton", dialog).Click();
+ };
+
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl))
+ {
+ // Call
+ contextMenu.Items[customOnlyContextMenuAddGenerateCalculationsIndex].PerformClick();
+ }
+
+ // Assert
+ Assert.AreEqual(0, group.Children.Count);
+ Assert.NotNull(dialog);
+ Assert.NotNull(grid);
+ }
+ }
+
+ [Test]
+ public void OnNodeRemoved_ParentIsWaveConditionsCalculationGrouContainingGroup_RemoveGroupAndNotifyObservers()
+ {
+ // Setup
var observer = mocks.StrictMock();
observer.Expect(o => o.UpdateObserver());
@@ -1275,14 +1586,14 @@
ForeshoreProfile = CreateForeshoreProfile(),
UseForeshore = true,
UseBreakWater = true,
- StepSize = (RoundedDouble)0.5,
- LowerBoundaryRevetment = (RoundedDouble)4,
- UpperBoundaryRevetment = (RoundedDouble)10,
- UpperBoundaryWaterLevels = (RoundedDouble)8,
- LowerBoundaryWaterLevels = (RoundedDouble)7.1
+ StepSize = (RoundedDouble) 0.5,
+ LowerBoundaryRevetment = (RoundedDouble) 4,
+ UpperBoundaryRevetment = (RoundedDouble) 10,
+ UpperBoundaryWaterLevels = (RoundedDouble) 8,
+ LowerBoundaryWaterLevels = (RoundedDouble) 7.1
}
};
- calculation.InputParameters.HydraulicBoundaryLocation.DesignWaterLevel = (RoundedDouble)9.3;
+ calculation.InputParameters.HydraulicBoundaryLocation.DesignWaterLevel = (RoundedDouble) 9.3;
return calculation;
}