mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-12-30 07:40:13 +01:00
a3bfe5c7e4
# HG changeset patch # User Konstantina Chremmou <Konstantina.Chremmou@citrix.com> # Date 1376062101 -3600 # Node ID e9a03389b4dfd447a4034b55d74827d30e3950be # Parent d0a3fa6db59fcaea186f0909053866153d15d450 CA-112877: Set the description text of the transfer VM network page when the export/import mode is set ratehr than when the page is populated to avoid refreshing issues. Also, fixed string formatting issue which could potentially cause problems with the word order in languages other than English. Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
245 lines
7.0 KiB
C#
245 lines
7.0 KiB
C#
/* Copyright (c) Citrix Systems Inc.
|
|
* All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms,
|
|
* with or without modification, are permitted provided
|
|
* that the following conditions are met:
|
|
*
|
|
* * Redistributions of source code must retain the above
|
|
* copyright notice, this list of conditions and the
|
|
* following disclaimer.
|
|
* * Redistributions in binary form must reproduce the above
|
|
* copyright notice, this list of conditions and the
|
|
* following disclaimer in the documentation and/or other
|
|
* materials provided with the distribution.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
* SUCH DAMAGE.
|
|
*/
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text.RegularExpressions;
|
|
using XenAdmin.Controls;
|
|
using XenAdmin.Controls.Common;
|
|
using XenAdmin.Core;
|
|
|
|
|
|
namespace XenAdmin.Wizards.GenericPages
|
|
{
|
|
/// <summary>
|
|
/// Class representing the page of the wizard where the user specifies the IP address to be used by the Transfer VM.
|
|
/// </summary>
|
|
public partial class TvmIpPage : XenTabPage
|
|
{
|
|
private bool m_buttonNextEnabled;
|
|
|
|
public TvmIpPage()
|
|
{
|
|
InitializeComponent();
|
|
m_ctrlError.HideError();
|
|
}
|
|
|
|
#region Base class (XenTabPage) overrides
|
|
|
|
/// <summary>
|
|
/// Gets the page's title (headline)
|
|
/// </summary>
|
|
public override string PageTitle { get { return Messages.TVM_PAGE_TITLE; } }
|
|
|
|
/// <summary>
|
|
/// Gets the page's label in the (left hand side) wizard progress panel
|
|
/// </summary>
|
|
public override string Text { get { return Messages.TVM_PAGE_TEXT; } }
|
|
|
|
protected override bool ImplementsIsDirty()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public override void PageLoaded(PageLoadedDirection direction)
|
|
{
|
|
base.PageLoaded(direction);//call first so the page gets populated
|
|
m_buttonNextEnabled = true;
|
|
OnPageUpdated();
|
|
}
|
|
|
|
public override void PageLeave(PageLoadedDirection direction, ref bool cancel)
|
|
{
|
|
if (direction == PageLoadedDirection.Forward && IsDirty)
|
|
{
|
|
if (!PerformCheck(CheckValidData))
|
|
cancel = true;
|
|
}
|
|
base.PageLeave(direction, ref cancel);
|
|
}
|
|
|
|
public override void PopulatePage()
|
|
{
|
|
m_comboBoxNetwork.PopulateComboBox(Connection);
|
|
m_radioAutomatic.Checked = true;
|
|
}
|
|
|
|
public override bool EnableNext()
|
|
{
|
|
return m_buttonNextEnabled;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Accessors
|
|
|
|
public bool IsExportMode
|
|
{
|
|
set
|
|
{
|
|
autoHeightLabel1.Text = value
|
|
? Messages.TVM_PAGE_DESCRIPTION_EXPORT
|
|
: Messages.TVM_PAGE_DESCRIPTION_IMPORT;
|
|
}
|
|
}
|
|
|
|
public KeyValuePair<string, string> NetworkUuid
|
|
{
|
|
get { return m_comboBoxNetwork.SelectedNetworkUuid; }
|
|
}
|
|
|
|
public bool IsTvmIpStatic { get { return m_radioManual.Checked; } }
|
|
|
|
public string TvmIpAddress { get { return m_textBoxIP.Text; } }
|
|
|
|
public string TvmSubnetMask { get { return m_textBoxMask.Text; } }
|
|
|
|
public string TvmGateway { get { return m_textBoxGateway.Text; } }
|
|
|
|
#endregion
|
|
|
|
#region Private methods
|
|
|
|
/// <summary>
|
|
/// Performs certain checks on the pages's input data and shows/hides an error accordingly
|
|
/// </summary>
|
|
/// <param name="checks">The checks to perform</param>
|
|
private bool PerformCheck(params CheckDelegate[] checks)
|
|
{
|
|
m_buttonNextEnabled = m_ctrlError.PerformCheck(checks);
|
|
OnPageUpdated();
|
|
return m_buttonNextEnabled;
|
|
}
|
|
|
|
private bool CheckRequiredFieldsCompleted(out string error)
|
|
{
|
|
error = string.Empty;
|
|
|
|
if (m_radioManual.Checked && (string.IsNullOrEmpty(m_textBoxIP.Text) || string.IsNullOrEmpty(m_textBoxMask.Text) || string.IsNullOrEmpty(m_textBoxGateway.Text)))
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
private bool CheckValidData(out string error)
|
|
{
|
|
error = string.Empty;
|
|
|
|
if (m_radioManual.Checked)
|
|
{
|
|
if (!StringUtility.IsIPAddress(m_textBoxIP.Text))
|
|
{
|
|
error = Messages.ERROR_INVALID_IP;
|
|
return false;
|
|
}
|
|
|
|
if (!StringUtility.IsIPAddress(m_textBoxMask.Text))
|
|
{
|
|
error = Messages.ERROR_INVALID_MASK;
|
|
return false;
|
|
}
|
|
|
|
if (!StringUtility.IsIPAddress(m_textBoxGateway.Text))
|
|
{
|
|
error = Messages.ERROR_INVALID_GATEWAY;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
private void ToggleRadioManualCheckedState()
|
|
{
|
|
if (m_radioManual.Checked)
|
|
return;
|
|
|
|
if (!String.IsNullOrEmpty(m_textBoxIP.Text) || !String.IsNullOrEmpty(m_textBoxMask.Text) || !String.IsNullOrEmpty(m_textBoxGateway.Text))
|
|
m_radioManual.Checked = true;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Control event handlers
|
|
|
|
private void m_radioAutomatic_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
//only examine the Checked case to avoid cyclical calls between the radion button handlers
|
|
if (m_radioAutomatic.Checked)
|
|
{
|
|
m_radioManual.Checked = false;
|
|
PerformCheck(CheckRequiredFieldsCompleted);
|
|
IsDirty = true;
|
|
}
|
|
}
|
|
|
|
private void m_radioManual_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
//only examine the Checked case to avoid cyclical calls between the radion button handlers
|
|
if (m_radioManual.Checked)
|
|
{
|
|
m_radioAutomatic.Checked = false;
|
|
PerformCheck(CheckRequiredFieldsCompleted);
|
|
IsDirty = true;
|
|
}
|
|
}
|
|
|
|
private void m_textBoxIP_TextChanged(object sender, EventArgs e)
|
|
{
|
|
ToggleRadioManualCheckedState();
|
|
PerformCheck(CheckRequiredFieldsCompleted);
|
|
IsDirty = true;
|
|
}
|
|
|
|
private void m_textBoxMask_TextChanged(object sender, EventArgs e)
|
|
{
|
|
ToggleRadioManualCheckedState();
|
|
PerformCheck(CheckRequiredFieldsCompleted);
|
|
IsDirty = true;
|
|
}
|
|
|
|
private void m_textBoxGateway_TextChanged(object sender, EventArgs e)
|
|
{
|
|
ToggleRadioManualCheckedState();
|
|
PerformCheck(CheckRequiredFieldsCompleted);
|
|
IsDirty = true;
|
|
}
|
|
|
|
private void m_comboBoxNetwork_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
IsDirty = true;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|