Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -r8e046c6a53687ba335893602f77ab5c79f505fdf -rc6609aa18c44e976105aa8f434616576aeb7f677 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 8e046c6a53687ba335893602f77ab5c79f505fdf) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision c6609aa18c44e976105aa8f434616576aeb7f677) @@ -245,6 +245,15 @@ } /// + /// Looks up a localized string similar to Er zijn geen berekeningen geselecteerd.. + /// + public static string CalculatableViews_No_calculations_selected { + get { + return ResourceManager.GetString("CalculatableViews_No_calculations_selected", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Be&rekenen. /// public static string Calculate { Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx =================================================================== diff -u -r8e046c6a53687ba335893602f77ab5c79f505fdf -rc6609aa18c44e976105aa8f434616576aeb7f677 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision 8e046c6a53687ba335893602f77ab5c79f505fdf) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision c6609aa18c44e976105aa8f434616576aeb7f677) @@ -905,4 +905,7 @@ Weet u zeker dat u wilt doorgaan? + + Er zijn geen berekeningen geselecteerd. + \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj =================================================================== diff -u -re8745adff2332038bbcbcc5f9ddd3028804ebd81 -rc6609aa18c44e976105aa8f434616576aeb7f677 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision e8745adff2332038bbcbcc5f9ddd3028804ebd81) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision c6609aa18c44e976105aa8f434616576aeb7f677) @@ -175,6 +175,9 @@ ScenarioSelectionControl.cs + + CalculatableView.cs + FailureMechanismView.cs Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/CalculatableView.Designer.cs =================================================================== diff -u -r58e63d129c58c0247ce8918486f4e68120876bd9 -rc6609aa18c44e976105aa8f434616576aeb7f677 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/CalculatableView.Designer.cs (.../CalculatableView.Designer.cs) (revision 58e63d129c58c0247ce8918486f4e68120876bd9) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/CalculatableView.Designer.cs (.../CalculatableView.Designer.cs) (revision c6609aa18c44e976105aa8f434616576aeb7f677) @@ -36,12 +36,15 @@ /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.dataGridViewControl = new Core.Common.Controls.DataGrid.DataGridViewControl(); this.CalculateForSelectedButton = new System.Windows.Forms.Button(); this.DeselectAllButton = new System.Windows.Forms.Button(); this.SelectAllButton = new System.Windows.Forms.Button(); this.ButtonGroupBox = new System.Windows.Forms.GroupBox(); + this.CalculateForSelectedButtonErrorProvider = new System.Windows.Forms.ErrorProvider(this.components); this.ButtonGroupBox.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.CalculateForSelectedButtonErrorProvider)).BeginInit(); this.SuspendLayout(); // // dataGridViewControl @@ -96,17 +99,23 @@ this.ButtonGroupBox.TabIndex = 3; this.ButtonGroupBox.TabStop = false; // - // HydraulicBoundaryLocationsView + // CalculateForSelectedButtonErrorProvider // + this.CalculateForSelectedButtonErrorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink; + this.CalculateForSelectedButtonErrorProvider.ContainerControl = this; + // + // CalculatableView + // 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.Name = "CalculatableView"; this.Size = new System.Drawing.Size(533, 146); this.ButtonGroupBox.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.CalculateForSelectedButtonErrorProvider)).EndInit(); this.ResumeLayout(false); } @@ -118,5 +127,6 @@ private System.Windows.Forms.Button DeselectAllButton; private System.Windows.Forms.Button SelectAllButton; protected System.Windows.Forms.GroupBox ButtonGroupBox; + private System.Windows.Forms.ErrorProvider CalculateForSelectedButtonErrorProvider; } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/CalculatableView.cs =================================================================== diff -u -r888f6cdc81e8fb6d6a5b9baadf6395f209008836 -rc6609aa18c44e976105aa8f434616576aeb7f677 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/CalculatableView.cs (.../CalculatableView.cs) (revision 888f6cdc81e8fb6d6a5b9baadf6395f209008836) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/CalculatableView.cs (.../CalculatableView.cs) (revision c6609aa18c44e976105aa8f434616576aeb7f677) @@ -132,6 +132,20 @@ .Select(r => r.CalculatableObject); } + /// + /// Validates the calculatable objects. + /// + /// A validation message in case no calculations can be performed, null otherwise. + protected virtual string ValidateCalculatableObjects() + { + if (!GetCalculatableRows().Any(r => r.ShouldCalculate)) + { + return Resources.CalculatableViews_No_calculations_selected; + } + + return null; + } + private void LocalizeControls() { CalculateForSelectedButton.Text = Resources.CalculatableView_CalculateForSelectedButton_Text; @@ -142,7 +156,17 @@ private void UpdateCalculateForSelectedButton() { - CalculateForSelectedButton.Enabled = GetCalculatableRows().Any(r => r.ShouldCalculate); + var validationText = ValidateCalculatableObjects(); + if (!string.IsNullOrEmpty(validationText)) + { + CalculateForSelectedButton.Enabled = false; + CalculateForSelectedButtonErrorProvider.SetError(CalculateForSelectedButton, validationText); + } + else + { + CalculateForSelectedButton.Enabled = true; + CalculateForSelectedButtonErrorProvider.Clear(); + } } private void InitializeEventHandlers() Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/CalculatableView.resx =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/CalculatableView.resx (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/CalculatableView.resx (revision c6609aa18c44e976105aa8f434616576aeb7f677) @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 17, 17 + + \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/CalculatableViewTest.cs =================================================================== diff -u -r888f6cdc81e8fb6d6a5b9baadf6395f209008836 -rc6609aa18c44e976105aa8f434616576aeb7f677 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/CalculatableViewTest.cs (.../CalculatableViewTest.cs) (revision 888f6cdc81e8fb6d6a5b9baadf6395f209008836) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/CalculatableViewTest.cs (.../CalculatableViewTest.cs) (revision c6609aa18c44e976105aa8f434616576aeb7f677) @@ -23,6 +23,7 @@ using System.Linq; using System.Windows.Forms; using Core.Common.Controls.Views; +using Core.Common.Utils.Reflection; using NUnit.Extensions.Forms; using NUnit.Framework; using Ringtoets.Common.Forms.Views; @@ -178,18 +179,39 @@ } [Test] - public void GivenFullyConfiguredView_WhenNoRowsSelected_ThenCalculateForSelectedButtonDisabled() + public void GivenFullyConfiguredView_WhenNoRowsSelected_ThenCalculateForSelectedButtonDisabledAndErrorMessageProvided() { // Given & When TestCalculatableView view = ShowFullyConfiguredTestCalculatableView(); // Then var button = (Button) view.Controls.Find("CalculateForSelectedButton", true)[0]; Assert.IsFalse(button.Enabled); - Assert.IsEmpty(view.ObjectsToCalculate); + + var errorProvider = TypeUtils.GetField(view, "CalculateForSelectedButtonErrorProvider"); + Assert.AreEqual("Er zijn geen berekeningen geselecteerd.", errorProvider.GetError(button)); } [Test] + public void GivenFullyConfiguredView_WhenRowsSelected_ThenCalculateForSelectedButtonEnabledAndNoErrorMessageProvided() + { + // Given & When + TestCalculatableView view = ShowFullyConfiguredTestCalculatableView(); + + var dataGridView = (DataGridView) view.Controls.Find("dataGridView", true)[0]; + + DataGridViewRowCollection rows = dataGridView.Rows; + rows[0].Cells[calculateColumnIndex].Value = true; + + // Then + var button = (Button) view.Controls.Find("CalculateForSelectedButton", true)[0]; + Assert.IsTrue(button.Enabled); + + var errorProvider = TypeUtils.GetField(view, "CalculateForSelectedButtonErrorProvider"); + Assert.AreEqual("", errorProvider.GetError(button)); + } + + [Test] public void CalculateForSelectedButton_OneSelected_CallsCalculateHandleCalculateSelectedObjects() { // Setup