public override bool IsValid(SelectedItemCollection selection) { return(selection.AllItemsAre <GroupingTag>(IsValid) && selection.Count > 1); }
/// <summary> /// Initializes a new instance of the <see cref="Command"/> class. /// </summary> /// <param name="mainWindow">The application main window.</param> /// <param name="selection">The selection context for the Command.</param> protected Command(IMainWindow mainWindow, IEnumerable <SelectedItem> selection) : this(mainWindow) { Util.ThrowIfParameterNull(selection, "selection"); _selection = new SelectedItemCollection(selection); }
protected override bool CanExecuteCore(SelectedItemCollection selection) { return(selection.AllItemsAre <Host>() && selection.AtLeastOneXenObjectCan <Host>(CanExecute)); }
protected sealed override void ExecuteCore(SelectedItemCollection selection) { //It only supports one item selected for now Trace.Assert(selection.Count == 1); XenAPI.Network network = (XenAPI.Network)selection.FirstAsXenObject; List <PIF> pifs = network.Connection.ResolveAll(network.PIFs); if (pifs.Count == 0) { // Should never happen as long as the caller is enabling the button correctly, but // it's possible in a tiny window across disconnecting. log.Error("Network has no PIFs"); return; } // We just want one, so that we can name it. PIF pif = pifs[0]; string msg = string.Format(Messages.DELETE_BOND_MESSAGE, pif.Name); bool will_disturb_primary = NetworkingHelper.ContainsPrimaryManagement(pifs); bool will_disturb_secondary = NetworkingHelper.ContainsSecondaryManagement(pifs); if (will_disturb_primary) { Pool pool = Helpers.GetPool(network.Connection); if (pool != null && pool.ha_enabled) { using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, string.Format(Messages.BOND_DELETE_HA_ENABLED, pif.Name, pool.Name), Messages.DELETE_BOND))) { dlg.ShowDialog(Parent); } return; } string message = string.Format(will_disturb_secondary ? Messages.BOND_DELETE_WILL_DISTURB_BOTH : Messages.BOND_DELETE_WILL_DISTURB_PRIMARY, msg); DialogResult result; using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, message, Messages.DELETE_BOND), "NetworkingConfigWarning", new ThreeButtonDialog.TBDButton(Messages.BOND_DELETE_CONTINUE, DialogResult.OK), ThreeButtonDialog.ButtonCancel)) { result = dlg.ShowDialog(Parent); } if (DialogResult.OK != result) { return; } } else if (will_disturb_secondary) { DialogResult dialogResult; using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.BOND_DELETE_WILL_DISTURB_SECONDARY, msg), Messages.XENCENTER), ThreeButtonDialog.ButtonOK, ThreeButtonDialog.ButtonCancel)) { dialogResult = dlg.ShowDialog(Parent); } if (DialogResult.OK != dialogResult) { return; } } else { DialogResult dialogResult; using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, msg, Messages.XENCENTER), new ThreeButtonDialog.TBDButton(Messages.OK, DialogResult.OK, ThreeButtonDialog.ButtonType.ACCEPT, true), ThreeButtonDialog.ButtonCancel)) { dialogResult = dlg.ShowDialog(Parent); } if (DialogResult.OK != dialogResult) { return; } } // The UI shouldn't offer deleting a bond in this case, but let's make sure we've // done the right thing and that the bond hasn't been deleted in the meantime. (CA-27436). Bond bond = pif.BondMasterOf; if (bond != null) { new Actions.DestroyBondAction(bond).RunAsync(); } }
/// <summary> /// Executes this Command. /// </summary> /// <param name="selection">The selection the Command should operate on.</param> protected virtual void ExecuteCore(SelectedItemCollection selection) { }
protected override bool CanExecuteCore(SelectedItemCollection selection) { return(new ShutDownVMCommand(MainWindowCommandInterface, selection).CanExecute() || new ShutDownHostCommand(MainWindowCommandInterface, selection).CanExecute()); }
protected override void ExecuteCore(SelectedItemCollection selection) { MainWindowCommandInterface.ShowForm(typeof(RollingUpgradeWizard)); }
public override bool IsValid(SelectedItemCollection selection) { return(selection.Count > 1 && selection.AllItemsAre <SR>()); }
public override bool IsValid(SelectedItemCollection selection) { return(selection.Count == 1 && selection[0].XenObject is VDI); }
public override void Build(IMainWindow mainWindow, SelectedItemCollection selection, ContextMenuItemCollection items) { items.AddIfEnabled(new DisconnectHostsAndPoolsCommand(mainWindow, selection), true); items.AddIfEnabled(new ReconnectHostCommand(mainWindow, selection), true); items.AddIfEnabled(new EditTagsCommand(mainWindow, selection)); }
public override void Build(IMainWindow mainWindow, SelectedItemCollection selection, ContextMenuItemCollection items) { items.AddIfEnabled(new DisconnectPoolCommand(mainWindow, selection), true); items.AddIfEnabled(new EditTagsCommand(mainWindow, selection)); items.AddPluginItems(PluginContextMenu.pool, selection); }
public abstract bool IsValid(SelectedItemCollection selection);
public abstract void Build(IMainWindow mainWindow, SelectedItemCollection selection, ContextMenuItemCollection items);
public override bool IsValid(SelectedItemCollection selection) { return(selection.AllItemsAre <DockerContainer>()); }
protected sealed override void ExecuteCore(SelectedItemCollection selection) { //It only supports one item selected for now Trace.Assert(selection.Count == 1); XenAPI.Network network = (XenAPI.Network)selection.FirstAsXenObject; List <PIF> pifs = network.Connection.ResolveAll(network.PIFs); if (pifs.Count == 0) { // Should never happen as long as the caller is enabling the button correctly, but // it's possible in a tiny window across disconnecting. log.Error("Network has no PIFs"); return; } // We just want one, so that we can name it. PIF pif = pifs[0]; string new_name; string msg; if (network != null && !Helpers.BostonOrGreater(network.Connection) && network.Connection.ResolveAll(network.VIFs).Count > 0) { // We have a live pre-Boston network. Tell the user that we're going to rename it. new_name = Helpers.MakeUniqueName(Messages.RENAMED_BOND, GetAllNetworkNames(network.Connection)); msg = string.Format(Messages.DELETE_BOND_WITH_VIFS_MESSAGE, pif.Name, new_name); } else { // It's not in use -- delete the network as well as the bonds and PIFs. new_name = null; msg = string.Format(Messages.DELETE_BOND_MESSAGE, pif.Name); } bool will_disturb_primary = NetworkingHelper.ContainsPrimaryManagement(pifs); bool will_disturb_secondary = NetworkingHelper.ContainsSecondaryManagement(pifs); if (will_disturb_primary) { Pool pool = Helpers.GetPool(network.Connection); if (pool != null && pool.ha_enabled) { new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, string.Format(Messages.BOND_DELETE_HA_ENABLED, pif.Name, pool.Name), Messages.DELETE_BOND)).ShowDialog(Parent); return; } string message = string.Format(will_disturb_secondary ? Messages.BOND_DELETE_WILL_DISTURB_BOTH : Messages.BOND_DELETE_WILL_DISTURB_PRIMARY, msg); if (DialogResult.OK != new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, message, Messages.DELETE_BOND), "NetworkingConfigWarning", new ThreeButtonDialog.TBDButton(Messages.BOND_DELETE_CONTINUE, DialogResult.OK), ThreeButtonDialog.ButtonCancel).ShowDialog(Parent)) { return; } } else if (will_disturb_secondary) { if (DialogResult.OK != new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.BOND_DELETE_WILL_DISTURB_SECONDARY, msg), Messages.XENCENTER), ThreeButtonDialog.ButtonOK, ThreeButtonDialog.ButtonCancel).ShowDialog(Parent)) { return; } } else { if (DialogResult.OK != new ThreeButtonDialog( new ThreeButtonDialog.Details(SystemIcons.Warning, msg, Messages.XENCENTER), new ThreeButtonDialog.TBDButton(Messages.OK, DialogResult.OK, ThreeButtonDialog.ButtonType.ACCEPT, true), ThreeButtonDialog.ButtonCancel).ShowDialog(Program.MainWindow)) { return; } } // The UI shouldn't offer deleting a bond in this case, but let's make sure we've // done the right thing and that the bond hasn't been deleted in the meantime. (CA-27436). Bond bond = pif.BondMasterOf; if (bond != null) { Program.MainWindow.AllowHistorySwitch = true; new Actions.DestroyBondAction(bond, new_name).RunAsync(); } }
public override void Build(IMainWindow mainWindow, SelectedItemCollection selection, ContextMenuItemCollection items) { items.Add(new PropertiesCommand(mainWindow, selection)); }
protected override void ExecuteCore(SelectedItemCollection selection) { Execute(selection.AsXenObjects <VM>()); }
public override void Build(IMainWindow mainWindow, SelectedItemCollection selection, ContextMenuItemCollection items) { items.AddIfEnabled(new DeleteVMsAndTemplatesCommand(mainWindow, selection)); items.AddIfEnabled(new EditTagsCommand(mainWindow, selection)); }
protected override void ExecuteCore(SelectedItemCollection selection) { new SrAction(SrActionKind.SetAsDefault, (SR)selection[0].XenObject).RunAsync(); }
public override void Build(IMainWindow mainWindow, SelectedItemCollection selection, ContextMenuItemCollection items) { items.AddIfEnabled(new ShutDownHostCommand(mainWindow, selection)); items.AddIfEnabled(new PowerOnHostCommand(mainWindow, selection)); items.AddIfEnabled(new RestartToolstackCommand(mainWindow, selection)); }
protected override bool CanExecuteCore(SelectedItemCollection selection) { return(selection.ContainsOneItemOfType <Host>() && selection.AtLeastOneXenObjectCan <Host>(CanExecute)); }
public override void Build(IMainWindow mainWindow, SelectedItemCollection selection, ContextMenuItemCollection items) { items.AddIfEnabled(new VappStartCommand(mainWindow, selection)); items.AddIfEnabled(new VappShutDownCommand(mainWindow, selection)); }
/// <summary> /// Determines whether this instance can execute with the current selection context. /// </summary> /// <param name="selection">The selection context.</param> /// <returns> /// <c>true</c> if this instance can execute with the specified selection; otherwise, <c>false</c>. /// </returns> protected virtual bool CanExecuteCore(SelectedItemCollection selection) { return(true); }
public override bool IsValid(SelectedItemCollection selection) { return(selection.AllItemsAre <VM_appliance>()); }
/// <summary> /// Sets the selection context for the Command. This is hidden as it is only for use by the Command framework. /// </summary> void ICommand.SetSelection(IEnumerable <SelectedItem> selection) { Util.ThrowIfParameterNull(selection, "selection"); _selection = new SelectedItemCollection(selection); }
public override bool IsValid(SelectedItemCollection selection) { return(selection.ContainsOneItemOfType <Folder>()); }
protected override void ExecuteCore(SelectedItemCollection selection) { VM snapshot = (VM)selection[0].XenObject; new NewVMCommand(MainWindowCommandInterface, snapshot.Connection, null, snapshot).Execute(); }
protected override void ExecuteCore(SelectedItemCollection selection) { var con = selection.GetConnectionOfFirstItem(); MainWindowCommandInterface.ShowPerConnectionWizard(con, new ExportApplianceWizard(con, selection)); }
protected override bool CanExecuteCore(SelectedItemCollection selection) { return(selection.Count > 0 && selection.AllItemsAre <VM>() && selection.GetConnectionOfAllItems() != null && selection.Any(CanExecute)); }
public override void Build(IMainWindow mainWindow, SelectedItemCollection selection, ContextMenuItemCollection items) { items.AddIfEnabled(new DeleteTagCommand(mainWindow, selection)); }