use of org.ovirt.engine.ui.uicommonweb.models.vms.CustomInstanceType in project ovirt-engine by oVirt.
the class ExistingPoolInstanceTypeManager method getSource.
@Override
protected VmBase getSource() {
boolean customInstanceTypeUsed = getModel().getInstanceTypes() != null && getModel().getInstanceTypes().getSelectedItem() instanceof CustomInstanceType;
if (!customInstanceTypeUsed) {
return (VmBase) getModel().getInstanceTypes().getSelectedItem();
}
if (getModel().getTemplateWithVersion() == null || getModel().getTemplateWithVersion().getSelectedItem() == null || getModel().getTemplateWithVersion().getSelectedItem().getTemplateVersion() == null) {
return pool.getStaticData();
}
VmTemplate template = getModel().getTemplateWithVersion().getSelectedItem().getTemplateVersion();
boolean isLatestPropertyChanged = pool.isUseLatestVersion() != (template instanceof LatestVmTemplate);
// template ID changed but latest is not set, as it would cause false-positives
boolean isTemplateIdChangedSinceInit = !pool.getVmtGuid().equals(template.getId()) && !pool.isUseLatestVersion();
if (isTemplateIdChangedSinceInit || isLatestPropertyChanged) {
return template;
}
return pool.getStaticData();
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.CustomInstanceType in project ovirt-engine by oVirt.
the class InstanceTypeManager method updateAll.
/**
* First updates the list of instance types and selects the one which is supposed to be selected and then
* updates all the fields which are taken from the instance type (by calling the updateFields()).
*/
public void updateAll() {
final Guid selectedInstanceTypeId = getSelectedInstanceTypeId();
Frontend.getInstance().runQuery(QueryType.GetAllInstanceTypes, new QueryParametersBase(), new AsyncQuery<QueryReturnValue>(returnValue -> {
if (returnValue == null || !returnValue.getSucceeded()) {
return;
}
List<InstanceType> instanceTypes = new ArrayList<>();
// add this only if the user is allowed to
if (!getModel().isCreateInstanceOnly()) {
instanceTypes.add(CustomInstanceType.INSTANCE);
}
for (InstanceType instanceType : (Iterable<InstanceType>) returnValue.getReturnValue()) {
instanceTypes.add(instanceType);
}
getModel().getInstanceTypes().setItems(instanceTypes);
for (InstanceType instanceType : instanceTypes) {
if ((instanceType instanceof CustomInstanceType) && selectedInstanceTypeId == null) {
getModel().getInstanceTypes().setSelectedItem(CustomInstanceType.INSTANCE);
break;
}
if (instanceType.getId() == null || selectedInstanceTypeId == null) {
continue;
}
if (instanceType.getId().equals(selectedInstanceTypeId)) {
getModel().getInstanceTypes().setSelectedItem(instanceType);
break;
}
}
if (getModel().getInstanceTypes().getSelectedItem() instanceof CustomInstanceType) {
// detach if the instance type is "custom"
getModel().getAttachedToInstanceType().setEntity(false);
}
updateFields();
}));
}
Aggregations