use of org.ovirt.engine.ui.uicompat.EnumTranslator in project ovirt-engine by oVirt.
the class VmGeneralModel method updateProperties.
private void updateProperties() {
VM vm = getEntity();
super.updateProperties(vm.getId());
setName(vm.getName());
setDescription(vm.getVmDescription());
// $NON-NLS-1$
setQuotaName(vm.getQuotaName() != null ? vm.getQuotaName() : "");
setQuotaAvailable(vm.getQuotaEnforcementType() != null && !vm.getQuotaEnforcementType().equals(QuotaEnforcementTypeEnum.DISABLED));
setTemplate(vmTemplateNameRenderer.render(vm));
// $NON-NLS-1$
setDefinedMemory(vm.getVmMemSizeMb() + " MB");
// $NON-NLS-1$
setMinAllocatedMemory(vm.getMinAllocatedMem() + " MB");
if (vm.isRunningOrPaused() && vm.getGuestMemoryBuffered() != null && vm.getGuestMemoryCached() != null && vm.getGuestMemoryFree() != null) {
setGuestFreeCachedBufferedMemInfo(// $NON-NLS-1$
(vm.getGuestMemoryFree() / 1024L) + " / " + (vm.getGuestMemoryBuffered() / 1024L) + // $NON-NLS-1$
" / " + (vm.getGuestMemoryCached() / 1024L) + // $NON-NLS-1$
" MB");
} else {
// Handled in form
setGuestFreeCachedBufferedMemInfo(null);
}
setOS(AsyncDataProvider.getInstance().getOsName(vm.getVmOsId()));
EnumTranslator translator = EnumTranslator.getInstance();
setDefaultDisplayType(translator.translate(vm.getDefaultDisplayType()));
setOrigin(translator.translate(vm.getOrigin()));
setIsHighlyAvailable(vm.isAutoStartup());
setPriority(AsyncDataProvider.getInstance().priorityToString(vm.getPriority()));
setOptimizedForSystemProfile(translator.translate(vm.getVmType()));
setMonitorCount(vm.getNumOfMonitors());
setUsbPolicy(translator.translate(vm.getUsbPolicy()));
setCpuInfo(ConstantsManager.getInstance().getMessages().cpuInfoLabel(vm.getNumOfCpus(), vm.getNumOfSockets(), vm.getCpuPerSocket(), vm.getThreadsPerCpu()));
setGuestCpuCount(vm.getGuestCpuCount());
setHasDomain(AsyncDataProvider.getInstance().isWindowsOsType(vm.getVmOsId()));
if (vm.getVmInit() != null) {
setDomain(vm.getVmInit().getDomain());
}
setHasTimeZone(!StringHelper.isNullOrEmpty(vm.getTimeZone()));
setTimeZone(vm.getTimeZone());
setHasCustomProperties(!StringHelper.isNullOrEmpty(vm.getCustomProperties()));
setCustomProperties(getHasCustomProperties() ? constants.configured() : constants.notConfigured());
setCompatibilityVersion(vm.getCompatibilityVersion() != null ? vm.getCompatibilityVersion().toString() : // $NON-NLS-1$
"");
setVmId(vm.getId().toString());
setFqdn(vm.getFqdn());
setHasAlert(vm.getVmPauseStatus() != VmPauseStatus.NONE && vm.getVmPauseStatus() != VmPauseStatus.NOERR);
if (getHasAlert()) {
setAlert(translator.translate(vm.getVmPauseStatus()));
} else {
setAlert(null);
}
setHasCreatedByUser(vm.getCreatedByUserId() != null);
if (getHasCreatedByUser()) {
Frontend.getInstance().runQuery(QueryType.GetDbUserByUserId, new IdQueryParameters(vm.getCreatedByUserId()), new AsyncQuery<>(new AsyncCallback<QueryReturnValue>() {
@Override
public void onSuccess(QueryReturnValue result) {
DbUser dbUser = result.getReturnValue();
if (dbUser != null) {
setCreatedByUser(getUserName(dbUser));
}
}
private String getUserName(DbUser dbUser) {
if (StringHelper.isNotNullOrEmpty(dbUser.getFirstName()) || StringHelper.isNotNullOrEmpty(dbUser.getLastName())) {
return messages.userName(nullToEmpty(dbUser.getFirstName()), nullToEmpty(dbUser.getLastName()));
}
return dbUser.getLoginName();
}
private String nullToEmpty(String val) {
return val == null ? "" : val;
}
}));
}
setHasDefaultHost(vm.getDedicatedVmForVdsList().size() > 0);
if (getHasDefaultHost()) {
Frontend.getInstance().runQuery(QueryType.Search, new SearchParameters(// $NON-NLS-1$
"Host: cluster = " + vm.getClusterName() + " sortby name", SearchType.VDS).withoutRefresh(), new AsyncQuery<QueryReturnValue>(returnValue -> {
// $NON-NLS-1$
VM localVm = getEntity();
if (localVm == null) {
return;
}
ArrayList<VDS> hosts = returnValue.getReturnValue();
if (localVm.getDedicatedVmForVdsList().size() > 0) {
String defaultHost = "";
for (VDS host : hosts) {
if (localVm.getDedicatedVmForVdsList().contains(host.getId())) {
if (defaultHost.isEmpty()) {
defaultHost = host.getName();
} else {
// $NON-NLS-1$
defaultHost += ", " + host.getName();
}
}
}
setDefaultHost(defaultHost);
}
}));
} else {
setDefaultHost(ConstantsManager.getInstance().getConstants().anyHostInCluster());
}
final String guestCpuType = vm.getCpuName() != null ? vm.getCpuName() : (vm.getCustomCpuName() != null ? vm.getCustomCpuName() : vm.getClusterCpuName());
setGuestCpuType(guestCpuType);
}
use of org.ovirt.engine.ui.uicompat.EnumTranslator in project ovirt-engine by oVirt.
the class StorageGeneralModel method onEntityChanged.
@Override
protected void onEntityChanged() {
super.onEntityChanged();
if (getEntity() != null) {
StorageDomain storageDomain = getEntity();
setIsNfs(storageDomain.getStorageType() == StorageType.NFS);
setIsLocalS(storageDomain.getStorageType() == StorageType.LOCALFS);
setIsPosix(storageDomain.getStorageType() == StorageType.POSIXFS);
setIsGlusterfs(storageDomain.getStorageType() == StorageType.GLUSTERFS);
if (getIsNfs() || getIsLocalS() || getIsPosix() || getIsGlusterfs()) {
AsyncDataProvider.getInstance().getStorageConnectionById(new AsyncQuery<>(connection -> {
if (connection != null) {
setPath(connection.getConnection());
if (isNfs) {
EnumTranslator translator = EnumTranslator.getInstance();
setNfsVersion(translator.translate(connection.getNfsVersion()));
setRetransmissions(connection.getNfsRetrans());
setTimeout(connection.getNfsTimeo());
}
if (isPosix || isGlusterfs) {
setVfsType(connection.getVfsType());
setMountOptions(connection.getMountOptions());
}
} else {
setPath(null);
}
}), storageDomain.getStorage(), false);
} else {
setPath(null);
}
}
}
use of org.ovirt.engine.ui.uicompat.EnumTranslator in project ovirt-engine by oVirt.
the class VmStatusColumn method getTooltip.
@Override
public SafeHtml getTooltip(T object) {
String tooltip;
EnumTranslator translator = EnumTranslator.getInstance();
VM vm = getValue(object);
if (vm == null) {
return null;
}
// the tooltip always has at least the vm status
tooltip = getStatusTooltipText(vm.getStatus());
// optionally, the vm status icon gets an alert exclamation. Indicate why.
if (needsAlert(vm)) {
if (isUpdateNeeded(vm)) {
// $NON-NLS-1$
tooltip += "<br/><br/>" + constants.newtools();
}
if (hasPauseError(vm)) {
// $NON-NLS-1$
tooltip += "<br/><br/>" + translator.translate(vm.getVmPauseStatus());
}
if (hasIllegalImages(vm)) {
if (vm.getStatus() == VMStatus.Up) {
// $NON-NLS-1$
tooltip += "<br/><br/>" + constants.runningVmHasIllegalImages();
} else {
// $NON-NLS-1$
tooltip += "<br/><br/>" + constants.shutdownVmHasIllegalImages();
}
}
if (vm.getStatus() == VMStatus.Up) {
if (hasGuestAgent(vm)) {
if (hasDifferentTimezone(vm)) {
// $NON-NLS-1$
tooltip += "<br/><br/>" + constants.guestTimezoneDiffers();
}
if (hasDifferentOSType(vm)) {
// $NON-NLS-1$
tooltip += "<br/><br/>" + constants.guestOSDiffers();
}
} else {
// $NON-NLS-1$
tooltip += "<br/><br/>" + constants.guestAgentNotAvailable();
}
}
}
if (tooltip != null) {
return SafeHtmlUtils.fromSafeConstant(tooltip);
}
return null;
}
use of org.ovirt.engine.ui.uicompat.EnumTranslator in project ovirt-engine by oVirt.
the class SubTabVolumeGeneralView method translateVolumeType.
private void translateVolumeType(GlusterVolumeEntity volumeEntity) {
EnumTranslator translator = EnumTranslator.getInstance();
if (translator.containsKey(volumeEntity.getVolumeType())) {
String volumeType = translator.translate(volumeEntity.getVolumeType());
if (volumeEntity.getIsArbiter()) {
// $NON-NLS-1$ //$NON-NLS-2$
volumeType += " (" + ConstantsManager.getInstance().getConstants().arbiter() + ")";
}
getDetailModel().setVolumeTypeSilently(volumeType);
}
}
Aggregations