Source:
private void Spice_MenuItemSelected(Object sender, SpiceMenuItemEventArgs e) { if (getEntity() != null) { SpiceMenuCommandItem item = null; for (SpiceMenuItem a : menu.Descendants()) { if (a.getClass() == SpiceMenuCommandItem.class && a.getId() == e.getMenuItemId()) { item = (SpiceMenuCommandItem) a; break; } } if (item != null) { if (StringHelper.stringsEqual(item.getCommandName(), CommandPlay)) { boolean reinitialize = !getEntity().isInitialized() && AsyncDataProvider.IsWindowsOsType(getEntity().getVmOs()); RunVmParams tempVar = new RunVmParams(getEntity().getId()); tempVar.setRunAsStateless(getEntity().isStateless()); tempVar.setReinitialize(reinitialize); Frontend.RunMultipleAction(VdcActionType.RunVm, new ArrayList<VdcActionParametersBase>( Arrays.asList(new VdcActionParametersBase[] { tempVar }))); } else if (StringHelper.stringsEqual(item.getCommandName(), CommandSuspend)) { Frontend.RunMultipleAction(VdcActionType.HibernateVm, new ArrayList<VdcActionParametersBase>( Arrays.asList( new VdcActionParametersBase[] { new HibernateVmParameters(getEntity().getId()) })), null, null); } else if (StringHelper.stringsEqual(item.getCommandName(), CommandStop)) { Frontend.RunMultipleAction(VdcActionType.ShutdownVm, new ArrayList<VdcActionParametersBase>(Arrays.asList( new VdcActionParametersBase[] { new ShutdownVmParameters(getEntity().getId(), true) }))); } else if (StringHelper.stringsEqual(item.getCommandName(), CommandChangeCD)) { Frontend.RunMultipleAction(VdcActionType.ChangeDisk, new ArrayList<VdcActionParametersBase>(Arrays.asList( new VdcActionParametersBase[] { new ChangeDiskCommandParameters(getEntity().getId(), StringHelper.stringsEqual(item.getText(), EjectLabel) ? "" : item.getText()) }))); } } } }

Target:
private void Spice_MenuItemSelected(Object sender, SpiceMenuItemEventArgs e) { if (getEntity() != null) { SpiceMenuCommandItem item = null; for (SpiceMenuItem a : menu.Descendants()) { if (a.getClass() == SpiceMenuCommandItem.class && a.getId() == e.getMenuItemId()) { item = (SpiceMenuCommandItem) a; break; } } if (item != null) { if (StringHelper.stringsEqual(item.getCommandName(), CommandPlay)) { boolean reinitialize = !getEntity().isInitialized() && AsyncDataProvider.IsWindowsOsType(getEntity().getVmOs()); RunVmParams tempVar = new RunVmParams(getEntity().getId()); tempVar.setRunAsStateless(getEntity().isStateless()); tempVar.setReinitialize(reinitialize); Frontend.RunMultipleAction(VdcActionType.RunVm, new ArrayList<VdcActionParametersBase>( Arrays.asList(new VdcActionParametersBase[] { tempVar })), null, null); } else if (StringHelper.stringsEqual(item.getCommandName(), CommandSuspend)) { Frontend.RunMultipleAction(VdcActionType.HibernateVm, new ArrayList<VdcActionParametersBase>( Arrays.asList( new VdcActionParametersBase[] { new HibernateVmParameters(getEntity().getId()) })), null, null); } else if (StringHelper.stringsEqual(item.getCommandName(), CommandStop)) { Frontend.RunMultipleAction(VdcActionType.ShutdownVm, new ArrayList<VdcActionParametersBase>(Arrays.asList( new VdcActionParametersBase[] { new ShutdownVmParameters(getEntity().getId(), true) })), null, null); } else if (StringHelper.stringsEqual(item.getCommandName(), CommandChangeCD)) { Frontend.RunMultipleAction(VdcActionType.ChangeDisk, new ArrayList<VdcActionParametersBase>(Arrays.asList( new VdcActionParametersBase[] { new ChangeDiskCommandParameters(getEntity().getId(), StringHelper.stringsEqual(item.getText(), EjectLabel) ? "" : item.getText()) })), null, null); } } } }