protected sealed override void OnDropDownOpening(EventArgs e) { base.DropDownItems.Clear(); Command cmd = new ChangeStorageLinkPasswordCommand(Command.MainWindowCommandInterface, Command.GetSelection()); CommandToolStripMenuItem item = new CommandToolStripMenuItem(cmd); base.DropDownItems.Add(item); cmd = new SetStorageLinkLicenseServerCommand(Command.MainWindowCommandInterface, Command.GetSelection()); item = new CommandToolStripMenuItem(cmd); base.DropDownItems.Add(item); base.DropDownItems.Add(new ToolStripSeparator()); cmd = new AddStorageLinkSystemCommand(Command.MainWindowCommandInterface, Command.GetSelection()); item = new CommandToolStripMenuItem(cmd); base.DropDownItems.Add(item); cmd = new RemoveStorageLinkSystemCommand(Command.MainWindowCommandInterface, Command.GetSelection()); item = new CommandToolStripMenuItem(cmd); base.DropDownItems.Add(item); cmd = new RefreshStorageLinkConnectionCommand(Command.MainWindowCommandInterface, Command.GetSelection()); item = new CommandToolStripMenuItem(cmd); base.DropDownItems.Add(item); }
protected override void OnDropDownOpening(EventArgs e) { base.DropDownItems.Clear(); var cmd = new NewGroupCommand(Command.MainWindowCommandInterface, Command.GetSelection()); var item = new CommandToolStripMenuItem(cmd); base.DropDownItems.Add(item); T[] groups = VMGroup <T> .GroupsInCache(Command.GetSelection()[0].Connection.Cache); if (groups.Length > 0) { base.DropDownItems.Add(new ToolStripSeparator()); } Array.Sort(groups); for (int index = 0; index < groups.Length; index++) { T group = groups[index]; var menuText = index < 9 ? String.Format(Messages.DYNAMIC_MENUITEM_WITH_ACCESS_KEY, index + 1, group.Name) : String.Format(Messages.DYNAMIC_MENUITEM_WITHOUT_ACCESS_KEY, group.Name); var cmdGroup = new AssignGroupToVMCommand(Command.MainWindowCommandInterface, Command.GetSelection(), group, menuText); var itemGroup = new CommandToolStripMenuItem(cmdGroup); if (Command.GetSelection().Count == 1 && VMGroup <T> .VmToGroup((VM)Command.GetSelection()[0].XenObject).opaque_ref == group.opaque_ref) { itemGroup.Checked = true; } base.DropDownItems.Add(itemGroup); } }
public override void Build(IMainWindow mainWindow, SelectedItemCollection selection, ContextMenuItemCollection items) { items.Add(new NewVMCommand(mainWindow, selection)); items.Add(new NewSRCommand(mainWindow, selection)); items.Add(new ImportCommand(mainWindow, selection)); items.AddSeparator(); if (selection.FirstAsXenObject != null) { items.Add(new HACommand(mainWindow, selection)); } items.AddIfEnabled(new VMGroupCommand <VMPP>(mainWindow, selection)); items.AddIfEnabled(new VMGroupCommand <VM_appliance>(mainWindow, selection)); var drItem = new CommandToolStripMenuItem(new DRCommand(mainWindow, selection), true); if (drItem.Command.CanExecute()) { drItem.DropDownItems.Add(new CommandToolStripMenuItem( new DRConfigureCommand(mainWindow, selection), true)); drItem.DropDownItems.Add(new CommandToolStripMenuItem(new DisasterRecoveryCommand(mainWindow, selection), true)); items.Add(drItem); } items.AddSeparator(); items.Add(new AddHostToSelectedPoolToolStripMenuItem(mainWindow, selection, true)); items.Add(new DisconnectPoolCommand(mainWindow, selection)); items.Add(new PoolReconnectAsCommand(mainWindow, selection)); items.AddSeparator(); items.Add(new DeletePoolCommand(mainWindow, selection)); items.AddPluginItems(PluginContextMenu.pool, selection); items.AddSeparator(); items.Add(new PoolPropertiesCommand(mainWindow, selection)); }
public void AddPluginItems(PluginContextMenu contextMenu, SelectedItemCollection selection) { if (_pluginManager == null) { throw new InvalidOperationException("No plugin manager was specified."); } bool addedSeparatorBefore = false; foreach (PluginDescriptor plugin in _pluginManager.Plugins) { if (plugin.Enabled) { foreach (Feature feature in plugin.Features) { MenuItemFeature menuItemFeature = feature as MenuItemFeature; if (menuItemFeature != null && menuItemFeature.ContextMenu == contextMenu) { if (!addedSeparatorBefore) { AddSeparator(); addedSeparatorBefore = true; } Add(menuItemFeature.GetCommand(_mainWindow, selection)); } ParentMenuItemFeature parentMenuItemFeature = feature as ParentMenuItemFeature; if (parentMenuItemFeature != null && parentMenuItemFeature.ContextMenu == contextMenu) { CommandToolStripMenuItem parentItem = new CommandToolStripMenuItem(parentMenuItemFeature.GetCommand(_mainWindow, selection)); foreach (MenuItemFeature f in parentMenuItemFeature.Features) { parentItem.DropDownItems.Add(new CommandToolStripMenuItem(f.GetCommand(_mainWindow, selection))); } if (!addedSeparatorBefore) { AddSeparator(); addedSeparatorBefore = true; } Add(parentItem); } } } } if (addedSeparatorBefore) { AddSeparator(); } }
public void Add(Command command, bool bold) { CommandToolStripMenuItem item = new CommandToolStripMenuItem(command, true); if (bold) { item.Font = Program.DefaultFontBold; } Add(item); }
protected override void OnDropDownOpening(EventArgs e) { base.DropDownItems.Clear(); var cmd = new NewGroupCommand(Command.MainWindowCommandInterface, Command.GetSelection()); var item = new CommandToolStripMenuItem(cmd); base.DropDownItems.Add(item); T[] groups = VMGroup <T> .GroupsInCache(Command.GetSelection()[0].Connection.Cache); if (groups.Length > 0) { base.DropDownItems.Add(new ToolStripSeparator()); } Array.Sort(groups); for (int index = 0, offset = 0; index < groups.Length; index++) { T group = groups[index]; /* do not add unsupported policies to the drop down for VMSS */ XenAPI.VMSS policy = group as VMSS; if (policy != null && policy.policy_type == policy_backup_type.snapshot_with_quiesce) { List <VM> vms = Command.GetSelection().AsXenObjects <VM>(); bool doNotInclude = vms.Any(vm => !vm.allowed_operations.Contains(vm_operations.snapshot_with_quiesce)); if (doNotInclude) { offset--; continue; } } var menuText = (index + offset) < 9 ? String.Format(Messages.DYNAMIC_MENUITEM_WITH_ACCESS_KEY, (index + offset) + 1, group.Name) : String.Format(Messages.DYNAMIC_MENUITEM_WITHOUT_ACCESS_KEY, group.Name); var cmdGroup = new AssignGroupToVMCommand(Command.MainWindowCommandInterface, Command.GetSelection(), group, menuText); var itemGroup = new CommandToolStripMenuItem(cmdGroup); if (Command.GetSelection().Count == 1 && VMGroup <T> .VmToGroup((VM)Command.GetSelection()[0].XenObject).opaque_ref == group.opaque_ref) { itemGroup.Checked = true; } base.DropDownItems.Add(itemGroup); } }
public override void Build(IMainWindow mainWindow, SelectedItemCollection selection, ContextMenuItemCollection items) { items.Add(new NewVMCommand(mainWindow, selection)); items.Add(new NewSRCommand(mainWindow, selection)); items.Add(new ImportCommand(mainWindow, selection)); items.AddSeparator(); var haItem = new CommandToolStripMenuItem(new HACommand(mainWindow, selection), true); if (haItem.Command.CanExecute()) { haItem.DropDownItems.Add(new CommandToolStripMenuItem(new HAConfigureCommand(mainWindow, selection), true)); haItem.DropDownItems.Add(new CommandToolStripMenuItem(new HADisableCommand(mainWindow, selection), true)); items.Add(haItem); } items.AddIfEnabled(new VMGroupCommand <VMSS>(mainWindow, selection)); items.AddIfEnabled(new VMGroupCommand <VM_appliance>(mainWindow, selection)); var drItem = new CommandToolStripMenuItem(new DRCommand(mainWindow, selection), true); if (drItem.Command.CanExecute()) { drItem.DropDownItems.Add(new CommandToolStripMenuItem( new DRConfigureCommand(mainWindow, selection), true)); drItem.DropDownItems.Add(new CommandToolStripMenuItem(new DisasterRecoveryCommand(mainWindow, selection), true)); items.Add(drItem); } items.AddIfEnabled(new LaunchConversionManagerCommand(mainWindow, selection)); var pool = selection.FirstAsXenObject as Pool; if (pool != null && !pool.IsPoolFullyUpgraded()) { items.Add(new RollingUpgradeCommand(mainWindow)); } items.AddSeparator(); items.Add(new AddHostToSelectedPoolToolStripMenuItem(mainWindow, selection, true)); items.Add(new DisconnectPoolCommand(mainWindow, selection)); items.Add(new PoolReconnectAsCommand(mainWindow, selection)); items.AddSeparator(); items.AddPluginItems(PluginContextMenu.pool, selection); items.AddSeparator(); items.Add(new PoolPropertiesCommand(mainWindow, selection)); }
protected override void OnDropDownOpening(EventArgs e) { base.DropDownItems.Clear(); SelectedItemCollection selection = Command.GetSelection(); IXenConnection connection = selection[0].Connection; // Add a menu item for each connection we might add to this pool foreach (Host host in GetSortedHostList()) { string hostName = Helpers.GetName(host.Connection); if (host.RestrictPooling) { hostName = String.Format(Messages.HOST_MENU_ADD_SERVER, hostName); } AddHostToPoolCommand cmd = new AddHostToPoolCommand(Command.MainWindowCommandInterface, new Host[] { host }, Helpers.GetPool(connection), true); CommandToolStripMenuItem hostMenuItem = new CommandToolStripMenuItem(cmd, hostName.EscapeAmpersands(), Resources._000_TreeConnected_h32bit_16); base.DropDownItems.Add(hostMenuItem); } if (base.DropDownItems.Count <= 0) { ToolStripMenuItem hostMenuItem = new ToolStripMenuItem(Messages.HOST_MENU_EMPTY); hostMenuItem.Enabled = false; hostMenuItem.Font = Program.DefaultFont; base.DropDownItems.Add(hostMenuItem); } if (Helpers.GetPool(connection) != null) { base.DropDownItems.Add(new ToolStripSeparator()); // Add a final option for connecting a new server and adding it to the pool in one action AddNewHostToPoolCommand cmd = new AddNewHostToPoolCommand(Command.MainWindowCommandInterface, Helpers.GetPool(connection)); CommandToolStripMenuItem connectAndAddToPoolMenuItem = new CommandToolStripMenuItem(cmd); base.DropDownItems.Add(connectAndAddToPoolMenuItem); } }
private void generatePoolPatchesBox() { Pool pool = xenObject as Pool; if (pool == null) return; PDSection s = pdSectionUpdates; List<KeyValuePair<String, String>> messages = CheckPoolUpdate(pool); if (messages.Count > 0) { foreach (KeyValuePair<String, String> kvp in messages) { s.AddEntry(kvp.Key, kvp.Value); } } Host master = Helpers.GetMaster(xenObject.Connection); if (master == null) return; var poolAppPatches = poolAppliedPatches(); if (!string.IsNullOrEmpty(poolAppPatches)) { s.AddEntry(FriendlyName("Pool_patch.fully_applied"), poolAppPatches); return; } CommandToolStripMenuItem applypatch = new CommandToolStripMenuItem( new InstallNewUpdateCommand(Program.MainWindow), true); var menuItems = new[] { applypatch }; var poolPartPatches = poolPartialPatches(); if (!string.IsNullOrEmpty(poolPartPatches)) { s.AddEntry(FriendlyName("Pool_patch.partially_applied"), poolPartPatches, menuItems, Color.Red); return; } var poolNotAppPatches = poolNotAppliedPatches(); }
public override void Build(IMainWindow mainWindow, SelectedItemCollection selection, ContextMenuItemCollection items) { items.Add(new NewVMCommand(mainWindow, selection)); items.Add(new NewSRCommand(mainWindow, selection)); items.Add(new ImportCommand(mainWindow, selection)); items.AddSeparator(); if (selection.FirstAsXenObject != null ) items.Add(new HACommand(mainWindow, selection)); items.AddIfEnabled(new VMGroupCommand<VMPP>(mainWindow, selection)); items.AddIfEnabled(new VMGroupCommand<VM_appliance>(mainWindow, selection)); var drItem = new CommandToolStripMenuItem(new DRCommand(mainWindow, selection), true); if (drItem.Command.CanExecute()) { drItem.DropDownItems.Add(new CommandToolStripMenuItem( new DRConfigureCommand(mainWindow, selection), true)); drItem.DropDownItems.Add(new CommandToolStripMenuItem(new DisasterRecoveryCommand(mainWindow, selection), true)); items.Add(drItem); } var pool = selection.FirstAsXenObject as Pool; if (pool != null && !pool.IsPoolFullyUpgraded) items.Add(new RollingUpgradeCommand(mainWindow)); items.AddSeparator(); items.Add(new AddHostToSelectedPoolToolStripMenuItem(mainWindow, selection, true)); items.Add(new DisconnectPoolCommand(mainWindow, selection)); items.Add(new PoolReconnectAsCommand(mainWindow, selection)); items.AddSeparator(); items.AddPluginItems(PluginContextMenu.pool, selection); items.AddSeparator(); items.Add(new PoolPropertiesCommand(mainWindow, selection)); }
protected override void OnDropDownOpening(EventArgs e) { base.DropDownItems.Clear(); SelectedItemCollection selection = Command.GetSelection(); IXenConnection connection = selection[0].Connection; // Add a menu item for each connection we might add to this pool foreach (Host host in GetSortedHostList()) { string hostName = Helpers.GetName(host.Connection); AddHostToPoolCommand cmd = new AddHostToPoolCommand(Command.MainWindowCommandInterface, new Host[] { host }, Helpers.GetPool(connection), true); CommandToolStripMenuItem hostMenuItem = new CommandToolStripMenuItem(cmd, hostName.EscapeAmpersands(), Resources._000_TreeConnected_h32bit_16); base.DropDownItems.Add(hostMenuItem); } if (base.DropDownItems.Count <= 0) { ToolStripMenuItem hostMenuItem = new ToolStripMenuItem(Messages.HOST_MENU_EMPTY); hostMenuItem.Enabled = false; hostMenuItem.Font = Program.DefaultFont; base.DropDownItems.Add(hostMenuItem); } if (Helpers.GetPool(connection) != null) { base.DropDownItems.Add(new ToolStripSeparator()); // Add a final option for connecting a new server and adding it to the pool in one action AddNewHostToPoolCommand cmd = new AddNewHostToPoolCommand(Command.MainWindowCommandInterface, Helpers.GetPool(connection)); CommandToolStripMenuItem connectAndAddToPoolMenuItem = new CommandToolStripMenuItem(cmd); base.DropDownItems.Add(connectAndAddToPoolMenuItem); } }
private void generateHostPatchesBox() { Host host = xenObject as Host; if (host == null) return; PDSection s = pdSectionUpdates; List<KeyValuePair<String, String>> messages = CheckServerUpdates(host); if (messages.Count > 0) { foreach (KeyValuePair<String, String> kvp in messages) { s.AddEntry(kvp.Key, kvp.Value); } } if (hostAppliedPatches(host) != "") { s.AddEntry(FriendlyName("Pool_patch.applied"), hostAppliedPatches(host)); } if (!Host.IsFullyPatched(host, ConnectionsManager.XenConnectionsCopy)) { CommandToolStripMenuItem applypatch = new CommandToolStripMenuItem( new InstallNewUpdateCommand(Program.MainWindow), true); var menuItems = new[] { applypatch }; s.AddEntry(FriendlyName("Pool_patch.not_applied"), hostUnappliedPatches(host), menuItems, Color.Red); } // add supplemental packs var suppPacks = hostInstalledSuppPacks(host); if (!string.IsNullOrEmpty(suppPacks)) { s.AddEntry(FriendlyName("Supplemental_packs.installed"), suppPacks); } }
private void generateHostPatchesBox() { Host host = xenObject as Host; if (host == null) return; PDSection s = pdSectionUpdates; List<KeyValuePair<String, String>> messages = CheckServerUpdates(host); if (messages.Count > 0) { foreach (KeyValuePair<String, String> kvp in messages) { s.AddEntry(kvp.Key, kvp.Value); } } if (hostAppliedPatches(host) != "") { s.AddEntry(FriendlyName("Pool_patch.applied"), hostAppliedPatches(host)); } if (!Host.IsFullyPatched(host, ConnectionsManager.XenConnectionsCopy)) { CommandToolStripMenuItem applypatch = new CommandToolStripMenuItem( new InstallNewUpdateCommand(Program.MainWindow.CommandInterface), true); List<ToolStripMenuItem> menuItems = new List<ToolStripMenuItem>(); menuItems.Add(applypatch); s.AddEntry(FriendlyName("Pool_patch.not_applied"), hostUnappliedPatches(host), menuItems, Color.Red); } }
protected override void OnDropDownOpening(EventArgs e) { base.DropDownItems.Clear(); SelectedItemCollection selection = Command.GetSelection(); IXenConnection connection = selection[0].Connection; // Add a menu item for each connection we might add to this pool foreach (Host host in GetSortedHostList()) { string hostName = Helpers.GetName(host.Connection); if (host.RestrictPooling) { hostName = String.Format(Messages.HOST_MENU_ADD_SERVER, hostName); } AddHostToPoolCommand cmd = new AddHostToPoolCommand(Command.MainWindowCommandInterface, new Host[] { host }, Helpers.GetPool(connection), true); CommandToolStripMenuItem hostMenuItem = new CommandToolStripMenuItem(cmd, hostName.EscapeAmpersands(), Images.StaticImages._000_TreeConnected_h32bit_16); base.DropDownItems.Add(hostMenuItem); } if (Helpers.GetPool(connection) != null) { if (base.DropDownItems.Count > 0) base.DropDownItems.Add(new ToolStripSeparator()); // Add a final option for connecting a new server and adding it to the pool in one action AddNewHostToPoolCommand cmd = new AddNewHostToPoolCommand(Command.MainWindowCommandInterface, Helpers.GetPool(connection)); CommandToolStripMenuItem connectAndAddToPoolMenuItem = new CommandToolStripMenuItem(cmd); base.DropDownItems.Add(connectAndAddToPoolMenuItem); } }