use of org.ovirt.engine.ui.frontend.AsyncQuery in project ovirt-engine by oVirt.
the class VmModelBehaviorBase method updateCompatibilityVersion.
/*
* Updates the custom compatibility version combo box options on init/DC-change
*/
protected void updateCompatibilityVersion() {
DataCenterWithCluster dataCenterWithCluster = getModel().getDataCenterWithClustersList().getSelectedItem();
if (dataCenterWithCluster == null) {
return;
}
final StoragePool dataCenter = dataCenterWithCluster.getDataCenter();
if (dataCenter == null) {
return;
}
AsyncDataProvider.getInstance().getDataCenterVersions(new AsyncQuery<>(versions -> {
versions.add(0, null);
Version selectedVersion;
selectedVersion = getModel().getCustomCompatibilityVersion().getSelectedItem();
if (selectedVersion != null && versions.contains(selectedVersion)) {
getModel().getCustomCompatibilityVersion().setItems(versions, selectedVersion);
} else {
getModel().getCustomCompatibilityVersion().setItems(versions);
}
}), dataCenter.getId());
}
use of org.ovirt.engine.ui.frontend.AsyncQuery in project ovirt-engine by oVirt.
the class VmModelBehaviorBase method updateDefaultHost.
protected void updateDefaultHost() {
Cluster cluster = getModel().getSelectedCluster();
if (cluster == null) {
getModel().getDefaultHost().setItems(new ArrayList<>());
getModel().getDefaultHost().setSelectedItems(new ArrayList<>());
return;
}
getHostListByCluster(cluster, asyncQuery(hosts -> {
List<VDS> oldDefaultHosts = getModel().getDefaultHost().getSelectedItems();
getModel().getDefaultHost().setItems(hosts);
// attempt to preserve selection as much as possible
if (oldDefaultHosts != null && !oldDefaultHosts.isEmpty()) {
Set<VDS> oldSelectedIntersectionNewHosts = new HashSet<>(oldDefaultHosts);
oldSelectedIntersectionNewHosts.retainAll(hosts);
oldDefaultHosts = new ArrayList<>(oldSelectedIntersectionNewHosts);
}
List<VDS> hostsToSelect = oldDefaultHosts != null && !oldDefaultHosts.isEmpty() ? oldDefaultHosts : !hosts.isEmpty() ? Collections.singletonList(hosts.get(0)) : Collections.emptyList();
getModel().getDefaultHost().setSelectedItems(hostsToSelect);
changeDefaultHost();
}));
}
use of org.ovirt.engine.ui.frontend.AsyncQuery in project ovirt-engine by oVirt.
the class VmModelBehaviorBase method updateEmulatedMachines.
/*
* Updates the emulated machine combobox after a cluster change occurs
*/
protected void updateEmulatedMachines() {
Cluster cluster = getModel().getSelectedCluster();
if (cluster == null) {
return;
}
AsyncDataProvider.getInstance().getEmulatedMachinesByClusterID(new AsyncQuery<>(returnValue -> {
if (returnValue != null) {
Set<String> emulatedSet = new TreeSet<>(returnValue);
// $NON-NLS-1$
emulatedSet.add("");
String oldVal = getModel().getEmulatedMachine().getSelectedItem();
getModel().getEmulatedMachine().setItems(emulatedSet);
getModel().getEmulatedMachine().setSelectedItem(oldVal);
}
}), cluster.getId());
}
use of org.ovirt.engine.ui.frontend.AsyncQuery in project ovirt-engine by oVirt.
the class VmModelBehaviorBase method setupTemplateWithVersion.
protected void setupTemplateWithVersion(final Guid templateId, final boolean useLatest, final boolean isVersionChangeable) {
AsyncDataProvider.getInstance().getTemplateById(new AsyncQuery<>(rawTemplate -> {
if (isVersionChangeable) {
// only used by pools therefore query is limited to admin-portal permissions.
AsyncDataProvider.getInstance().getVmTemplatesByBaseTemplateId(new AsyncQuery<>(templatesChain -> initTemplateWithVersion(templatesChain, templateId, useLatest)), rawTemplate.getBaseTemplateId());
} else {
final VmTemplate template = useLatest ? new LatestVmTemplate(rawTemplate) : rawTemplate;
if (template.isBaseTemplate()) {
TemplateWithVersion templateCouple = new TemplateWithVersion(template, template);
setReadOnlyTemplateWithVersion(templateCouple);
} else {
AsyncDataProvider.getInstance().getTemplateById(new AsyncQuery<>(baseTemplate -> {
TemplateWithVersion templateCouple = new TemplateWithVersion(baseTemplate, template);
setReadOnlyTemplateWithVersion(templateCouple);
}), template.getBaseTemplateId());
}
}
}), templateId);
}
use of org.ovirt.engine.ui.frontend.AsyncQuery in project ovirt-engine by oVirt.
the class ExistingNonClusterModelBehavior method initialize.
@Override
public void initialize() {
super.initialize();
updateNumOfSockets();
getModel().getUsbPolicy().setItems(Arrays.asList(UsbPolicy.values()));
getModel().getIsSoundcardEnabled().setIsChangeable(true);
Frontend.getInstance().runQuery(QueryType.GetGraphicsDevices, new IdQueryParameters(entity.getId()), new AsyncQuery<QueryReturnValue>(returnValue -> {
List<GraphicsDevice> graphicsDevices = returnValue.getReturnValue();
Set<GraphicsType> graphicsTypesCollection = new HashSet<>();
for (GraphicsDevice graphicsDevice : graphicsDevices) {
graphicsTypesCollection.add(graphicsDevice.getGraphicsType());
}
initDisplayTypes(entity.getDefaultDisplayType(), UnitVmModel.GraphicsTypes.fromGraphicsTypes(graphicsTypesCollection));
doBuild();
}));
initSoundCard(entity.getId());
updateConsoleDevice(entity.getId());
initPriority(entity.getPriority());
Frontend.getInstance().runQuery(QueryType.IsBalloonEnabled, new IdQueryParameters(entity.getId()), new AsyncQuery<QueryReturnValue>(returnValue -> getModel().getMemoryBalloonDeviceEnabled().setEntity((Boolean) returnValue.getReturnValue())));
getInstance().isVirtioScsiEnabledForVm(new AsyncQuery<>(returnValue -> getModel().getIsVirtioScsiEnabled().setEntity(returnValue)), entity.getId());
getInstance().getWatchdogByVmId(new AsyncQuery<QueryReturnValue>(returnValue -> {
@SuppressWarnings("unchecked") Collection<VmWatchdog> watchdogs = returnValue.getReturnValue();
for (VmWatchdog watchdog : watchdogs) {
getModel().getWatchdogAction().setSelectedItem(watchdog.getAction());
getModel().getWatchdogModel().setSelectedItem(watchdog.getModel());
}
}), entity.getId());
Frontend.getInstance().runQuery(QueryType.GetRngDevice, new IdQueryParameters(entity.getId()), new AsyncQuery<QueryReturnValue>(returnValue -> {
List<VmDevice> rngDevices = returnValue.getReturnValue();
getModel().getIsRngEnabled().setEntity(!rngDevices.isEmpty());
if (!rngDevices.isEmpty()) {
VmRngDevice rngDevice = new VmRngDevice(rngDevices.get(0));
getModel().setRngDevice(rngDevice);
}
}));
getModel().getEmulatedMachine().setSelectedItem(entity.getCustomEmulatedMachine());
getModel().getCustomCpu().setSelectedItem(entity.getCustomCpuName());
getModel().getMigrationMode().setSelectedItem(entity.getMigrationSupport());
getModel().getCpuSharesAmount().setEntity(entity.getCpuShares());
getModel().getIsHighlyAvailable().setEntity(entity.isAutoStartup());
updateCpuSharesSelection();
}
Aggregations