Source:
private void updateExistingVm(UserPortalListModel userPortalListModel, final boolean applyCpuChangesLater) { final UnitVmModel model = (UnitVmModel) getWindow(); UserPortalItemModel selectedItem = (UserPortalItemModel) userPortalListModel.getSelectedItem(); Guid oldClusterID = ((VM) selectedItem.getEntity()).getVdsGroupId(); Guid newClusterID = model.getSelectedCluster().getId(); if (oldClusterID.equals(newClusterID) == false) { Frontend.getInstance().runAction(VdcActionType.ChangeVMCluster, new ChangeVMClusterParameters(newClusterID, gettempVm().getId()), new IFrontendActionAsyncCallback() { @Override public void executed(FrontendActionAsyncResult result) { VmManagementParametersBase param = new VmManagementParametersBase(gettempVm()); param.setSoundDeviceEnabled(model.getIsSoundcardEnabled().getEntity()); param.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity()); param.setApplyChangesLater(applyCpuChangesLater); Frontend.getInstance().runAction(VdcActionType.UpdateVm, param, new UnitVmModelNetworkAsyncCallback(model, defaultNetworkCreatingManager, gettempVm().getId()), this); } }, this); } else { VmManagementParametersBase param = new VmManagementParametersBase(gettempVm()); param.setSoundDeviceEnabled(model.getIsSoundcardEnabled().getEntity()); param.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity()); param.setApplyChangesLater(applyCpuChangesLater); Frontend.getInstance().runAction(VdcActionType.UpdateVm, param, new UnitVmModelNetworkAsyncCallback(model, defaultNetworkCreatingManager, gettempVm().getId()), this); } }

Target:
private void updateExistingVm(UserPortalListModel userPortalListModel, final boolean applyCpuChangesLater) { final UnitVmModel model = (UnitVmModel) getWindow(); UserPortalItemModel selectedItem = (UserPortalItemModel) userPortalListModel.getSelectedItem(); Guid oldClusterID = ((VM) selectedItem.getEntity()).getVdsGroupId(); Guid newClusterID = model.getSelectedCluster().getId(); if (oldClusterID.equals(newClusterID) == false) { Frontend.getInstance().runAction(VdcActionType.ChangeVMCluster, new ChangeVMClusterParameters(newClusterID, gettempVm().getId()), new IFrontendActionAsyncCallback() { @Override public void executed(FrontendActionAsyncResult result) { VmManagementParametersBase param = new VmManagementParametersBase(gettempVm()); param.setSoundDeviceEnabled(model.getIsSoundcardEnabled().getEntity()); param.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity()); param.setApplyChangesLater(applyCpuChangesLater); setRngDeviceToParams(model, param); Frontend.getInstance().runAction(VdcActionType.UpdateVm, param, new UnitVmModelNetworkAsyncCallback(model, defaultNetworkCreatingManager, gettempVm().getId()), this); } }, this); } else { VmManagementParametersBase param = new VmManagementParametersBase(gettempVm()); param.setSoundDeviceEnabled(model.getIsSoundcardEnabled().getEntity()); param.setConsoleEnabled(model.getIsConsoleDeviceEnabled().getEntity()); param.setApplyChangesLater(applyCpuChangesLater); setRngDeviceToParams(model, param); Frontend.getInstance().runAction(VdcActionType.UpdateVm, param, new UnitVmModelNetworkAsyncCallback(model, defaultNetworkCreatingManager, gettempVm().getId()), this); } }