diff --git a/XenAdmin/Controls/SrPicker.cs b/XenAdmin/Controls/SrPicker.cs index 57c3cc4ac..a2de1e291 100644 --- a/XenAdmin/Controls/SrPicker.cs +++ b/XenAdmin/Controls/SrPicker.cs @@ -29,6 +29,7 @@ * SUCH DAMAGE. */ +using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; @@ -57,18 +58,32 @@ namespace XenAdmin.Controls private SR _defaultSr; private SR _preselectedSr; private readonly CollectionChangeEventHandler _srCollectionChangedWithInvoke; - private readonly object _lock = new object(); #endregion + public event Action CanBeScannedChanged; + public SrPicker() { _srCollectionChangedWithInvoke = Program.ProgramInvokeHandler(SR_CollectionChanged); - _refreshQueue.CollectionChanged += RefreshQueue_CollectionChanged; } #region Properties + public bool CanBeScanned + { + get + { + foreach (var item in Items) + { + if (item is SrPickerItem it && !it.Scanning && !it.TheSR.IsDetached()) + return true; + } + + return false; + } + } + public override bool ShowCheckboxes => false; public override bool ShowDescription => true; @@ -79,34 +94,17 @@ namespace XenAdmin.Controls public SR SR => SelectedItem is SrPickerItem srpITem && srpITem.Enabled ? srpITem.TheSR : null; - public bool ValidSelectionExists(out string invalidReason) - { - invalidReason = string.Empty; - bool allScanning = true; - - foreach (SrPickerItem item in Items) - { - if (item != null) - { - if (item.Enabled) - return true; - - if (!item.Scanning) - allScanning = false; - } - } - - if (!allScanning) - invalidReason = Messages.NO_VALID_DISK_LOCATION; - - return false; - } - #endregion - public void PopulateAsync(SRPickerType usage, IXenConnection connection, Host affinity, + public void Populate(SRPickerType usage, IXenConnection connection, Host affinity, SR preselectedSr, VDI[] existingDisks) { + foreach (var action in _refreshQueue) + action.Completed -= SrRefreshAction_Completed; + + _refreshQueue.Clear(); + ClearAllNodes(); + _usage = usage; _connection = connection; _affinity = affinity; @@ -130,6 +128,25 @@ namespace XenAdmin.Controls AddNewSr(sr); } + public void ScanSRs() + { + foreach (var item in Items) + { + if (item is SrPickerItem it && !it.Scanning && !it.TheSR.IsDetached()) + { + it.Scanning = true; + var srRefreshAction = new SrRefreshAction(it.TheSR); + srRefreshAction.Completed += SrRefreshAction_Completed; + + _refreshQueue.Add(srRefreshAction); + + if (_refreshQueue.Count(a => a.StartedRunning && !a.IsCompleted) < MAX_SCANS_PER_CONNECTION) + srRefreshAction.RunAsync(); + } + } + OnCanBeScannedChanged(); + } + public void UpdateDisks(params VDI[] vdi) { Program.AssertOnEventThread(); @@ -156,25 +173,19 @@ namespace XenAdmin.Controls sr.PropertyChanged += sr_PropertyChanged; item.ItemUpdated += Item_ItemUpdated; - item.Scanning = true; + if (HelpersGUI.BeingScanned(item.TheSR, out var scanAction)) + { + item.Scanning = true; + scanAction.Completed += SrRefreshAction_Completed; + _refreshQueue.Add(scanAction); + } AddNode(item); - - var srRefreshAction = new SrRefreshAction(item.TheSR, true); - srRefreshAction.Completed += SrRefreshAction_Completed; - - lock (_lock) - _refreshQueue.Add(srRefreshAction); + OnCanBeScannedChanged(); } - private void RefreshQueue_CollectionChanged(object sender, CollectionChangeEventArgs e) + private void OnCanBeScannedChanged() { - lock (_lock) - { - var srRefreshAction = _refreshQueue.FirstOrDefault(a => !a.StartedRunning && !a.IsCompleted); - - if (srRefreshAction != null && _refreshQueue.Count(a => a.StartedRunning && !a.IsCompleted) < MAX_SCANS_PER_CONNECTION) - srRefreshAction.RunAsync(); - } + Program.Invoke(this, () => CanBeScannedChanged?.Invoke()); } private void Item_ItemUpdated(SrPickerItem item) @@ -187,16 +198,21 @@ namespace XenAdmin.Controls if (!(obj is SrRefreshAction action)) return; - lock (_lock) - _refreshQueue.Remove(action); - Program.Invoke(this, () => { + _refreshQueue.Remove(action); + + var srRefreshAction = _refreshQueue.FirstOrDefault(a => !a.StartedRunning && !a.IsCompleted); + + if (srRefreshAction != null && _refreshQueue.Count(a => a.StartedRunning && !a.IsCompleted) < MAX_SCANS_PER_CONNECTION) + srRefreshAction.RunAsync(); + foreach (var item in Items) { if (item is SrPickerItem it && it.TheSR.opaque_ref == action.SR.opaque_ref) { it.Scanning = false; + OnCanBeScannedChanged(); if (_preselectedSr != null) { @@ -245,6 +261,7 @@ namespace XenAdmin.Controls if (item is SrPickerItem it && !it.Scanning && it.TheSR.opaque_ref == pbd.SR.opaque_ref) { it.Update(); + OnCanBeScannedChanged(); break; } } @@ -324,6 +341,8 @@ namespace XenAdmin.Controls foreach (var item in itemsToRemove) RemoveNode(item); + + OnCanBeScannedChanged(); }); } } @@ -354,15 +373,9 @@ namespace XenAdmin.Controls { if (disposing) { - lock (_lock) - { - foreach (var action in _refreshQueue) - { - action.Completed -= SrRefreshAction_Completed; - if (!action.IsCompleted) - action.Cancel(); - } - } + foreach (var action in _refreshQueue) + action.Completed -= SrRefreshAction_Completed; + UnregisterHandlers(); } diff --git a/XenAdmin/Core/HelpersGUI.cs b/XenAdmin/Core/HelpersGUI.cs index e4975e37b..04f698115 100644 --- a/XenAdmin/Core/HelpersGUI.cs +++ b/XenAdmin/Core/HelpersGUI.cs @@ -322,11 +322,10 @@ namespace XenAdmin.Core { if (!a.IsCompleted) { - if (a is SrAction && a.SR == sr) + if (a is SrAction && a.SR.opaque_ref == sr.opaque_ref) return true; - EnableHAAction haAction = a as EnableHAAction; - if (haAction != null && haAction.HeartbeatSRs.Contains(sr)) + if (a is EnableHAAction haAction && haAction.HeartbeatSRs.Contains(sr)) return true; } @@ -334,18 +333,19 @@ namespace XenAdmin.Core return false; } - public static bool BeingScanned(SR sr) + public static bool BeingScanned(SR sr, out SrRefreshAction scanAction) { foreach (ActionBase a in ConnectionsManager.History) + { + if (!a.IsCompleted && a is SrRefreshAction refreshAction && a.SR.opaque_ref == sr.opaque_ref) { - if (!a.IsCompleted) - { - if (a is SrRefreshAction && a.SR == sr) - return true; - } + scanAction = refreshAction; + return true; } - return false; - + } + + scanAction = null; + return false; } /// diff --git a/XenAdmin/Dialogs/CopyVMDialog.Designer.cs b/XenAdmin/Dialogs/CopyVMDialog.Designer.cs index 0708a86f4..a10d891c3 100644 --- a/XenAdmin/Dialogs/CopyVMDialog.Designer.cs +++ b/XenAdmin/Dialogs/CopyVMDialog.Designer.cs @@ -42,6 +42,7 @@ namespace XenAdmin.Dialogs this.groupBox1 = new XenAdmin.Controls.DecentGroupBox(); this.tableLayoutPanelSrPicker = new System.Windows.Forms.TableLayoutPanel(); this.labelSrHint = new System.Windows.Forms.Label(); + this.buttonRescan = new System.Windows.Forms.Button(); this.toolTipContainer1 = new XenAdmin.Controls.ToolTipContainer(); this.FastClonePanel = new System.Windows.Forms.Panel(); this.groupBox1.SuspendLayout(); @@ -61,6 +62,7 @@ namespace XenAdmin.Dialogs this.srPicker1.ShowDescription = true; this.srPicker1.ShowImages = true; this.srPicker1.ShowRootLines = true; + this.srPicker1.CanBeScannedChanged += new System.Action(this.srPicker1_CanBeScannedChanged); this.srPicker1.SelectedIndexChanged += new System.EventHandler(this.srPicker1_SelectedIndexChanged); // // CloseButton @@ -120,7 +122,6 @@ namespace XenAdmin.Dialogs // FastCloneDescription // resources.ApplyResources(this.FastCloneDescription, "FastCloneDescription"); - this.FastCloneDescription.AutoEllipsis = true; this.FastCloneDescription.Name = "FastCloneDescription"; // // groupBox1 @@ -137,13 +138,22 @@ namespace XenAdmin.Dialogs resources.ApplyResources(this.tableLayoutPanelSrPicker, "tableLayoutPanelSrPicker"); this.tableLayoutPanelSrPicker.Controls.Add(this.srPicker1, 0, 1); this.tableLayoutPanelSrPicker.Controls.Add(this.labelSrHint, 0, 0); + this.tableLayoutPanelSrPicker.Controls.Add(this.buttonRescan, 1, 1); this.tableLayoutPanelSrPicker.Name = "tableLayoutPanelSrPicker"; // // labelSrHint // resources.ApplyResources(this.labelSrHint, "labelSrHint"); + this.tableLayoutPanelSrPicker.SetColumnSpan(this.labelSrHint, 2); this.labelSrHint.Name = "labelSrHint"; // + // buttonRescan + // + resources.ApplyResources(this.buttonRescan, "buttonRescan"); + this.buttonRescan.Name = "buttonRescan"; + this.buttonRescan.UseVisualStyleBackColor = true; + this.buttonRescan.Click += new System.EventHandler(this.buttonRescan_Click); + // // toolTipContainer1 // resources.ApplyResources(this.toolTipContainer1, "toolTipContainer1"); @@ -202,5 +212,6 @@ namespace XenAdmin.Dialogs private System.Windows.Forms.Panel FastClonePanel; private System.Windows.Forms.TableLayoutPanel tableLayoutPanelSrPicker; private System.Windows.Forms.Label labelSrHint; + private System.Windows.Forms.Button buttonRescan; } } diff --git a/XenAdmin/Dialogs/CopyVMDialog.cs b/XenAdmin/Dialogs/CopyVMDialog.cs index 621dac2dd..ca15af2dc 100644 --- a/XenAdmin/Dialogs/CopyVMDialog.cs +++ b/XenAdmin/Dialogs/CopyVMDialog.cs @@ -99,8 +99,7 @@ namespace XenAdmin.Dialogs where vdi != null select vdi).ToArray(); - srPicker1.PopulateAsync(SrPicker.SRPickerType.Copy, _vm.Connection, - _vm.Home(), null, vdis); + srPicker1.Populate(SrPicker.SRPickerType.Copy, _vm.Connection, _vm.Home(), null, vdis); } private void EnableMoveButton() @@ -108,6 +107,11 @@ namespace XenAdmin.Dialogs MoveButton.Enabled = NameTextBox.Text.Trim().Length > 0 && srPicker1.SR != null; } + private void EnableRescanButton() + { + buttonRescan.Enabled = tableLayoutPanelSrPicker.Enabled && srPicker1.CanBeScanned; + } + private static string GetDefaultCopyName(VM vmToCopy) { var takenNames = vmToCopy.Connection.Cache.VMs.Select(vm => vm.Name()).ToList(); @@ -117,6 +121,12 @@ namespace XenAdmin.Dialogs #region Control event handlers + private void srPicker1_CanBeScannedChanged() + { + EnableRescanButton(); + EnableMoveButton(); + } + private void srPicker1_SelectedIndexChanged(object sender, EventArgs e) { EnableMoveButton(); @@ -127,6 +137,11 @@ namespace XenAdmin.Dialogs EnableMoveButton(); } + private void buttonRescan_Click(object sender, EventArgs e) + { + srPicker1.ScanSRs(); + } + private void CloseButton_Click(object sender, EventArgs e) { Close(); @@ -153,6 +168,7 @@ namespace XenAdmin.Dialogs private void CopyRadioButton_CheckedChanged(object sender, EventArgs e) { tableLayoutPanelSrPicker.Enabled = CopyRadioButton.Checked; + EnableRescanButton(); // Since the radiobuttons aren't in the same panel, we have to do manual mutual exclusion CloneRadioButton.Checked = !CopyRadioButton.Checked; } diff --git a/XenAdmin/Dialogs/CopyVMDialog.resx b/XenAdmin/Dialogs/CopyVMDialog.resx index 93b621127..119e8a25a 100644 --- a/XenAdmin/Dialogs/CopyVMDialog.resx +++ b/XenAdmin/Dialogs/CopyVMDialog.resx @@ -135,11 +135,8 @@ 3, 18 - - 3, 0, 3, 3 - - 335, 107 + 318, 129 1 @@ -148,7 +145,7 @@ srPicker1 - XenAdmin.Controls.SrPicker, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + XenAdmin.Controls.SrPicker, [XenCenter_No_Space]Main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null tableLayoutPanelSrPicker @@ -163,7 +160,7 @@ Segoe UI, 9pt - 312, 320 + 364, 342 75, 23 @@ -193,7 +190,7 @@ Segoe UI, 9pt - 231, 320 + 283, 342 75, 23 @@ -256,7 +253,7 @@ 79, 12 - 308, 23 + 369, 23 1 @@ -346,7 +343,7 @@ 79, 38 - 308, 23 + 369, 23 3 @@ -399,6 +396,9 @@ Top, Left, Right + + True + Segoe UI, 9pt @@ -406,13 +406,10 @@ NoControl - 13, 20 - - - 3, 0, 3, 0 + 13, 22 - 344, 31 + 370, 15 1 @@ -439,7 +436,7 @@ Top, Bottom, Left, Right - 1 + 2 True @@ -453,11 +450,8 @@ 3, 0 - - 3, 0, 3, 3 - - 335, 15 + 399, 15 0 @@ -477,6 +471,33 @@ 1 + + Segoe UI, 9pt + + + 327, 18 + + + 75, 23 + + + 2 + + + &Rescan + + + buttonRescan + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanelSrPicker + + + 2 + Segoe UI, 9pt @@ -487,7 +508,7 @@ 2 - 341, 128 + 405, 150 2 @@ -505,7 +526,7 @@ 0 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="srPicker1" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="labelSrHint" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100" /><Rows Styles="AutoSize,0,Percent,100" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="srPicker1" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="labelSrHint" Row="0" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="buttonRescan" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="Percent,100,AutoSize,0" /><Rows Styles="AutoSize,0,Percent,100,Absolute,20" /></TableLayoutSettings> Top, Left, Right @@ -520,7 +541,7 @@ 0, 0 - 360, 52 + 421, 52 0 @@ -544,7 +565,7 @@ 9, 19 - 360, 52 + 421, 52 0 @@ -553,7 +574,7 @@ toolTipContainer1 - XenAdmin.Controls.ToolTipContainer, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + XenAdmin.Controls.ToolTipContainer, [XenCenter_No_Space]Main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null groupBox1 @@ -571,7 +592,7 @@ 3, 10, 3, 10 - 375, 236 + 436, 258 4 @@ -583,7 +604,7 @@ groupBox1 - XenAdmin.Controls.DecentGroupBox, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + XenAdmin.Controls.DecentGroupBox, [XenCenter_No_Space]Main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null $this @@ -598,13 +619,13 @@ 96, 96 - 403, 359 + 464, 381 Tahoma, 8pt - 419, 398 + 480, 420 Copy Virtual Machine @@ -613,6 +634,6 @@ CopyVMDialog - XenAdmin.Dialogs.XenDialogBase, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + XenAdmin.Dialogs.XenDialogBase, [XenCenter_No_Space]Main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null \ No newline at end of file diff --git a/XenAdmin/Dialogs/MoveVirtualDiskDialog.Designer.cs b/XenAdmin/Dialogs/MoveVirtualDiskDialog.Designer.cs index 606428a5e..345767900 100644 --- a/XenAdmin/Dialogs/MoveVirtualDiskDialog.Designer.cs +++ b/XenAdmin/Dialogs/MoveVirtualDiskDialog.Designer.cs @@ -36,6 +36,7 @@ this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); this.buttonCancel = new System.Windows.Forms.Button(); this.labelBlurb = new System.Windows.Forms.Label(); + this.buttonRescan = new System.Windows.Forms.Button(); this.toolTipContainer2.SuspendLayout(); this.tableLayoutPanel2.SuspendLayout(); this.SuspendLayout(); @@ -61,19 +62,28 @@ // // srPicker1 // + this.tableLayoutPanel2.SetColumnSpan(this.srPicker1, 3); resources.ApplyResources(this.srPicker1, "srPicker1"); - this.tableLayoutPanel2.SetColumnSpan(this.srPicker1, 2); + this.srPicker1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; this.srPicker1.Name = "srPicker1"; - this.srPicker1.SelectedIndexChanged += new System.EventHandler(this.srPicker1_SelectedIndexChanged); + this.srPicker1.NodeIndent = 3; + this.srPicker1.RootAlwaysExpanded = false; + this.srPicker1.ShowCheckboxes = false; + this.srPicker1.ShowDescription = true; + this.srPicker1.ShowImages = true; + this.srPicker1.ShowRootLines = true; + this.srPicker1.CanBeScannedChanged += new System.Action(this.srPicker1_CanBeScannedChanged); this.srPicker1.DoubleClickOnRow += new System.EventHandler(this.srPicker1_DoubleClickOnRow); + this.srPicker1.SelectedIndexChanged += new System.EventHandler(this.srPicker1_SelectedIndexChanged); // // tableLayoutPanel2 // resources.ApplyResources(this.tableLayoutPanel2, "tableLayoutPanel2"); - this.tableLayoutPanel2.Controls.Add(this.toolTipContainer2, 0, 2); - this.tableLayoutPanel2.Controls.Add(this.buttonCancel, 1, 2); + this.tableLayoutPanel2.Controls.Add(this.buttonCancel, 2, 2); this.tableLayoutPanel2.Controls.Add(this.srPicker1, 0, 1); this.tableLayoutPanel2.Controls.Add(this.labelBlurb, 0, 0); + this.tableLayoutPanel2.Controls.Add(this.toolTipContainer2, 1, 2); + this.tableLayoutPanel2.Controls.Add(this.buttonRescan, 0, 2); this.tableLayoutPanel2.Name = "tableLayoutPanel2"; // // buttonCancel @@ -87,9 +97,16 @@ // labelBlurb // resources.ApplyResources(this.labelBlurb, "labelBlurb"); - this.tableLayoutPanel2.SetColumnSpan(this.labelBlurb, 2); + this.tableLayoutPanel2.SetColumnSpan(this.labelBlurb, 3); this.labelBlurb.Name = "labelBlurb"; // + // buttonRescan + // + resources.ApplyResources(this.buttonRescan, "buttonRescan"); + this.buttonRescan.Name = "buttonRescan"; + this.buttonRescan.UseVisualStyleBackColor = true; + this.buttonRescan.Click += new System.EventHandler(this.buttonRescan_Click); + // // MoveVirtualDiskDialog // this.AcceptButton = this.buttonMove; @@ -115,5 +132,6 @@ private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; private System.Windows.Forms.Label labelBlurb; private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonRescan; } } \ No newline at end of file diff --git a/XenAdmin/Dialogs/MoveVirtualDiskDialog.cs b/XenAdmin/Dialogs/MoveVirtualDiskDialog.cs index 27abd18e8..851815334 100644 --- a/XenAdmin/Dialogs/MoveVirtualDiskDialog.cs +++ b/XenAdmin/Dialogs/MoveVirtualDiskDialog.cs @@ -65,9 +65,9 @@ namespace XenAdmin.Dialogs protected override void OnLoad(EventArgs e) { base.OnLoad(e); - - UpdateButtons(); - srPicker1.PopulateAsync(SrPickerType, connection, null, null, _vdis.ToArray()); + + UpdateMoveButton(); + srPicker1.Populate(SrPickerType, connection, null, null, _vdis.ToArray()); } internal override string HelpName => "VDIMigrateDialog"; @@ -76,7 +76,7 @@ namespace XenAdmin.Dialogs protected virtual SrPicker.SRPickerType SrPickerType => SrPicker.SRPickerType.Move; - private void UpdateButtons() + private void UpdateMoveButton() { buttonMove.Enabled = srPicker1.SR != null; } @@ -85,7 +85,7 @@ namespace XenAdmin.Dialogs private void srPicker1_SelectedIndexChanged(object sender, EventArgs e) { - UpdateButtons(); + UpdateMoveButton(); } private void srPicker1_DoubleClickOnRow(object sender, EventArgs e) @@ -94,6 +94,17 @@ namespace XenAdmin.Dialogs buttonMove.PerformClick(); } + private void srPicker1_CanBeScannedChanged() + { + buttonRescan.Enabled = srPicker1.CanBeScanned; + UpdateMoveButton(); + } + + private void buttonRescan_Click(object sender, EventArgs e) + { + srPicker1.ScanSRs(); + } + private void buttonMove_Click(object sender, EventArgs e) { CreateAndRunParallelActions(); diff --git a/XenAdmin/Dialogs/MoveVirtualDiskDialog.resx b/XenAdmin/Dialogs/MoveVirtualDiskDialog.resx index e6ed86651..f8d074154 100644 --- a/XenAdmin/Dialogs/MoveVirtualDiskDialog.resx +++ b/XenAdmin/Dialogs/MoveVirtualDiskDialog.resx @@ -214,25 +214,22 @@ 75, 25 - 2 + 3 toolTipContainer2 - XenAdmin.Controls.ToolTipContainer, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + XenAdmin.Controls.ToolTipContainer, [XenCenter_No_Space]Main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null tableLayoutPanel2 - 0 - - - Top, Bottom, Left, Right + 3 - 2 + 3 True @@ -256,7 +253,7 @@ 75, 25 - 3 + 4 Cancel @@ -271,7 +268,7 @@ tableLayoutPanel2 - 1 + 0 True @@ -288,11 +285,11 @@ 3, 0 - - 0, 0, 0, 10 + + 3, 0, 3, 10 - 507, 25 + 507, 15 0 @@ -310,7 +307,34 @@ tableLayoutPanel2 - 3 + 2 + + + Segoe UI, 9pt + + + 3, 218 + + + 75, 23 + + + 2 + + + &Rescan + + + buttonRescan + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel2 + + + 4 Fill @@ -343,19 +367,25 @@ 0 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="toolTipContainer2" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="buttonCancel" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="srPicker1" Row="1" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="labelBlurb" Row="0" RowSpan="1" Column="0" ColumnSpan="2" /></Controls><Columns Styles="Percent,100,AutoSize,0" /><Rows Styles="AutoSize,0,Percent,100,AutoSize,0" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="buttonCancel" Row="2" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="srPicker1" Row="1" RowSpan="1" Column="0" ColumnSpan="3" /><Control Name="labelBlurb" Row="0" RowSpan="1" Column="0" ColumnSpan="3" /><Control Name="toolTipContainer2" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="buttonRescan" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100,AutoSize,0,AutoSize,0" /><Rows Styles="AutoSize,0,Percent,100,AutoSize,0" /></TableLayoutSettings> + + + Fill Segoe UI, 9pt - - 3, 25 + + False - - 3, 0, 3, 3 + + 17 + + + 3, 28 - 507, 187 + 507, 184 1 @@ -364,13 +394,13 @@ srPicker1 - XenAdmin.Controls.SrPicker, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + XenAdmin.Controls.SrPicker, [XenCenter_No_Space]Main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null tableLayoutPanel2 - 2 + 1 True @@ -397,6 +427,6 @@ MoveVirtualDiskDialog - XenAdmin.Dialogs.XenDialogBase, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + XenAdmin.Dialogs.XenDialogBase, [XenCenter_No_Space]Main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null \ No newline at end of file diff --git a/XenAdmin/Dialogs/NewDiskDialog.Designer.cs b/XenAdmin/Dialogs/NewDiskDialog.Designer.cs index 0bea68d44..f24506a0a 100644 --- a/XenAdmin/Dialogs/NewDiskDialog.Designer.cs +++ b/XenAdmin/Dialogs/NewDiskDialog.Designer.cs @@ -41,6 +41,7 @@ namespace XenAdmin.Dialogs this.label4 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.diskSpinner1 = new XenAdmin.Controls.DiskSpinner(); + this.buttonRescan = new System.Windows.Forms.Button(); this.tableLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // @@ -56,6 +57,7 @@ namespace XenAdmin.Dialogs this.srPicker.ShowDescription = true; this.srPicker.ShowImages = true; this.srPicker.ShowRootLines = true; + this.srPicker.CanBeScannedChanged += new System.Action(this.srPicker_CanBeScannedChanged); this.srPicker.SelectedIndexChanged += new System.EventHandler(this.srListBox_SelectedIndexChanged); // // CloseButton @@ -117,6 +119,7 @@ namespace XenAdmin.Dialogs this.tableLayoutPanel1.Controls.Add(this.label6, 0, 1); this.tableLayoutPanel1.Controls.Add(this.OkButton, 2, 6); this.tableLayoutPanel1.Controls.Add(this.diskSpinner1, 1, 4); + this.tableLayoutPanel1.Controls.Add(this.buttonRescan, 1, 6); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; // // label4 @@ -137,6 +140,13 @@ namespace XenAdmin.Dialogs this.diskSpinner1.Name = "diskSpinner1"; this.diskSpinner1.SelectedSizeChanged += new System.Action(this.diskSpinner1_SelectedSizeChanged); // + // buttonRescan + // + resources.ApplyResources(this.buttonRescan, "buttonRescan"); + this.buttonRescan.Name = "buttonRescan"; + this.buttonRescan.UseVisualStyleBackColor = true; + this.buttonRescan.Click += new System.EventHandler(this.buttonRescan_Click); + // // NewDiskDialog // this.AcceptButton = this.OkButton; @@ -166,5 +176,6 @@ namespace XenAdmin.Dialogs private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label6; private Controls.DiskSpinner diskSpinner1; + private System.Windows.Forms.Button buttonRescan; } } diff --git a/XenAdmin/Dialogs/NewDiskDialog.cs b/XenAdmin/Dialogs/NewDiskDialog.cs index 406f75245..ef296ac58 100644 --- a/XenAdmin/Dialogs/NewDiskDialog.cs +++ b/XenAdmin/Dialogs/NewDiskDialog.cs @@ -61,7 +61,8 @@ namespace XenAdmin.Dialogs NameTextBox.Text = GetDefaultVDIName(); diskSpinner1.Populate(); - srPicker.PopulateAsync(SrPicker.SRPickerType.InstallFromTemplate, connection, null, sr, new[] { NewDisk() }); + srPicker.Populate(SrPicker.SRPickerType.InstallFromTemplate, connection, null, sr, new[] { NewDisk() }); + buttonRescan.Enabled = srPicker.CanBeScanned; UpdateErrorsAndButtons(); } @@ -80,7 +81,8 @@ namespace XenAdmin.Dialogs { NameTextBox.Text = GetDefaultVDIName(); diskSpinner1.Populate(minSize: minSize); - srPicker.PopulateAsync(pickerUsage, connection, affinity, null, new[] { NewDisk() }); + srPicker.Populate(pickerUsage, connection, affinity, null, new[] { NewDisk() }); + buttonRescan.Enabled = srPicker.CanBeScanned; UpdateErrorsAndButtons(); } else @@ -91,7 +93,8 @@ namespace XenAdmin.Dialogs Text = Messages.EDIT_DISK; OkButton.Text = Messages.OK; diskSpinner1.Populate(DiskTemplate.virtual_size, minSize); - srPicker.PopulateAsync(pickerUsage, connection, affinity, connection.Resolve(DiskTemplate.SR), new[] { NewDisk() }); + srPicker.Populate(pickerUsage, connection, affinity, connection.Resolve(DiskTemplate.SR), new[] { NewDisk() }); + buttonRescan.Enabled = srPicker.CanBeScanned; UpdateErrorsAndButtons(); } } @@ -117,6 +120,17 @@ namespace XenAdmin.Dialogs UpdateErrorsAndButtons(); } + private void srPicker_CanBeScannedChanged() + { + buttonRescan.Enabled = srPicker.CanBeScanned; + UpdateErrorsAndButtons(); + } + + private void buttonRescan_Click(object sender, EventArgs e) + { + srPicker.ScanSRs(); + } + private void OkButton_Click(object sender, EventArgs e) { if (srPicker.SR == null || NameTextBox.Text == "" || !connection.IsConnected) @@ -286,10 +300,28 @@ namespace XenAdmin.Dialogs return; } - if (!srPicker.ValidSelectionExists(out var invalidReason))//all SRs disabled + bool allDisabled = true; + bool anyScanning = false; + + foreach (SrPickerItem item in srPicker.Items) + { + if (item == null) + continue; + + if (item.Enabled) + { + allDisabled = false; + break; + } + + if (item.Scanning) + anyScanning = true; + } + + if (allDisabled) { OkButton.Enabled = false; - diskSpinner1.SetError(invalidReason); + diskSpinner1.SetError(anyScanning ? null : Messages.NO_VALID_DISK_LOCATION); return; } diff --git a/XenAdmin/Dialogs/NewDiskDialog.resx b/XenAdmin/Dialogs/NewDiskDialog.resx index 12cea5f35..7e114a68b 100644 --- a/XenAdmin/Dialogs/NewDiskDialog.resx +++ b/XenAdmin/Dialogs/NewDiskDialog.resx @@ -142,7 +142,7 @@ 75, 23 - 10 + 11 Cancel @@ -406,7 +406,7 @@ 75, 23 - 9 + 10 &Add @@ -459,6 +459,33 @@ 10 + + Segoe UI, 9pt + + + 79, 356 + + + 75, 23 + + + 9 + + + &Rescan + + + buttonRescan + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel1 + + + 11 + Fill @@ -490,7 +517,7 @@ 0 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="CloseButton" Row="6" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="label2" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="label1" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="NameTextBox" Row="2" RowSpan="1" Column="1" ColumnSpan="3" /><Control Name="DescriptionTextBox" Row="3" RowSpan="1" Column="1" ColumnSpan="3" /><Control Name="srPicker" Row="5" RowSpan="1" Column="1" ColumnSpan="3" /><Control Name="label3" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="label4" Row="5" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="label6" Row="1" RowSpan="1" Column="0" ColumnSpan="4" /><Control Name="OkButton" Row="6" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="diskSpinner1" Row="4" RowSpan="1" Column="1" ColumnSpan="3" /></Controls><Columns Styles="AutoSize,0,Percent,100,AutoSize,0,AutoSize,0" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Percent,100,AutoSize,0,Absolute,20,Absolute,20,Absolute,20" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="CloseButton" Row="6" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="label2" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="label1" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="NameTextBox" Row="2" RowSpan="1" Column="1" ColumnSpan="3" /><Control Name="DescriptionTextBox" Row="3" RowSpan="1" Column="1" ColumnSpan="3" /><Control Name="srPicker" Row="5" RowSpan="1" Column="1" ColumnSpan="3" /><Control Name="label3" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="label4" Row="5" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="label6" Row="1" RowSpan="1" Column="0" ColumnSpan="4" /><Control Name="OkButton" Row="6" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="diskSpinner1" Row="4" RowSpan="1" Column="1" ColumnSpan="3" /><Control Name="buttonRescan" Row="6" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100,AutoSize,0,AutoSize,0" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Percent,100,AutoSize,0,Absolute,20,Absolute,20,Absolute,20" /></TableLayoutSettings> Fill diff --git a/XenAdmin/Dialogs/VMDialogs/MoveVMDialog.Designer.cs b/XenAdmin/Dialogs/VMDialogs/MoveVMDialog.Designer.cs index 51f514c49..b2489b1b4 100644 --- a/XenAdmin/Dialogs/VMDialogs/MoveVMDialog.Designer.cs +++ b/XenAdmin/Dialogs/VMDialogs/MoveVMDialog.Designer.cs @@ -35,6 +35,7 @@ this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.label1 = new System.Windows.Forms.Label(); this.toolTipContainer1 = new XenAdmin.Controls.ToolTipContainer(); + this.buttonRescan = new System.Windows.Forms.Button(); this.tableLayoutPanel1.SuspendLayout(); this.toolTipContainer1.SuspendLayout(); this.SuspendLayout(); @@ -42,7 +43,15 @@ // srPicker1 // resources.ApplyResources(this.srPicker1, "srPicker1"); + this.srPicker1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; this.srPicker1.Name = "srPicker1"; + this.srPicker1.NodeIndent = 3; + this.srPicker1.RootAlwaysExpanded = false; + this.srPicker1.ShowCheckboxes = false; + this.srPicker1.ShowDescription = true; + this.srPicker1.ShowImages = true; + this.srPicker1.ShowRootLines = true; + this.srPicker1.CanBeScannedChanged += new System.Action(this.srPicker1_CanBeScannedChanged); this.srPicker1.DoubleClickOnRow += new System.EventHandler(this.srPicker1_DoubleClickOnRow); this.srPicker1.SelectedIndexChanged += new System.EventHandler(this.srPicker1_SelectedIndexChanged); // @@ -79,12 +88,20 @@ this.toolTipContainer1.Controls.Add(this.buttonMove); this.toolTipContainer1.Name = "toolTipContainer1"; // + // buttonRescan + // + resources.ApplyResources(this.buttonRescan, "buttonRescan"); + this.buttonRescan.Name = "buttonRescan"; + this.buttonRescan.UseVisualStyleBackColor = true; + this.buttonRescan.Click += new System.EventHandler(this.buttonRescan_Click); + // // MoveVMDialog // this.AcceptButton = this.buttonMove; resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.CancelButton = this.buttonCancel; + this.Controls.Add(this.buttonRescan); this.Controls.Add(this.toolTipContainer1); this.Controls.Add(this.tableLayoutPanel1); this.Controls.Add(this.buttonCancel); @@ -104,5 +121,6 @@ private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; private System.Windows.Forms.Label label1; private XenAdmin.Controls.ToolTipContainer toolTipContainer1; + private System.Windows.Forms.Button buttonRescan; } } \ No newline at end of file diff --git a/XenAdmin/Dialogs/VMDialogs/MoveVMDialog.cs b/XenAdmin/Dialogs/VMDialogs/MoveVMDialog.cs index 27c0daebe..69f7f5756 100644 --- a/XenAdmin/Dialogs/VMDialogs/MoveVMDialog.cs +++ b/XenAdmin/Dialogs/VMDialogs/MoveVMDialog.cs @@ -59,8 +59,7 @@ namespace XenAdmin.Dialogs.VMDialogs where vdi != null select vdi).ToArray(); - srPicker1.PopulateAsync(SrPicker.SRPickerType.Move, vm.Connection, - vm.Home(), null, vdis); + srPicker1.Populate(SrPicker.SRPickerType.Move, vm.Connection, vm.Home(), null, vdis); } private void EnableMoveButton() @@ -76,6 +75,11 @@ namespace XenAdmin.Dialogs.VMDialogs buttonMove.PerformClick(); } + private void buttonRescan_Click(object sender, EventArgs e) + { + srPicker1.ScanSRs(); + } + private void buttonMove_Click(object sender, EventArgs e) { var action = new VMMoveAction(vm, srPicker1.SR, vm.GetStorageHost(false)); @@ -83,6 +87,12 @@ namespace XenAdmin.Dialogs.VMDialogs Close(); } + private void srPicker1_CanBeScannedChanged() + { + buttonRescan.Enabled = srPicker1.CanBeScanned; + EnableMoveButton(); + } + private void srPicker1_SelectedIndexChanged(object sender, EventArgs e) { EnableMoveButton(); diff --git a/XenAdmin/Dialogs/VMDialogs/MoveVMDialog.resx b/XenAdmin/Dialogs/VMDialogs/MoveVMDialog.resx index 777496689..b5b64c0a3 100644 --- a/XenAdmin/Dialogs/VMDialogs/MoveVMDialog.resx +++ b/XenAdmin/Dialogs/VMDialogs/MoveVMDialog.resx @@ -125,6 +125,13 @@ Segoe UI, 9pt + + + False + + + 17 + 3, 25 @@ -134,7 +141,6 @@ 495, 186 - 1 @@ -142,7 +148,7 @@ srPicker1 - XenAdmin.Controls.SrPicker, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + XenAdmin.Controls.SrPicker, [XenCenter_No_Space]Main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null tableLayoutPanel1 @@ -193,7 +199,7 @@ 75, 23 - 2 + 3 Cancel @@ -208,7 +214,7 @@ $this - 2 + 3 Top, Bottom, Left, Right @@ -277,7 +283,7 @@ $this - 1 + 2 <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="srPicker1" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="label1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100" /><Rows Styles="AutoSize,0,Percent,100" /></TableLayoutSettings> @@ -295,18 +301,45 @@ 77, 23 - 1 + 2 toolTipContainer1 - XenAdmin.Controls.ToolTipContainer, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + XenAdmin.Controls.ToolTipContainer, [XenCenter_No_Space]Main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null $this + 1 + + + Segoe UI, 9pt + + + 15, 237 + + + 75, 23 + + + 1 + + + &Rescan + + + buttonRescan + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + 0 @@ -331,6 +364,6 @@ MoveVMDialog - XenAdmin.Dialogs.XenDialogBase, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + XenAdmin.Dialogs.XenDialogBase, [XenCenter_No_Space]Main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null \ No newline at end of file diff --git a/XenAdmin/TabPages/SrStoragePage.cs b/XenAdmin/TabPages/SrStoragePage.cs index 8b9b48a76..572b31788 100644 --- a/XenAdmin/TabPages/SrStoragePage.cs +++ b/XenAdmin/TabPages/SrStoragePage.cs @@ -434,7 +434,7 @@ namespace XenAdmin.TabPages buttonRescan.Enabled = false; toolTipContainerRescan.SetToolTip(Messages.SR_DETACHED); } - else if (HelpersGUI.BeingScanned(sr)) + else if (HelpersGUI.BeingScanned(sr, out _)) { buttonRescan.Enabled = false; toolTipContainerRescan.SetToolTip(Messages.SCAN_IN_PROGRESS_TOOLTIP); diff --git a/XenAdmin/Wizards/CrossPoolMigrateWizard/IntraPoolCopyPage.Designer.cs b/XenAdmin/Wizards/CrossPoolMigrateWizard/IntraPoolCopyPage.Designer.cs index 9b7a949ac..cbac1c9e2 100644 --- a/XenAdmin/Wizards/CrossPoolMigrateWizard/IntraPoolCopyPage.Designer.cs +++ b/XenAdmin/Wizards/CrossPoolMigrateWizard/IntraPoolCopyPage.Designer.cs @@ -44,6 +44,7 @@ this.labelRubric = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); + this.buttonRescan = new System.Windows.Forms.Button(); this.tableLayoutPanel1.SuspendLayout(); this.groupBox1.SuspendLayout(); this.tableLayoutPanelSrPicker.SuspendLayout(); @@ -89,17 +90,27 @@ resources.ApplyResources(this.tableLayoutPanelSrPicker, "tableLayoutPanelSrPicker"); this.tableLayoutPanelSrPicker.Controls.Add(this.srPicker1, 0, 1); this.tableLayoutPanelSrPicker.Controls.Add(this.labelSrHint, 0, 0); + this.tableLayoutPanelSrPicker.Controls.Add(this.buttonRescan, 1, 1); this.tableLayoutPanelSrPicker.Name = "tableLayoutPanelSrPicker"; // // srPicker1 // resources.ApplyResources(this.srPicker1, "srPicker1"); + this.srPicker1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; this.srPicker1.Name = "srPicker1"; + this.srPicker1.NodeIndent = 3; + this.srPicker1.RootAlwaysExpanded = false; + this.srPicker1.ShowCheckboxes = false; + this.srPicker1.ShowDescription = true; + this.srPicker1.ShowImages = true; + this.srPicker1.ShowRootLines = true; + this.srPicker1.CanBeScannedChanged += new System.Action(this.srPicker1_CanBeScannedChanged); this.srPicker1.SelectedIndexChanged += new System.EventHandler(this.srPicker1_SelectedIndexChanged); // // labelSrHint // resources.ApplyResources(this.labelSrHint, "labelSrHint"); + this.tableLayoutPanelSrPicker.SetColumnSpan(this.labelSrHint, 2); this.labelSrHint.Name = "labelSrHint"; // // toolTipContainer1 @@ -153,6 +164,13 @@ resources.ApplyResources(this.label1, "label1"); this.label1.Name = "label1"; // + // buttonRescan + // + resources.ApplyResources(this.buttonRescan, "buttonRescan"); + this.buttonRescan.Name = "buttonRescan"; + this.buttonRescan.UseVisualStyleBackColor = true; + this.buttonRescan.Click += new System.EventHandler(this.buttonRescan_Click); + // // IntraPoolCopyPage // resources.ApplyResources(this, "$this"); @@ -188,7 +206,8 @@ private System.Windows.Forms.TextBox DescriptionTextBox; private System.Windows.Forms.TextBox NameTextBox; private System.Windows.Forms.TableLayoutPanel tableLayoutPanelSrPicker; - private System.Windows.Forms.Label labelSrHint; + private System.Windows.Forms.Label labelSrHint; + private System.Windows.Forms.Button buttonRescan; } } diff --git a/XenAdmin/Wizards/CrossPoolMigrateWizard/IntraPoolCopyPage.cs b/XenAdmin/Wizards/CrossPoolMigrateWizard/IntraPoolCopyPage.cs index ed4c83775..b366ee547 100644 --- a/XenAdmin/Wizards/CrossPoolMigrateWizard/IntraPoolCopyPage.cs +++ b/XenAdmin/Wizards/CrossPoolMigrateWizard/IntraPoolCopyPage.cs @@ -41,15 +41,15 @@ namespace XenAdmin.Wizards.CrossPoolMigrateWizard { public partial class IntraPoolCopyPage : XenTabPage { - public readonly VM TheVM; + private bool _buttonNextEnabled; public IntraPoolCopyPage(List selectedVMs) { - this.TheVM = selectedVMs[0]; + TheVM = selectedVMs[0]; InitializeComponent(); } - private bool _buttonNextEnabled; + public VM TheVM { get; } public bool CloneVM => !tableLayoutPanelSrPicker.Enabled || CloneRadioButton.Checked; @@ -134,8 +134,7 @@ namespace XenAdmin.Wizards.CrossPoolMigrateWizard where vdi != null select vdi).ToArray(); - srPicker1.PopulateAsync(SrPicker.SRPickerType.Copy, TheVM.Connection, - TheVM.Home(), null, vdis); + srPicker1.Populate(SrPicker.SRPickerType.Copy, TheVM.Connection, TheVM.Home(), null, vdis); } public override bool EnableNext() @@ -152,6 +151,7 @@ namespace XenAdmin.Wizards.CrossPoolMigrateWizard if (!CrossPoolMigrateWizard.AllVMsAvailable(l)) cancel = true; } + #endregion private void UpdateButtons() @@ -166,11 +166,27 @@ namespace XenAdmin.Wizards.CrossPoolMigrateWizard OnPageUpdated(); } + private void EnableRescanButton() + { + buttonRescan.Enabled = tableLayoutPanelSrPicker.Enabled && srPicker1.CanBeScanned; + } + private void srPicker1_SelectedIndexChanged(object sender, EventArgs e) { UpdateButtons(); } + private void srPicker1_CanBeScannedChanged() + { + EnableRescanButton(); + UpdateButtons(); + } + + private void buttonRescan_Click(object sender, EventArgs e) + { + srPicker1.ScanSRs(); + } + private void NameTextBox_TextChanged(object sender, EventArgs e) { UpdateButtons(); @@ -196,6 +212,7 @@ namespace XenAdmin.Wizards.CrossPoolMigrateWizard private void CopyRadioButton_CheckedChanged(object sender, EventArgs e) { tableLayoutPanelSrPicker.Enabled = CopyRadioButton.Checked; + EnableRescanButton(); // Since the radiobuttons aren't in the same panel, we have to do manual mutual exclusion CloneRadioButton.Checked = !CopyRadioButton.Checked; UpdateButtons(); diff --git a/XenAdmin/Wizards/CrossPoolMigrateWizard/IntraPoolCopyPage.resx b/XenAdmin/Wizards/CrossPoolMigrateWizard/IntraPoolCopyPage.resx index 5110bfc15..0abcc0caf 100644 --- a/XenAdmin/Wizards/CrossPoolMigrateWizard/IntraPoolCopyPage.resx +++ b/XenAdmin/Wizards/CrossPoolMigrateWizard/IntraPoolCopyPage.resx @@ -181,22 +181,25 @@ Top, Bottom, Left, Right - 1 + 2 - - Top, Bottom, Left, Right + + Fill Segoe UI, 9pt + + False + + + 17 + 3, 18 - - 3, 0, 3, 3 - - 430, 138 + 349, 138 1 @@ -205,7 +208,7 @@ srPicker1 - XenAdmin.Controls.SrPicker, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + XenAdmin.Controls.SrPicker, [XenCenter_No_Space]Main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null tableLayoutPanelSrPicker @@ -222,9 +225,6 @@ 3, 0 - - 3, 0, 3, 3 - 430, 15 @@ -246,6 +246,30 @@ 1 + + 358, 18 + + + 75, 23 + + + 2 + + + &Rescan + + + buttonRescan + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanelSrPicker + + + 2 + 25, 102 @@ -271,7 +295,7 @@ 0 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="srPicker1" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="labelSrHint" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100" /><Rows Styles="AutoSize,0,Percent,100" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="srPicker1" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="labelSrHint" Row="0" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="buttonRescan" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="Percent,100,AutoSize,0" /><Rows Styles="AutoSize,0,Percent,100" /></TableLayoutSettings> Top, Left, Right @@ -388,7 +412,7 @@ toolTipContainer1 - XenAdmin.Controls.ToolTipContainer, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + XenAdmin.Controls.ToolTipContainer, [XenCenter_No_Space]Main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null groupBox1 @@ -451,7 +475,7 @@ groupBox1 - XenAdmin.Controls.DecentGroupBox, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + XenAdmin.Controls.DecentGroupBox, [XenCenter_No_Space]Main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null tableLayoutPanel1 @@ -619,6 +643,6 @@ IntraPoolCopyPage - XenAdmin.Controls.XenTabPage, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + XenAdmin.Controls.XenTabPage, [XenCenter_No_Space]Main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null \ No newline at end of file diff --git a/XenAdmin/Wizards/ImportWizard/StoragePickerPage.Designer.cs b/XenAdmin/Wizards/ImportWizard/StoragePickerPage.Designer.cs index 533ad120e..f6a7559ba 100644 --- a/XenAdmin/Wizards/ImportWizard/StoragePickerPage.Designer.cs +++ b/XenAdmin/Wizards/ImportWizard/StoragePickerPage.Designer.cs @@ -32,6 +32,7 @@ this.m_srPicker = new XenAdmin.Controls.SrPicker(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.labelSrHint = new System.Windows.Forms.Label(); + this.buttonRescan = new System.Windows.Forms.Button(); this.tableLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // @@ -46,6 +47,7 @@ this.m_srPicker.ShowDescription = true; this.m_srPicker.ShowImages = true; this.m_srPicker.ShowRootLines = true; + this.m_srPicker.CanBeScannedChanged += new System.Action(this.m_srPicker_CanBeScannedChanged); this.m_srPicker.SelectedIndexChanged += new System.EventHandler(this.m_srPicker_SelectedIndexChanged); // // tableLayoutPanel1 @@ -53,6 +55,7 @@ resources.ApplyResources(this.tableLayoutPanel1, "tableLayoutPanel1"); this.tableLayoutPanel1.Controls.Add(this.labelSrHint, 0, 0); this.tableLayoutPanel1.Controls.Add(this.m_srPicker, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.buttonRescan, 0, 2); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; // // labelSrHint @@ -60,6 +63,13 @@ resources.ApplyResources(this.labelSrHint, "labelSrHint"); this.labelSrHint.Name = "labelSrHint"; // + // buttonRescan + // + resources.ApplyResources(this.buttonRescan, "buttonRescan"); + this.buttonRescan.Name = "buttonRescan"; + this.buttonRescan.UseVisualStyleBackColor = true; + this.buttonRescan.Click += new System.EventHandler(this.buttonRescan_Click); + // // StoragePickerPage // resources.ApplyResources(this, "$this"); @@ -77,5 +87,6 @@ private XenAdmin.Controls.SrPicker m_srPicker; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; private System.Windows.Forms.Label labelSrHint; - } + private System.Windows.Forms.Button buttonRescan; + } } diff --git a/XenAdmin/Wizards/ImportWizard/StoragePickerPage.cs b/XenAdmin/Wizards/ImportWizard/StoragePickerPage.cs index 615036d25..dbb298e5e 100644 --- a/XenAdmin/Wizards/ImportWizard/StoragePickerPage.cs +++ b/XenAdmin/Wizards/ImportWizard/StoragePickerPage.cs @@ -117,7 +117,7 @@ namespace XenAdmin.Wizards.ImportWizard public override void PopulatePage() { SetButtonNextEnabled(false); - m_srPicker.PopulateAsync(SrPicker.SRPickerType.VM, TargetConnection, TargetHost, null, null); + m_srPicker.Populate(SrPicker.SRPickerType.VM, TargetConnection, TargetHost, null, null); IsDirty = true; } @@ -287,6 +287,17 @@ namespace XenAdmin.Wizards.ImportWizard IsDirty = true; } - #endregion - } + private void m_srPicker_CanBeScannedChanged() + { + buttonRescan.Enabled = m_srPicker.CanBeScanned; + SetButtonNextEnabled(m_srPicker.SR != null); + } + + private void buttonRescan_Click(object sender, EventArgs e) + { + m_srPicker.ScanSRs(); + } + + #endregion + } } diff --git a/XenAdmin/Wizards/ImportWizard/StoragePickerPage.resx b/XenAdmin/Wizards/ImportWizard/StoragePickerPage.resx index 6b4d580e4..ea4866035 100644 --- a/XenAdmin/Wizards/ImportWizard/StoragePickerPage.resx +++ b/XenAdmin/Wizards/ImportWizard/StoragePickerPage.resx @@ -136,16 +136,16 @@ 3, 52 - 566, 277 + 566, 248 - 0 + 1 m_srPicker - XenAdmin.Controls.SrPicker, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + XenAdmin.Controls.SrPicker, [XenCenter_No_Space]Main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null tableLayoutPanel1 @@ -191,6 +191,30 @@ When you have finished, click "Import" to begin importing the VM and proceed to 0 + + 3, 306 + + + 75, 23 + + + 2 + + + &Rescan + + + buttonRescan + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel1 + + + 2 + Fill @@ -198,7 +222,7 @@ When you have finished, click "Import" to begin importing the VM and proceed to 0, 0 - 2 + 3 572, 332 @@ -219,7 +243,7 @@ When you have finished, click "Import" to begin importing the VM and proceed to 0 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="labelSrHint" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="m_srPicker" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100" /><Rows Styles="AutoSize,0,Percent,100" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="labelSrHint" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="m_srPicker" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="buttonRescan" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100" /><Rows Styles="AutoSize,0,Percent,100,AutoSize,0" /></TableLayoutSettings> True @@ -234,6 +258,6 @@ When you have finished, click "Import" to begin importing the VM and proceed to StoragePickerPage - XenAdmin.Controls.XenTabPage, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + XenAdmin.Controls.XenTabPage, [XenCenter_No_Space]Main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null \ No newline at end of file