Search in sources :

Example 1 with Translator

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();
}
Also used : EnumTranslator(org.ovirt.engine.ui.uicompat.EnumTranslator) Translator(org.ovirt.engine.ui.uicompat.Translator) TransportType(org.ovirt.engine.core.common.businessentities.gluster.TransportType)

Example 2 with Translator

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());
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) EnumTranslator(org.ovirt.engine.ui.uicompat.EnumTranslator) Translator(org.ovirt.engine.ui.uicompat.Translator)

Example 3 with Translator

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);
            }
        }
    }));
}
Also used : VmPool(org.ovirt.engine.core.common.businessentities.VmPool) SearchType(org.ovirt.engine.core.common.interfaces.SearchType) QueryType(org.ovirt.engine.core.common.queries.QueryType) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) EnumTranslator(org.ovirt.engine.ui.uicompat.EnumTranslator) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) Event(org.ovirt.engine.ui.uicompat.Event) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) Objects(java.util.Objects) Frontend(org.ovirt.engine.ui.frontend.Frontend) VM(org.ovirt.engine.core.common.businessentities.VM) Translator(org.ovirt.engine.ui.uicompat.Translator) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) EventDefinition(org.ovirt.engine.ui.uicompat.EventDefinition) AbstractGeneralModel(org.ovirt.engine.ui.uicommonweb.models.vms.AbstractGeneralModel) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) VDS(org.ovirt.engine.core.common.businessentities.VDS) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) VmTemplateNameRenderer(org.ovirt.engine.ui.uicommonweb.models.vms.VmTemplateNameRenderer) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VDS(org.ovirt.engine.core.common.businessentities.VDS) VmPool(org.ovirt.engine.core.common.businessentities.VmPool) EnumTranslator(org.ovirt.engine.ui.uicompat.EnumTranslator) Translator(org.ovirt.engine.ui.uicompat.Translator) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) ArrayList(java.util.ArrayList)

Example 4 with Translator

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);
}
Also used : SelectionTreeNodeModel(org.ovirt.engine.ui.uicommonweb.models.common.SelectionTreeNodeModel) EventSubscriber(org.ovirt.engine.core.common.businessentities.EventSubscriber) AuditLogType(org.ovirt.engine.core.common.AuditLogType) EventNotificationEntity(org.ovirt.engine.core.common.EventNotificationEntity) MissingResourceException(java.util.MissingResourceException) ArrayList(java.util.ArrayList) EnumTranslator(org.ovirt.engine.ui.uicompat.EnumTranslator) Translator(org.ovirt.engine.ui.uicompat.Translator) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) HashSet(java.util.HashSet)

Aggregations

EnumTranslator (org.ovirt.engine.ui.uicompat.EnumTranslator)4 Translator (org.ovirt.engine.ui.uicompat.Translator)4 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)1 MissingResourceException (java.util.MissingResourceException)1 Objects (java.util.Objects)1 AuditLogType (org.ovirt.engine.core.common.AuditLogType)1 EventNotificationEntity (org.ovirt.engine.core.common.EventNotificationEntity)1 EventSubscriber (org.ovirt.engine.core.common.businessentities.EventSubscriber)1 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 VM (org.ovirt.engine.core.common.businessentities.VM)1 VmPool (org.ovirt.engine.core.common.businessentities.VmPool)1 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)1 TransportType (org.ovirt.engine.core.common.businessentities.gluster.TransportType)1 SearchType (org.ovirt.engine.core.common.interfaces.SearchType)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)1 QueryType (org.ovirt.engine.core.common.queries.QueryType)1 SearchParameters (org.ovirt.engine.core.common.queries.SearchParameters)1 AsyncCallback (org.ovirt.engine.ui.frontend.AsyncCallback)1