Source:
private void onSaveConfirmCpuLevel() { ClusterModel model = (ClusterModel) getWindow(); cancelConfirmation(); ServerCpu vdsCpu = getVdsGroupServerCpu(model, getSelectedItem()); if (vdsCpu != null && model.getCPU().getSelectedItem().getLevel() < vdsCpu.getLevel()) { AsyncQuery _asyncQuery = new AsyncQuery(); _asyncQuery.setModel(model); _asyncQuery.asyncCallback = new INewAsyncCallback() { @Override public void onSuccess(Object model, Object result) { ClusterModel clusterModel = (ClusterModel) model; final Map<String, String> highCpuVms = (Map<String, String>)result; AsyncQuery _asyncQuery = new AsyncQuery(); _asyncQuery.setModel(clusterModel); _asyncQuery.asyncCallback = new INewAsyncCallback() { @Override public void onSuccess(Object model, Object result) { Integer activeVms = (Integer) result; StringBuilder message = new StringBuilder(); if (!highCpuVms.isEmpty()) { message.append(ConstantsManager.getInstance() .getConstants() .changeCpuLevelCustomVmCpusMessage()); for (Map.Entry<String, String> highCpu : highCpuVms.entrySet()) { message.append("* \""); message.append(highCpu.getKey()); message.append("\" - "); message.append(highCpu.getValue()); message.append(" CPU\n"); } } if (activeVms > 0) { message.append(ConstantsManager.getInstance() .getConstants() .changeCpuLevelWhileRunningMessage()); } if (message.length() == 0) { onSaveInternal(); } else { message.append(ConstantsManager.getInstance() .getConstants() .changeCpuLevelWarningMessage()); cpuLevelConfirmationWindow(message.toString()); } } }; AsyncDataProvider.getInstance() .getNumberOfActiveVmsInCluster(_asyncQuery, getSelectedItem().getId()); } }; AsyncDataProvider.getInstance().verifyClusterSupportsVmCpu(_asyncQuery, getSelectedItem().getId(), model.getCPU().getSelectedItem().getCpuName()); } else { onSaveInternal(); } }

Target:
private void onSaveConfirmCpuLevel() { ClusterModel model = (ClusterModel) getWindow(); cancelConfirmation(); ServerCpu vdsCpu = getVdsGroupServerCpu(model, getSelectedItem()); if (vdsCpu != null && model.getCPU().getSelectedItem().getLevel() < vdsCpu.getLevel()) { getWindow().startProgress(null); AsyncQuery _asyncQuery = new AsyncQuery(); _asyncQuery.setModel(model); _asyncQuery.asyncCallback = new INewAsyncCallback() { @Override public void onSuccess(Object model, Object result) { ClusterModel clusterModel = (ClusterModel) model; final Map<String, String> highCpuVms = (Map<String, String>)result; AsyncQuery _asyncQuery = new AsyncQuery(); _asyncQuery.setModel(clusterModel); _asyncQuery.asyncCallback = new INewAsyncCallback() { @Override public void onSuccess(Object model, Object result) { Integer activeVms = (Integer) result; StringBuilder message = new StringBuilder(); if (!highCpuVms.isEmpty()) { message.append(ConstantsManager.getInstance() .getConstants() .changeCpuLevelCustomVmCpusMessage()); for (Map.Entry<String, String> highCpu : highCpuVms.entrySet()) { message.append("* \""); message.append(highCpu.getKey()); message.append("\" - "); message.append(highCpu.getValue()); message.append(" CPU\n"); } } if (activeVms > 0) { message.append(ConstantsManager.getInstance() .getConstants() .changeCpuLevelWhileRunningMessage()); } getWindow().stopProgress(); if (message.length() == 0) { onSaveInternal(); } else { message.append(ConstantsManager.getInstance() .getConstants() .changeCpuLevelWarningMessage()); cpuLevelConfirmationWindow(message.toString()); } } }; AsyncDataProvider.getInstance() .getNumberOfActiveVmsInCluster(_asyncQuery, getSelectedItem().getId()); } }; AsyncDataProvider.getInstance().getClusterUnsupportedVmsCpus(_asyncQuery, getSelectedItem().getId(), model.getCPU().getSelectedItem().getCpuName()); } else { onSaveInternal(); } }