Duplicate key. Use "Delete" instead of "Delete VM" to match menus for other objects.

Made Debug Assertion more detailed to aid us pick unique hotkeys.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2019-07-24 00:14:51 +01:00 committed by Mihaela Stoica
parent 655b8eedf7
commit dd94ebaf3f
4 changed files with 12 additions and 36 deletions

View File

@ -31,16 +31,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using XenAPI;
using System.Windows.Forms;
using XenAdmin.Model;
using XenAdmin.Core;
using System.Reflection;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Collections.ObjectModel;
using System.Drawing;
using System.Linq;
using XenAdmin.Dialogs;
using XenAdmin.Plugins;
@ -163,7 +162,7 @@ namespace XenAdmin.Commands
[Conditional("DEBUG")]
private void CheckAccessKeys(ContextMenuItemCollection items)
{
List<string> usedKeys = new List<string>();
var usedKeys = new Dictionary<string, List<string>>();
foreach (ToolStripItem item in items)
{
@ -174,16 +173,16 @@ namespace XenAdmin.Commands
{
string c = text[index + 1].ToString().ToLower();
if (usedKeys.Contains(c))
{
Debug.Fail("Duplicated access key: " + c);
}
if (usedKeys.ContainsKey(c))
usedKeys[c].Add(text);
else
{
usedKeys.Add(c);
}
usedKeys[c] = new List<string> { text };
}
}
if (usedKeys.Any(kvp => kvp.Value.Count > 1))
Debug.Fail("Found duplicate access key. Here are the used ones:\n" +
string.Join("\n", usedKeys.Select(kvp => $"{kvp.Key} => {string.Join(", ", kvp.Value)}")));
}
private abstract class Builder

View File

@ -113,18 +113,7 @@ namespace XenAdmin.Commands
return selection.AllItemsAre<VM>() && selection.AtLeastOneXenObjectCan<VM>(CanExecute);
}
public override string MenuText
{
get
{
if (GetSelection().Count > 1)
{
return Messages.MAINWINDOW_DELETE_OBJECTS;
}
return Messages.MAINWINDOW_DELETE_VM;
}
}
public override string MenuText => Messages.MAINWINDOW_DELETE_OBJECTS;
protected virtual string ErrorDialogText
{

View File

@ -21594,7 +21594,7 @@ namespace XenAdmin {
}
/// <summary>
/// Looks up a localized string similar to De&amp;lete....
/// Looks up a localized string similar to &amp;Delete....
/// </summary>
public static string MAINWINDOW_DELETE_OBJECTS {
get {
@ -21638,15 +21638,6 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to &amp;Delete VM....
/// </summary>
public static string MAINWINDOW_DELETE_VM {
get {
return ResourceManager.GetString("MAINWINDOW_DELETE_VM", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Destr&amp;oy....
/// </summary>

View File

@ -7519,7 +7519,7 @@ This will permanently delete and reinitialize all local storage on the servers.
<value>Ctrl+Y</value>
</data>
<data name="MAINWINDOW_DELETE_OBJECTS" xml:space="preserve">
<value>De&amp;lete...</value>
<value>&amp;Delete...</value>
</data>
<data name="MAINWINDOW_DELETE_POOL" xml:space="preserve">
<value>Mak&amp;e into standalone server</value>
@ -7533,9 +7533,6 @@ This will permanently delete and reinitialize all local storage on the servers.
<data name="MAINWINDOW_DELETE_TEMPLATE" xml:space="preserve">
<value>&amp;Delete Template...</value>
</data>
<data name="MAINWINDOW_DELETE_VM" xml:space="preserve">
<value>&amp;Delete VM...</value>
</data>
<data name="MAINWINDOW_DESTROY_SR" xml:space="preserve">
<value>Destr&amp;oy...</value>
</data>