mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-23 12:30:50 +01:00
Removed unused SaveSessionCommand and consequently refactored SaveAndRestoreDialog constructor.
Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
parent
65ea154b9d
commit
ca3e9c0219
@ -1,98 +0,0 @@
|
||||
/* 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.Text;
|
||||
using System.Windows.Forms;
|
||||
using XenAPI;
|
||||
|
||||
|
||||
namespace XenAdmin.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// Explicit request to save the current session. Turn the SaveSession property to true and save the
|
||||
/// session details - this will cause a master-password dialog to be shown.
|
||||
/// </summary>
|
||||
internal class SaveSessionCommand : Command
|
||||
{
|
||||
public SaveSessionCommand()
|
||||
{
|
||||
}
|
||||
|
||||
protected override bool CanExecuteCore(SelectedItemCollection selection)
|
||||
{
|
||||
if (XenAdmin.Properties.Settings.Default.RequirePass && Program.MasterPassword == null)
|
||||
{
|
||||
// A master password is set, but they didn't enter it. Don't let them fiddle with the saved mater password session
|
||||
return false;
|
||||
}
|
||||
return base.CanExecuteCore(selection);
|
||||
}
|
||||
|
||||
protected override string GetCantExecuteReasonCore(IXenObject item)
|
||||
{
|
||||
if (XenAdmin.Properties.Settings.Default.RequirePass && Program.MasterPassword == null)
|
||||
return Messages.ENTER_MASTER_PASSWORD_TO_ACCESS_SETTINGS_TT;
|
||||
|
||||
return base.GetCantExecuteReasonCore(item);
|
||||
}
|
||||
|
||||
protected override void ExecuteCore(SelectedItemCollection selection)
|
||||
{
|
||||
new Dialogs.RestoreSession.SaveAndRestoreDialog(true).ShowDialog(Parent);
|
||||
}
|
||||
|
||||
public override string MenuText
|
||||
{
|
||||
get
|
||||
{
|
||||
return Messages.MAINWINDOW_SAVE_AND_RESTORE;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ShortcutKeyDisplayString
|
||||
{
|
||||
get
|
||||
{
|
||||
return Messages.MAINWINDOW_CTRL_S;
|
||||
}
|
||||
}
|
||||
|
||||
public override Keys ShortcutKeys
|
||||
{
|
||||
get
|
||||
{
|
||||
return Keys.Control | Keys.S;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -44,12 +44,14 @@ namespace XenAdmin.Dialogs.RestoreSession
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
resources.ApplyResources(this.okButton, "okButton");
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.UseVisualStyleBackColor = true;
|
||||
this.okButton.Click += new System.EventHandler(this.okButton_Click);
|
||||
//
|
||||
// tableLayoutPanel1
|
||||
//
|
||||
|
@ -34,23 +34,16 @@ using System;
|
||||
namespace XenAdmin.Dialogs.RestoreSession
|
||||
{
|
||||
/// <summary>
|
||||
/// The dialog used to set whether or not to save server usernames and passwords and whether a master password should be set to protect these passwords
|
||||
/// The dialog used to set whether or not to save server usernames and passwords
|
||||
/// and whether a master password should be set to protect these passwords
|
||||
/// </summary>
|
||||
public partial class SaveAndRestoreDialog : XenDialogBase
|
||||
{
|
||||
public SaveAndRestoreDialog(bool saveAllAfter)
|
||||
public SaveAndRestoreDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
// register the checked and clicked events after the inital values of the controls have been set, saves compications of events accidentally being fired programtically
|
||||
RegisterEvents();
|
||||
// call save serverlist on OK
|
||||
saveAndRestoreOptionsPage1.SaveAllAfter = saveAllAfter;
|
||||
}
|
||||
|
||||
private void RegisterEvents()
|
||||
{
|
||||
okButton.Click += new EventHandler(okButton_Click);
|
||||
cancelButton.Click += new EventHandler(cancelButton_Click);
|
||||
// do not call SaveServerlist on OK
|
||||
saveAndRestoreOptionsPage1.SaveAllAfter = false;
|
||||
}
|
||||
|
||||
void cancelButton_Click(object sender, EventArgs e)
|
||||
@ -60,14 +53,13 @@ namespace XenAdmin.Dialogs.RestoreSession
|
||||
|
||||
void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
// ronseal
|
||||
SaveEverything();
|
||||
Close();
|
||||
}
|
||||
|
||||
// all prompts for old password should have been made
|
||||
private void SaveEverything()
|
||||
{
|
||||
// all prompts for old password must have been made
|
||||
saveAndRestoreOptionsPage1.Save();
|
||||
Settings.TrySaveSettings();
|
||||
}
|
||||
|
@ -379,7 +379,8 @@ namespace XenAdmin
|
||||
log.Debug("In automated test mode: not showing save session dialog");
|
||||
else
|
||||
{
|
||||
new Dialogs.RestoreSession.SaveAndRestoreDialog(false).ShowDialog(Program.MainWindow);
|
||||
using (var dialog = new SaveAndRestoreDialog())
|
||||
dialog.ShowDialog(Program.MainWindow);
|
||||
Program.SkipSessionSave = true;
|
||||
}
|
||||
}
|
||||
|
@ -3539,7 +3539,6 @@
|
||||
</Compile>
|
||||
<Compile Include="Commands\ResumeVMCommand.cs" />
|
||||
<Compile Include="Commands\RevertToSnapshotCommand.cs" />
|
||||
<Compile Include="Commands\SaveSessionCommand.cs" />
|
||||
<Compile Include="Commands\SelectedItem.cs" />
|
||||
<Compile Include="Commands\SelectedItemCollection.cs" />
|
||||
<Compile Include="Commands\SelectionBroadcaster.cs" />
|
||||
|
27
XenModel/Messages.Designer.cs
generated
27
XenModel/Messages.Designer.cs
generated
@ -15071,15 +15071,6 @@ namespace XenAdmin {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to To access your saved session it is required that you enter the master password when starting [XenCenter].
|
||||
/// </summary>
|
||||
public static string ENTER_MASTER_PASSWORD_TO_ACCESS_SETTINGS_TT {
|
||||
get {
|
||||
return ResourceManager.GetString("ENTER_MASTER_PASSWORD_TO_ACCESS_SETTINGS_TT", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The QoS limit value should be an integer greater than zero.
|
||||
/// </summary>
|
||||
@ -22810,15 +22801,6 @@ namespace XenAdmin {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Ctrl+S.
|
||||
/// </summary>
|
||||
public static string MAINWINDOW_CTRL_S {
|
||||
get {
|
||||
return ResourceManager.GetString("MAINWINDOW_CTRL_S", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Ctrl+Y.
|
||||
/// </summary>
|
||||
@ -23368,15 +23350,6 @@ namespace XenAdmin {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Sa&ve and Restore....
|
||||
/// </summary>
|
||||
public static string MAINWINDOW_SAVE_AND_RESTORE {
|
||||
get {
|
||||
return ResourceManager.GetString("MAINWINDOW_SAVE_AND_RESTORE", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Set as Defaul&t.
|
||||
/// </summary>
|
||||
|
@ -5301,9 +5301,6 @@ Would you like to eject these ISOs before continuing?</value>
|
||||
<data name="ENTER_MAINTENANCE_MODE_CONTEXT_MENU" xml:space="preserve">
|
||||
<value>&Enter Maintenance Mode...</value>
|
||||
</data>
|
||||
<data name="ENTER_MASTER_PASSWORD_TO_ACCESS_SETTINGS_TT" xml:space="preserve">
|
||||
<value>To access your saved session it is required that you enter the master password when starting [XenCenter]</value>
|
||||
</data>
|
||||
<data name="ENTER_VALID_QOS" xml:space="preserve">
|
||||
<value>The QoS limit value should be an integer greater than zero</value>
|
||||
</data>
|
||||
@ -7924,9 +7921,6 @@ This will permanently delete and reinitialize all local storage on the servers.
|
||||
<data name="MAINWINDOW_CTRL_R" xml:space="preserve">
|
||||
<value>Ctrl+R</value>
|
||||
</data>
|
||||
<data name="MAINWINDOW_CTRL_S" xml:space="preserve">
|
||||
<value>Ctrl+S</value>
|
||||
</data>
|
||||
<data name="MAINWINDOW_CTRL_Y" xml:space="preserve">
|
||||
<value>Ctrl+Y</value>
|
||||
</data>
|
||||
@ -8110,9 +8104,6 @@ This will permanently delete and reinitialize all local storage on the servers.
|
||||
<data name="MAINWINDOW_RESUME_ON_HOST" xml:space="preserve">
|
||||
<value>Resume on Ser&ver</value>
|
||||
</data>
|
||||
<data name="MAINWINDOW_SAVE_AND_RESTORE" xml:space="preserve">
|
||||
<value>Sa&ve and Restore...</value>
|
||||
</data>
|
||||
<data name="MAINWINDOW_SET_AS_DEFAULT_SR" xml:space="preserve">
|
||||
<value>Set as Defaul&t</value>
|
||||
</data>
|
||||
|
Loading…
Reference in New Issue
Block a user