CA-381502: Show the disabled reason in a new column because the tooltips are obscure.

Signed-off-by: Konstantina Chremmou <Konstantina.Chremmou@cloud.com>
This commit is contained in:
Konstantina Chremmou 2023-08-15 21:07:07 +01:00
parent 218d910b0a
commit 143974e93d
3 changed files with 87 additions and 89 deletions

View File

@ -41,6 +41,7 @@ namespace XenAdmin.Wizards.PatchingWizard
this.ColumnExpander = new System.Windows.Forms.DataGridViewImageColumn();
this.ColumnPoolIconHostCheck = new System.Windows.Forms.DataGridViewImageColumn();
this.ColumnName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnNotes = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnVersion = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.label1 = new System.Windows.Forms.Label();
this.buttonSelectAll = new System.Windows.Forms.Button();
@ -77,6 +78,7 @@ namespace XenAdmin.Wizards.PatchingWizard
this.ColumnExpander,
this.ColumnPoolIconHostCheck,
this.ColumnName,
this.ColumnNotes,
this.ColumnVersion});
this.tableLayoutPanel1.SetColumnSpan(this.dataGridViewHosts, 2);
this.dataGridViewHosts.Name = "dataGridViewHosts";
@ -105,11 +107,15 @@ namespace XenAdmin.Wizards.PatchingWizard
//
// ColumnName
//
this.ColumnName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.ColumnName.FillWeight = 110.2538F;
resources.ApplyResources(this.ColumnName, "ColumnName");
this.ColumnName.Name = "ColumnName";
//
// ColumnNotes
//
resources.ApplyResources(this.ColumnNotes, "ColumnNotes");
this.ColumnNotes.Name = "ColumnNotes";
this.ColumnNotes.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// ColumnVersion
//
this.ColumnVersion.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
@ -161,6 +167,7 @@ namespace XenAdmin.Wizards.PatchingWizard
private DataGridViewImageColumn ColumnExpander;
private DataGridViewImageColumn ColumnPoolIconHostCheck;
private DataGridViewTextBoxColumn ColumnName;
private DataGridViewTextBoxColumn ColumnNotes;
private DataGridViewTextBoxColumn ColumnVersion;
private Label label1;
private CheckBox applyUpdatesCheckBox;

View File

