mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-23 12:30:50 +01:00
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:
parent
218d910b0a
commit
143974e93d
@ -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;
|
||||
|
@ -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,53 +837,49 @@ 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)
|
||||
base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
|
||||
else
|
||||
if (value is Pool)
|
||||
{
|
||||
Host host = value as Host;
|
||||
if (host != null)
|
||||
base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
|
||||
}
|
||||
else if (value is Host host)
|
||||
{
|
||||
PatchingHostsDataGridViewRow row = (PatchingHostsDataGridViewRow)DataGridView.Rows[RowIndex];
|
||||
if (row.HasPool)
|
||||
{
|
||||
PatchingHostsDataGridViewRow row = (PatchingHostsDataGridViewRow)this.DataGridView.Rows[this.RowIndex];
|
||||
if (row.HasPool)
|
||||
Image hostIcon = Images.GetImage16For(host);
|
||||
base.Paint(graphics, clipBounds,
|
||||
new Rectangle(cellBounds.X + 16, cellBounds.Y, cellBounds.Width - 16,
|
||||
cellBounds.Height), rowIndex, cellState, value, formattedValue,
|
||||
errorText, cellStyle, advancedBorderStyle, paintParts);
|
||||
|
||||
if ((cellState & DataGridViewElementStates.Selected) != 0 && row.Enabled)
|
||||
{
|
||||
Image hostIcon = Images.GetImage16For(host);
|
||||
base.Paint(graphics, clipBounds,
|
||||
new Rectangle(cellBounds.X + 16, cellBounds.Y, cellBounds.Width - 16,
|
||||
cellBounds.Height), rowIndex, cellState, value, formattedValue,
|
||||
errorText, cellStyle, advancedBorderStyle, paintParts);
|
||||
|
||||
if ((cellState & DataGridViewElementStates.Selected) != 0 && row.Enabled)
|
||||
{
|
||||
using (var brush = new SolidBrush(DataGridView.DefaultCellStyle.SelectionBackColor))
|
||||
graphics.FillRectangle(
|
||||
brush, cellBounds.X,
|
||||
cellBounds.Y, hostIcon.Width, cellBounds.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var brush = new SolidBrush(DataGridView.DefaultCellStyle.BackColor))
|
||||
graphics.FillRectangle(brush,
|
||||
cellBounds.X, cellBounds.Y, hostIcon.Width, cellBounds.Height);
|
||||
}
|
||||
|
||||
if (row.Enabled)
|
||||
graphics.DrawImage(hostIcon, cellBounds.X, cellBounds.Y + 3, hostIcon.Width,
|
||||
hostIcon.Height);
|
||||
else
|
||||
graphics.DrawImage(hostIcon,
|
||||
new Rectangle(cellBounds.X, cellBounds.Y + 3,
|
||||
hostIcon.Width, hostIcon.Height),
|
||||
0, 0, hostIcon.Width, hostIcon.Height, GraphicsUnit.Pixel,
|
||||
Drawing.GreyScaleAttributes);
|
||||
using (var brush = new SolidBrush(DataGridView.DefaultCellStyle.SelectionBackColor))
|
||||
graphics.FillRectangle(
|
||||
brush, cellBounds.X,
|
||||
cellBounds.Y, hostIcon.Width, cellBounds.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue,
|
||||
errorText, cellStyle, advancedBorderStyle, paintParts);
|
||||
using (var brush = new SolidBrush(DataGridView.DefaultCellStyle.BackColor))
|
||||
graphics.FillRectangle(brush,
|
||||
cellBounds.X, cellBounds.Y, hostIcon.Width, cellBounds.Height);
|
||||
}
|
||||
|
||||
if (row.Enabled)
|
||||
graphics.DrawImage(hostIcon, cellBounds.X, cellBounds.Y + 3, hostIcon.Width,
|
||||
hostIcon.Height);
|
||||
else
|
||||
graphics.DrawImage(hostIcon,
|
||||
new Rectangle(cellBounds.X, cellBounds.Y + 3,
|
||||
hostIcon.Width, hostIcon.Height),
|
||||
0, 0, hostIcon.Width, hostIcon.Height, GraphicsUnit.Pixel,
|
||||
Drawing.GreyScaleAttributes);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue,
|
||||
errorText, cellStyle, advancedBorderStyle, paintParts);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
|
@ -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=">>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=">>ColumnNotes.Name" xml:space="preserve">
|
||||
<value>ColumnNotes</value>
|
||||
</data>
|
||||
<data name=">>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=">>ColumnVersion.Name" xml:space="preserve">
|
||||
<value>ColumnVersion</value>
|
||||
</data>
|
||||
|
Loading…
Reference in New Issue
Block a user