use of org.ovirt.engine.ui.frontend.AsyncCallback in project ovirt-engine by oVirt.
the class ClusterModel method storagePool_SelectedItemChanged.
private void storagePool_SelectedItemChanged() {
// possible versions for new cluster (when editing cluster, this event won't occur)
// are actually the possible versions for the data-center that the cluster is going
// to be attached to.
final StoragePool selectedDataCenter = getDataCenter().getSelectedItem();
if (selectedDataCenter == null) {
getManagementNetwork().setItems(Collections.emptyList());
return;
}
if (selectedDataCenter.isLocal()) {
setMigrationTabAvailable(false);
} else {
setMigrationTabAvailable(true);
}
AsyncDataProvider.getInstance().getDataCenterVersions(new AsyncQuery<>(new AsyncCallback<List<Version>>() {
@Override
public void onSuccess(List<Version> versions) {
Version versionToSelect = calculateNewVersionWhichShouldBeSelected(versions);
getVersion().setItems(versions, versionToSelect);
}
private Version calculateNewVersionWhichShouldBeSelected(List<Version> versions) {
ListModel<Version> version = getVersion();
Version selectedVersion = version.getSelectedItem();
if (!getIsEdit() && (selectedVersion == null || !versions.contains(selectedVersion) || selectedVersion.compareTo(selectedDataCenter.getCompatibilityVersion()) > 0)) {
if (ApplicationModeHelper.getUiMode().equals(ApplicationMode.GlusterOnly)) {
return versions.stream().max(Comparator.naturalOrder()).orElse(null);
} else {
return selectedDataCenter.getCompatibilityVersion();
}
} else if (getIsEdit()) {
return Linq.firstOrNull(versions, x -> x.equals(getEntity().getCompatibilityVersion()));
} else {
return selectedVersion;
}
}
}), ApplicationModeHelper.getUiMode().equals(ApplicationMode.GlusterOnly) ? null : selectedDataCenter.getId());
if (getManagementNetwork().getIsChangable()) {
loadDcNetworks(selectedDataCenter.getId());
}
}
use of org.ovirt.engine.ui.frontend.AsyncCallback in project ovirt-engine by oVirt.
the class BookmarkListModel method syncSearch.
@Override
protected void syncSearch() {
super.syncSearch();
Frontend.getInstance().runQuery(QueryType.GetAllBookmarks, new QueryParametersBase(), new AsyncQuery<>((AsyncCallback<QueryReturnValue>) returnValue -> {
List<Bookmark> resultList = returnValue.getReturnValue();
if (resultList != null) {
Collections.sort(resultList, COMPARATOR);
}
setIsBookmarkInitiated(true);
setItems(resultList);
setIsBookmarkInitiated(false);
}));
}
use of org.ovirt.engine.ui.frontend.AsyncCallback in project ovirt-engine by oVirt.
the class ProviderModel method updateDatacentersForExternalProvider.
protected void updateDatacentersForExternalProvider() {
AsyncDataProvider.getInstance().getDataCenterList(new AsyncQuery<>(new AsyncCallback<List<StoragePool>>() {
@Override
public void onSuccess(List<StoragePool> dataCenters) {
StoragePool prevDataCenter = getPreviousDataCenter(dataCenters);
Collections.sort(dataCenters, new NameableComparator());
// any data center
dataCenters.add(0, null);
getDataCenter().setItems(dataCenters);
getDataCenter().setSelectedItem(prevDataCenter);
if (getDataCenter().getSelectedItem() == null) {
getProxyHostPropertiesModel().disableProxyHost();
}
}
private StoragePool getPreviousDataCenter(List<StoragePool> dataCenters) {
Guid previousDataCenterId = getProxyHostPropertiesModel().getLastStoragePoolId();
for (StoragePool dataCenter : dataCenters) {
if (dataCenter.getId().equals(previousDataCenterId)) {
return dataCenter;
}
}
return null;
}
}));
}
use of org.ovirt.engine.ui.frontend.AsyncCallback in project ovirt-engine by oVirt.
the class VmListModel method updateVM.
@Override
protected void updateVM(final UnitVmModel model) {
final VM selectedItem = getSelectedItem();
// explicitly pass non-editable field from the original VM
getcurrentVm().setCreatedByUserId(selectedItem.getCreatedByUserId());
getcurrentVm().setUseLatestVersion(model.getTemplateWithVersion().getSelectedItem().isLatest());
if (selectedItem.isRunningOrPaused() && !selectedItem.isHostedEngine()) {
AsyncDataProvider.getInstance().getVmChangedFieldsForNextRun(editedVm, getcurrentVm(), getUpdateVmParameters(false), new AsyncQuery<>(new AsyncCallback<QueryReturnValue>() {
@Override
public void onSuccess(QueryReturnValue returnValue) {
List<String> changedFields = returnValue.getReturnValue();
final boolean cpuHotPluggable = VmCommonUtils.isCpusToBeHotpluggedOrUnplugged(selectedItem, getcurrentVm());
final boolean isHeadlessModeChanged = isHeadlessModeChanged(editedVm, getUpdateVmParameters(false));
final boolean memoryHotPluggable = VmCommonUtils.isMemoryToBeHotplugged(selectedItem, getcurrentVm());
final boolean minAllocatedMemoryChanged = selectedItem.getMinAllocatedMem() != getcurrentVm().getMinAllocatedMem();
final boolean vmLeaseUpdated = VmCommonUtils.isVmLeaseToBeHotPluggedOrUnplugged(selectedItem, getcurrentVm());
if (isHeadlessModeChanged) {
changedFields.add(constants.headlessMode());
}
// provide warnings if isVmUnpinned()
if (!changedFields.isEmpty() || isVmUnpinned() || memoryHotPluggable || cpuHotPluggable || vmLeaseUpdated) {
VmNextRunConfigurationModel confirmModel = new VmNextRunConfigurationModel();
if (isVmUnpinned()) {
confirmModel.setVmUnpinned();
}
confirmModel.setTitle(ConstantsManager.getInstance().getConstants().editNextRunConfigurationTitle());
confirmModel.setHelpTag(HelpTag.edit_next_run_configuration);
// $NON-NLS-1$
confirmModel.setHashName("edit_next_run_configuration");
confirmModel.setChangedFields(changedFields);
confirmModel.setCpuPluggable(cpuHotPluggable);
confirmModel.setMemoryPluggable(memoryHotPluggable);
// it can be plugged only together with the memory, never alone
confirmModel.setMinAllocatedMemoryPluggable(memoryHotPluggable && minAllocatedMemoryChanged);
confirmModel.setVmLeaseUpdated(vmLeaseUpdated);
confirmModel.getCommands().add(// $NON-NLS-1$
new UICommand("updateExistingVm", VmListModel.this).setTitle(ConstantsManager.getInstance().getConstants().ok()).setIsDefault(true));
// $NON-NLS-1$
confirmModel.getCommands().add(UICommand.createCancelUiCommand("CancelConfirmation", VmListModel.this));
setConfirmWindow(confirmModel);
} else {
updateExistingVm(false);
}
}
private boolean isVmUnpinned() {
if (selectedItem.isRunning()) {
if (selectedItem.getMigrationSupport() == MigrationSupport.PINNED_TO_HOST && getcurrentVm().getMigrationSupport() != MigrationSupport.PINNED_TO_HOST) {
return true;
}
}
return false;
}
}));
} else {
updateExistingVm(false);
}
}
use of org.ovirt.engine.ui.frontend.AsyncCallback in project ovirt-engine by oVirt.
the class VmBaseListModel method postShowWarningOnExistingVms.
private void postShowWarningOnExistingVms(final ExportVmModel exportModel, List<StoragePool> storagePools, QueryType getVmOrTemplateQuery) {
StoragePool storagePool = storagePools.size() > 0 ? storagePools.get(0) : null;
if (storagePool != null) {
Guid storageDomainId = exportModel.getStorage().getSelectedItem().getId();
GetAllFromExportDomainQueryParameters tempVar = new GetAllFromExportDomainQueryParameters(storagePool.getId(), storageDomainId);
Frontend.getInstance().runQuery(getVmOrTemplateQuery, tempVar, new AsyncQuery<>((AsyncCallback<QueryReturnValue>) returnValue -> {
ExportVmModel windowModel = (ExportVmModel) getWindow();
List<T> foundVms = new ArrayList<>();
if (returnValue != null) {
Iterable<T> iterableReturnValue = asIterableReturnValue(returnValue.getReturnValue());
for (T selectedItem1 : getSelectedItems()) {
for (T returnValueItem : iterableReturnValue) {
if (entititesEqualsNullSafe(returnValueItem, selectedItem1)) {
foundVms.add(selectedItem1);
break;
}
}
}
}
if (foundVms.size() != 0) {
windowModel.setMessage(composeEntityOnStorage(composeExistingVmsWarningMessage(foundVms)));
}
exportModel.stopProgress();
}));
} else {
exportModel.stopProgress();
}
}
Aggregations