@ -152,9 +152,8 @@ namespace XenAdmin.Wizards.PatchingWizard
{
var hostRow = new PatchingHostsDataGridViewRow(host, hasPool, !poolSelectionOnly) {ParentPoolRow = poolRow};
dataGridViewHosts.Rows.Add(hostRow);
string tooltipText;
hostRow.Enabled = CanEnableRow(host, out tooltipText);
hostRow.Cells[3].ToolTipText = tooltipText;
hostRow.Enabled = CanEnableRow(host, out var cannotEnableReason);
hostRow.Notes = cannotEnableReason;
//Enable the pool row
if (poolRow != null && hostRow.Enabled)
@ -165,7 +164,7 @@ namespace XenAdmin.Wizards.PatchingWizard
}
if (poolRow != null && !poolRow.Enabled && coordinatorRow != null)
poolRow.Cells[3].ToolTipText = coordinatorRow.Cells[3].ToolTipText;
poolRow.Notes = coordinatorRow.Notes;
}
// restore server selection
@ -276,8 +275,7 @@ namespace XenAdmin.Wizards.PatchingWizard
return false;
}
string reason;
if (!IsHostAmongApplicable(host, out reason))
if (!IsHostAmongApplicable(host, out var reason))
{
tooltipText = reason;
return false;
@ -349,7 +347,7 @@ namespace XenAdmin.Wizards.PatchingWizard
{
var nonApplicables = host.Connection.Cache.Hosts.Count(h =>
!applicableHosts.Contains(h) && !string.IsNullOrEmpty(patchUuidFromAlert) &&
!isPatchApplied(patchUuidFromAlert, h));
!IsPatchApplied(patchUuidFromAlert, h));
if (0 < nonApplicables && nonApplicables < host.Connection.Cache.Hosts.Length)
{
@ -361,7 +359,7 @@ namespace XenAdmin.Wizards.PatchingWizard
if (!applicableHosts.Contains(host) && !string.IsNullOrEmpty(patchUuidFromAlert))
{
if (isPatchApplied(patchUuidFromAlert, host))
if (IsPatchApplied(patchUuidFromAlert, host))
{
if (ApplyUpdatesToNewVersion)
return CanEnableRowAutomatedUpdates(host, out tooltipText);
@ -377,7 +375,7 @@ namespace XenAdmin.Wizards.PatchingWizard
return true;
}
private bool isPatchApplied(string uuid, Host host)
private bool IsPatchApplied(string uuid, Host host)
{
if (Helpers.ElyOrGreater(host))
{
@ -654,26 +652,24 @@ namespace XenAdmin.Wizards.PatchingWizard
foreach (PatchingHostsDataGridViewRow row in dataGridViewHosts.Rows)
{
var host = row.Tag as Host;
if (host != null)
if (row.Tag is Host host)
{
string tooltipText;
row.Enabled = CanEnableRow(host, out tooltipText);
row.Cells[3].ToolTipText = tooltipText;
row.Enabled = CanEnableRow(host, out var cannotEnableReason);
row.Notes = cannotEnableReason;
if (row.ParentPoolRow != null)
{
if (row.Enabled)
{
row.ParentPoolRow.Enabled = true;
row.ParentPoolRow.Cells[3].ToolTipText = null;
row.Notes = null;
}
if (masterRow == null)
{
masterRow = row;
if (!row.Enabled)
row.ParentPoolRow.Cells[3].ToolTipText = row.Cells[3].ToolTipText;
row.ParentPoolRow.Notes = row.Notes;
}
}
}
@ -841,16 +837,13 @@ namespace XenAdmin.Wizards.PatchingWizard
{
protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
{
Pool pool = value as Pool;
if (pool != null)
if (value is Pool)
{
base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
else
}
else if (value is Host host)
{
Host host = value as Host;
if (host != null)
{
PatchingHostsDataGridViewRow row = (PatchingHostsDataGridViewRow)this.DataGridView.Rows[this.RowIndex];
PatchingHostsDataGridViewRow row = (PatchingHostsDataGridViewRow)DataGridView.Rows[RowIndex];
if (row.HasPool)
{
Image hostIcon = Images.GetImage16For(host);
@ -891,7 +884,6 @@ namespace XenAdmin.Wizards.PatchingWizard
}
}
}
}
private class DataGridViewIconCell : DataGridViewImageCell
{
@ -927,7 +919,7 @@ namespace XenAdmin.Wizards.PatchingWizard
private DataGridViewCell _poolIconHostCheckCell;
private DataGridViewTextBoxCell _versionCell;
private DataGridViewTextBoxCell _notesCell;
private readonly bool _showHostCheckBox = true;
public PatchingHostsDataGridViewRow(Pool pool)
@ -943,22 +935,15 @@ namespace XenAdmin.Wizards.PatchingWizard
SetupCells();
}
public int VersionCellIndex
{
get { return Cells.IndexOf(_versionCell); }
}
public PatchingHostsDataGridViewRow ParentPoolRow { get; set; }
public override bool IsCheckable
{
get { return !HasPool; }
}
public int VersionCellIndex => Cells.IndexOf(_versionCell);
public override bool IsCheckable => !HasPool;
public override bool Enabled
{
get
{
return base.Enabled;
}
get => base.Enabled;
set
{
base.Enabled = value;
@ -966,23 +951,18 @@ namespace XenAdmin.Wizards.PatchingWizard
}
}
public int CheckValue
{
get {
return IsPoolOrStandaloneHost
? (int) Cells[POOL_CHECKBOX_COL].Value
: (int) Cells[POOL_ICON_HOST_CHECKBOX_COL].Value;
}
}
public int CheckValue => IsPoolOrStandaloneHost
? (int)Cells[POOL_CHECKBOX_COL].Value
: (int)Cells[POOL_ICON_HOST_CHECKBOX_COL].Value;
public bool IsSelectableHost
{
get { return IsAHostRow && Enabled && (_showHostCheckBox || !HasPool); }
}
public bool IsSelectableHost => IsAHostRow && Enabled && (_showHostCheckBox || !HasPool);
public bool IsSelectablePool
public bool IsSelectablePool => IsAPoolRow && Enabled;
public string Notes
{
get { return IsAPoolRow && Enabled; }
get => _notesCell.Value as string;
set => _notesCell.Value = value;
}
private void SetupCells()
@ -996,10 +976,11 @@ namespace XenAdmin.Wizards.PatchingWizard
_nameCell = new DataGridViewNameCell();
_versionCell = new DataGridViewTextBoxCell();
_notesCell = new DataGridViewTextBoxCell();
Cells.AddRange(_expansionCell, _poolCheckBoxCell, _poolIconHostCheckCell, _nameCell, _versionCell);
Cells.AddRange(_expansionCell, _poolCheckBoxCell, _poolIconHostCheckCell, _nameCell, _notesCell, _versionCell);
this.UpdateDetails();
UpdateDetails();
}
private void UpdateDetails()
@ -1040,8 +1021,6 @@ namespace XenAdmin.Wizards.PatchingWizard
_poolIconHostCheckCell.Value = Images.GetImage16For((IXenObject)Tag);
}
}
public PatchingHostsDataGridViewRow ParentPoolRow { get; set; }
}
#endregion

View File

@ -198,6 +198,12 @@
<data name="ColumnName.HeaderText" xml:space="preserve">
<value>Name</value>
</data>
<metadata name="ColumnNotes.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="ColumnNotes.HeaderText" xml:space="preserve">
<value>Notes</value>
</data>
<metadata name="ColumnVersion.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@ -378,6 +384,12 @@
<data name="&gt;&gt;ColumnName.Type" xml:space="preserve">
<value>System.Windows.Forms.DataGridViewTextBoxColumn, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;ColumnNotes.Name" xml:space="preserve">
<value>ColumnNotes</value>
</data>
<data name="&gt;&gt;ColumnNotes.Type" xml:space="preserve">
<value>System.Windows.Forms.DataGridViewTextBoxColumn, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;ColumnVersion.Name" xml:space="preserve">
<value>ColumnVersion</value>
</data>