use of org.ovirt.engine.ui.uicompat.Translator in project ovirt-engine by oVirt.
the class VolumeTransportTypeRenderer method render.
@Override
public String render(Set<TransportType> transportTypes) {
Translator transportTypeTranslator = EnumTranslator.getInstance();
StringBuilder transportTypesBuilder = new StringBuilder();
Iterator<TransportType> iterator = transportTypes.iterator();
while (iterator.hasNext()) {
TransportType transportType = iterator.next();
transportTypesBuilder.append(transportTypeTranslator.translate(transportType));
if (iterator.hasNext()) {
// $NON-NLS-1$
transportTypesBuilder.append(", ");
}
}
return transportTypesBuilder.toString();
}
use of org.ovirt.engine.ui.uicompat.Translator in project ovirt-engine by oVirt.
the class TemplateGeneralModel method updateProperties.
private void updateProperties() {
VmTemplate template = getEntity();
super.updateProperties(template.getId());
setName(template.getName());
setTemplateId(template.getId().toString());
setDescription(template.getDescription());
// $NON-NLS-1$
setQuotaName(template.getQuotaName() != null ? template.getQuotaName() : "");
setQuotaAvailable(template.getQuotaEnforcementType() != null && !template.getQuotaEnforcementType().equals(QuotaEnforcementTypeEnum.DISABLED));
setHostCluster(template.getClusterName());
// $NON-NLS-1$
setDefinedMemory(template.getMemSizeMb() + " MB");
setIsHighlyAvailable(template.isAutoStartup());
setPriority(AsyncDataProvider.getInstance().priorityToString(template.getPriority()));
setMonitorCount(template.getNumOfMonitors());
setAllowConsoleReconnect(template.isAllowConsoleReconnect());
setCpuInfo(ConstantsManager.getInstance().getMessages().cpuInfoLabel(template.getNumOfCpus(), template.getNumOfSockets(), template.getCpuPerSocket(), template.getThreadsPerCpu()));
setOS(AsyncDataProvider.getInstance().getOsName(template.getOsId()));
Translator translator = EnumTranslator.getInstance();
setOptimizedForSystemProfile(translator.translate(template.getVmType()));
setDefaultDisplayType(translator.translate(template.getDefaultDisplayType()));
setOrigin(translator.translate(template.getOrigin()));
setHasDomain(AsyncDataProvider.getInstance().isWindowsOsType(template.getOsId()));
if (template.getVmInit() != null) {
setDomain(template.getVmInit().getDomain());
}
setHasTimeZone(AsyncDataProvider.getInstance().isWindowsOsType(template.getOsId()));
setTimeZone(template.getTimeZone());
setHasUsbPolicy(true);
setUsbPolicy(translator.translate(template.getUsbPolicy()));
setIsStateless(template.isStateless());
}
use of org.ovirt.engine.ui.uicompat.Translator in project ovirt-engine by oVirt.
the class PoolGeneralModel method updateProperties.
private void updateProperties() {
final VmPool pool = getEntity();
setName(pool.getName());
setDescription(pool.getVmPoolDescription());
Frontend.getInstance().runQuery(QueryType.GetVmDataByPoolId, new IdQueryParameters(pool.getVmPoolId()), new AsyncQuery<>(new AsyncCallback<QueryReturnValue>() {
@Override
public void onSuccess(QueryReturnValue result) {
// refactor to "switch ... case...".
if (result != null) {
setvm((VM) result.getReturnValue());
}
if (getvm() != null) {
setTemplate(vmTemplateNameRenderer.render(getvm()));
setCpuInfo(ConstantsManager.getInstance().getMessages().cpuInfoLabel(getvm().getNumOfCpus(), getvm().getNumOfSockets(), getvm().getCpuPerSocket(), getvm().getThreadsPerCpu()));
setMonitorCount(getvm().getNumOfMonitors());
setOS(getvm().getVmOsId());
// $NON-NLS-1$
setDefinedMemory(getvm().getVmMemSizeMb() + " MB");
// $NON-NLS-1$
setMinAllocatedMemory(getvm().getMinAllocatedMem() + " MB");
Translator translator = EnumTranslator.getInstance();
setDefaultDisplayType(translator.translate(getvm().getDefaultDisplayType()));
setOrigin(translator.translate(getvm().getOrigin()));
setUsbPolicy(translator.translate(getvm().getUsbPolicy()));
setHasDomain(AsyncDataProvider.getInstance().isWindowsOsType(getvm().getVmOsId()));
setOptimizedForSystemProfile(translator.translate(getvm().getVmType()));
setHasTimeZone(AsyncDataProvider.getInstance().isWindowsOsType(getvm().getVmOsId()));
setTimeZone(getvm().getTimeZone());
setIsStateless(!pool.isStateful());
setQuotaName(getvm().getQuotaName());
setHasDefaultHost(getvm().getDedicatedVmForVdsList().size() > 0);
if (getHasDefaultHost()) {
Frontend.getInstance().runQuery(QueryType.Search, new SearchParameters(// $NON-NLS-1$
"Host: cluster = " + getvm().getClusterName() + " sortby name", SearchType.VDS), new AsyncQuery<QueryReturnValue>(returnValue1 -> {
// $NON-NLS-1$
String defaultHost1 = "";
ArrayList<VDS> hosts = returnValue1.getReturnValue();
for (VDS host : hosts) {
if (getvm().getDedicatedVmForVdsList().contains(host.getId())) {
if (defaultHost1.isEmpty()) {
defaultHost1 = host.getName();
} else {
// $NON-NLS-1$
defaultHost1 += ", " + host.getName();
}
}
}
setDefaultHost(defaultHost1);
}));
} else {
setDefaultHost(ConstantsManager.getInstance().getConstants().anyHostInCluster());
}
if (getvm() != null) {
PoolGeneralModel.super.updateProperties(getvm().getId());
}
} else {
setTemplate(null);
setCpuCount(0);
setMonitorCount(0);
setOS(0);
setDefinedMemory(null);
setMinAllocatedMemory(null);
setDefaultDisplayType(null);
setHasDomain(false);
setDomain(null);
setHasTimeZone(false);
setTimeZone(null);
setUsbPolicy(null);
setDefaultHost(null);
setIsStateless(!pool.isStateful());
// $NON-NLS-1$
setGraphicsType("");
// $NON-NLS-1$
setOptimizedForSystemProfile("");
getUpdateCompleteEvent().raise(this, EventArgs.EMPTY);
}
}
}));
}
use of org.ovirt.engine.ui.uicompat.Translator in project ovirt-engine by oVirt.
the class UserEventNotifierListModel method manageEvents.
public void manageEvents() {
EventNotificationModel model = new EventNotificationModel();
setWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().addEventNotificationTitle());
model.setHelpTag(HelpTag.add_event_notification);
// $NON-NLS-1$
model.setHashName("add_event_notification");
ArrayList<EventNotificationEntity> eventTypes = ApplicationModeHelper.getModeSpecificEventNotificationTypeList();
Map<EventNotificationEntity, HashSet<AuditLogType>> availableEvents = AsyncDataProvider.getInstance().getAvailableNotificationEvents();
Translator translator = EnumTranslator.getInstance();
ArrayList<SelectionTreeNodeModel> list = new ArrayList<>();
Collection<EventSubscriber> items = getItems() == null ? new ArrayList<EventSubscriber>() : getItems();
for (EventNotificationEntity eventType : eventTypes) {
SelectionTreeNodeModel stnm = new SelectionTreeNodeModel();
stnm.setTitle(eventType.toString());
stnm.setDescription(translator.translate(eventType));
list.add(stnm);
for (AuditLogType logtype : availableEvents.get(eventType)) {
SelectionTreeNodeModel eventGrp = new SelectionTreeNodeModel();
String description;
try {
description = translator.translate(logtype);
} catch (MissingResourceException e) {
description = logtype.toString();
}
eventGrp.setTitle(logtype.toString());
eventGrp.setDescription(description);
eventGrp.setParent(list.get(list.size() - 1));
eventGrp.setIsSelectedNotificationPrevent(true);
eventGrp.setIsSelectedNullable(false);
for (EventSubscriber es : items) {
if (es.getEventUpName().equals(logtype.toString())) {
eventGrp.setIsSelectedNullable(true);
break;
}
}
list.get(list.size() - 1).getChildren().add(eventGrp);
eventGrp.setIsSelectedNotificationPrevent(false);
}
if (list.get(list.size() - 1).getChildren().size() > 0) {
list.get(list.size() - 1).getChildren().get(0).updateParentSelection();
}
}
model.setEventGroupModels(list);
if (!StringHelper.isNullOrEmpty(getEntity().getEmail())) {
model.getEmail().setEntity(getEntity().getEmail());
} else if (items.size() > 0) {
model.getEmail().setEntity(items.iterator().next().getMethodAddress());
}
model.setOldEmail(model.getEmail().getEntity());
// $NON-NLS-1$
UICommand tempVar = UICommand.createDefaultOkUiCommand("OnSave", this);
model.getCommands().add(tempVar);
// $NON-NLS-1$
UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
model.getCommands().add(tempVar2);
}
Aggregations