CA-368812: Prevent host reset when moving between wizard pages using SelectMultipleVMDestinationPage

Multiple changes:

1. Remove `SetDefaultTarget(ChosenItem);` from `PageLeaveCore`. This was clearing the value every time the page was left.
2. Add event `m_dataGridView_CellValueChanged`. Inside the event, we keep track of which target host/pool was selected
3. Add a check that resets the value set in `m_dataGridView_CellValueChanged` in case the chosen pool is changed.

Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com>
This commit is contained in:
Danilo Del Busso 2022-07-18 15:26:19 +01:00
parent 69c007eabb
commit a69843352f
No known key found for this signature in database
GPG Key ID: 0C48542619080FD4
3 changed files with 28 additions and 8 deletions

View File

@ -103,6 +103,7 @@
this.m_dataGridView.Name = "m_dataGridView";
this.m_dataGridView.RowHeadersVisible = false;
this.m_dataGridView.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.m_dataGridView_CellClick);
this.m_dataGridView.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.m_dataGridView_CellValueChanged);
this.m_dataGridView.CurrentCellDirtyStateChanged += new System.EventHandler(this.m_dataGridView_CurrentCellDirtyStateChanged);
//
// m_colVmName

View File

@ -205,7 +205,6 @@ namespace XenAdmin.Wizards.GenericPages
}
UnregisterHandlers();
SetDefaultTarget(ChosenItem);
ClearComboBox();
}
@ -464,7 +463,7 @@ namespace XenAdmin.Wizards.GenericPages
}
}
private void SetComboBoxPreSelection(DataGridViewEnableableComboBoxCell cb)
private void SetComboBoxPreSelection(DataGridViewEnableableComboBoxCell cb)
{
if (cb.Value == null)
{
@ -612,6 +611,12 @@ namespace XenAdmin.Wizards.GenericPages
if (updatingHomeServerList)
return;
// when selecting a new destination pool, reset the target host selection
if (ChosenItem != null && !ChosenItem.Equals(m_comboBoxConnection.SelectedItem))
{
SetDefaultTarget(null);
}
//If the item is delay loading and them item is disabled, null the selection made
//and clear the table containing server data
IEnableableXenObjectComboBoxItem item = m_comboBoxConnection.SelectedItem as IEnableableXenObjectComboBoxItem;
@ -675,8 +680,22 @@ namespace XenAdmin.Wizards.GenericPages
SetButtonNextEnabled(true);
}
#endregion
private void m_dataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex < 0 || e.ColumnIndex < 0)
{
return;
}
var cell = m_dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex];
if (cell.Value is IEnableableXenObjectComboBoxItem value)
{
SetDefaultTarget(value.Item);
}
}
#endregion
private void UnregisterHandlers()
{
ConnectionsManager.XenConnections.CollectionChanged -= CollectionChanged;

View File

@ -151,7 +151,7 @@
<value>m_labelIntro</value>
</data>
<data name="&gt;&gt;m_labelIntro.Type" xml:space="preserve">
<value>XenAdmin.Controls.Common.AutoHeightLabel, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
<value>XenAdmin.Controls.Common.AutoHeightLabel, [XenCenter_No_Space]Main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;m_labelIntro.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
@ -205,7 +205,7 @@
<value>m_comboBoxConnection</value>
</data>
<data name="&gt;&gt;m_comboBoxConnection.Type" xml:space="preserve">
<value>XenAdmin.Controls.EnableableComboBox, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
<value>XenAdmin.Controls.EnableableComboBox, [XenCenter_No_Space]Main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;m_comboBoxConnection.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
@ -427,12 +427,12 @@
<value>m_colTarget</value>
</data>
<data name="&gt;&gt;m_colTarget.Type" xml:space="preserve">
<value>XenAdmin.Controls.EnableableComboBoxColumn, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
<value>XenAdmin.Controls.EnableableComboBoxColumn, [XenCenter_No_Space]Main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>SelectMultipleVMDestinationPage</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>XenAdmin.Controls.XenTabPage, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
<value>XenAdmin.Controls.XenTabPage, [XenCenter_No_Space]Main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
</root>