Search in sources :

Example 6 with EventArgs

use of org.ovirt.engine.ui.uicompat.EventArgs in project ovirt-engine by oVirt.

the class ImportVmsModel method initDataCenters.

private void initDataCenters() {
    getDataCenters().getSelectedItemChangedEvent().addListener((ev, sender, args) -> {
        clearVms();
        exportDomain.setEntity(null);
        loadProviders();
        StoragePool dataCenter = dataCenters.getSelectedItem();
        Frontend.getInstance().runQuery(QueryType.GetStorageDomainsByStoragePoolId, new IdQueryParameters(dataCenter.getId()), new AsyncQuery<>(createGetStorageDomainsByStoragePoolIdCallback()));
    });
    dataCenters.getSelectedItemChangedEvent().addListener(new IEventListener<EventArgs>() {

        @Override
        public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) {
            AsyncDataProvider.getInstance().getHostListByDataCenter(new AsyncQuery<>(hosts -> {
                List<VDS> upHosts = filterUpHosts(hosts);
                proxyHosts.setItems(addAnyHostInCluster(upHosts));
                xenProxyHosts.setItems(addAnyHostInCluster(upHosts));
                kvmProxyHosts.setItems(addAnyHostInCluster(upHosts));
                ImportVmsModel.this.hosts.setItems(upHosts);
                stopProgress();
            }), dataCenters.getSelectedItem().getId());
        }

        private List<VDS> filterUpHosts(List<VDS> hosts) {
            List<VDS> result = new ArrayList<>();
            for (VDS host : hosts) {
                if (host.getStatus() == VDSStatus.Up) {
                    result.add(host);
                }
            }
            return result;
        }

        private List<VDS> addAnyHostInCluster(List<VDS> hosts) {
            List<VDS> result = new ArrayList<>(hosts);
            // Any host in the cluster
            result.add(0, null);
            return result;
        }
    });
    AsyncDataProvider.getInstance().getDataCenterList(new AsyncQuery<>(returnValue -> {
        List<StoragePool> dataCenters = new ArrayList<>();
        for (StoragePool a : returnValue) {
            if (a.getStatus() == StoragePoolStatus.Up) {
                dataCenters.add(a);
            }
        }
        if (dataCenters.isEmpty()) {
            getDataCenters().setIsChangeable(false);
            getImportSources().setIsChangeable(false);
            setError(constants.notAvailableWithNoUpDC());
            stopProgress();
            return;
        }
        Collections.sort(dataCenters, new NameableComparator());
        ImportVmsModel.this.dataCenters.setItems(dataCenters);
    }));
}
Also used : Arrays(java.util.Arrays) NameAndOptionalDomainValidation(org.ovirt.engine.ui.uicommonweb.validation.NameAndOptionalDomainValidation) Inject(com.google.inject.Inject) Provider(org.ovirt.engine.core.common.businessentities.Provider) Event(org.ovirt.engine.ui.uicompat.Event) IFrontendMultipleActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) OriginType(org.ovirt.engine.core.common.businessentities.OriginType) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) URL(com.google.gwt.http.client.URL) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) SortedListModel(org.ovirt.engine.ui.uicommonweb.models.SortedListModel) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Set(java.util.Set) StringHelper(org.ovirt.engine.core.compat.StringHelper) Objects(java.util.Objects) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) TypeResolver(org.ovirt.engine.ui.uicommonweb.TypeResolver) ProviderType(org.ovirt.engine.core.common.businessentities.ProviderType) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) HostAddressValidation(org.ovirt.engine.ui.uicommonweb.validation.HostAddressValidation) XENVmProviderProperties(org.ovirt.engine.core.common.businessentities.XENVmProviderProperties) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) KVMVmProviderProperties(org.ovirt.engine.core.common.businessentities.KVMVmProviderProperties) GetAllFromExportDomainQueryParameters(org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters) ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) Guid(org.ovirt.engine.core.compat.Guid) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) IEventListener(org.ovirt.engine.ui.uicompat.IEventListener) HashMap(java.util.HashMap) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) HashSet(java.util.HashSet) Frontend(org.ovirt.engine.ui.frontend.Frontend) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) Pair(org.ovirt.engine.core.common.utils.Pair) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) StoragePoolStatus(org.ovirt.engine.core.common.businessentities.StoragePoolStatus) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) VmwareVmProviderProperties(org.ovirt.engine.core.common.businessentities.VmwareVmProviderProperties) VM(org.ovirt.engine.core.common.businessentities.VM) ErrorPopupManager(org.ovirt.engine.ui.uicommonweb.ErrorPopupManager) ListWithSimpleDetailsModel(org.ovirt.engine.ui.uicommonweb.models.ListWithSimpleDetailsModel) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VDS(org.ovirt.engine.core.common.businessentities.VDS) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) List(java.util.List) ArrayList(java.util.ArrayList) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs)

Example 7 with EventArgs

use of org.ovirt.engine.ui.uicompat.EventArgs in project ovirt-engine by oVirt.

the class HostNetworkProviderWidget method edit.

@Override
public void edit(HostNetworkProviderModel model) {
    driver.edit(model);
    final NeutronAgentModel neutronAgentModel = model.getNeutronAgentModel();
    neutronAgentWidget.edit(neutronAgentModel);
    neutronAgentWidget.setVisible(neutronAgentModel.isPluginConfigurationAvailable().getEntity());
    IEventListener<EventArgs> providerPluginTypeListener = (ev, sender, args) -> neutronAgentWidget.setVisible(model.getNetworkProviderType().getSelectedItem() == OPENSTACK_NETWORK && model.providerPluginTypeIsOpenstack());
    model.getNetworkProviderType().getSelectedItemChangedEvent().addListener(providerPluginTypeListener);
    model.getProviderPluginType().getSelectedItemChangedEvent().addListener(providerPluginTypeListener);
}
Also used : NeutronAgentModel(org.ovirt.engine.ui.uicommonweb.models.providers.NeutronAgentModel) EnumRenderer(org.ovirt.engine.ui.common.widget.renderer.EnumRenderer) AssetProvider(org.ovirt.engine.ui.webadmin.gin.AssetProvider) HostNetworkProviderModel(org.ovirt.engine.ui.uicommonweb.models.providers.HostNetworkProviderModel) Inject(com.google.inject.Inject) IEventListener(org.ovirt.engine.ui.uicompat.IEventListener) Provider(org.ovirt.engine.core.common.businessentities.Provider) Align(org.ovirt.engine.ui.common.widget.Align) GWT(com.google.gwt.core.client.GWT) ListModelListBoxEditor(org.ovirt.engine.ui.common.widget.editor.ListModelListBoxEditor) EnableableFormLabel(org.ovirt.engine.ui.common.widget.label.EnableableFormLabel) UiBinder(com.google.gwt.uibinder.client.UiBinder) ApplicationConstants(org.ovirt.engine.ui.webadmin.ApplicationConstants) ListModelListBoxOnlyEditor(org.ovirt.engine.ui.common.widget.editor.ListModelListBoxOnlyEditor) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) EntityModelCheckBoxEditor(org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor) OpenstackNetworkProviderProperties(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties) NeutronAgentModel(org.ovirt.engine.ui.uicommonweb.models.providers.NeutronAgentModel) ElementIdHandler(org.ovirt.engine.ui.common.idhandler.ElementIdHandler) AbstractModelBoundPopupWidget(org.ovirt.engine.ui.common.widget.uicommon.popup.AbstractModelBoundPopupWidget) UiCommonEditorDriver(org.ovirt.engine.ui.common.editor.UiCommonEditorDriver) PatternFlyCompatible(org.ovirt.engine.ui.common.widget.PatternFlyCompatible) NameRenderer(org.ovirt.engine.ui.common.widget.renderer.NameRenderer) WithElementId(org.ovirt.engine.ui.common.idhandler.WithElementId) ListModelSuggestBoxEditor(org.ovirt.engine.ui.common.widget.editor.generic.ListModelSuggestBoxEditor) ApplicationTemplates(org.ovirt.engine.ui.webadmin.ApplicationTemplates) Widget(com.google.gwt.user.client.ui.Widget) OPENSTACK_NETWORK(org.ovirt.engine.core.common.businessentities.ProviderType.OPENSTACK_NETWORK) EntityModelWidgetWithInfo(org.ovirt.engine.ui.common.widget.EntityModelWidgetWithInfo) UiField(com.google.gwt.uibinder.client.UiField) ProviderType(org.ovirt.engine.core.common.businessentities.ProviderType) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs)

Example 8 with EventArgs

use of org.ovirt.engine.ui.uicompat.EventArgs in project ovirt-engine by oVirt.

the class RegisterVmModel method postClustersInit.

private void postClustersInit() {
    validateAllMacs();
    for (final RegisterVmData registerVmData : getEntities().getItems()) {
        final IEventListener<EventArgs> validateMacsListener = (ev, sender, args) -> validateVmMacs(Collections.singletonList(registerVmData));
        registerVmData.getReassignMacs().getEntityChangedEvent().addListener(validateMacsListener);
        registerVmData.getCluster().getSelectedItemChangedEvent().addListener(validateMacsListener);
    }
}
Also used : ImportVmFromConfParameters(org.ovirt.engine.core.common.action.ImportVmFromConfParameters) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) Predicate(java.util.function.Predicate) Guid(org.ovirt.engine.core.compat.Guid) Collection(java.util.Collection) IEventListener(org.ovirt.engine.ui.uicompat.IEventListener) HashMap(java.util.HashMap) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) Quota(org.ovirt.engine.core.common.businessentities.Quota) ArrayList(java.util.ArrayList) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Map(java.util.Map) ErrorTranslator(org.ovirt.engine.ui.frontend.ErrorTranslator) Linq.where(org.ovirt.engine.ui.uicommonweb.Linq.where) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) Collections(java.util.Collections) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) RegisterVmData(org.ovirt.engine.ui.uicommonweb.models.vms.register.RegisterVmData) RegisterVmData(org.ovirt.engine.ui.uicommonweb.models.vms.register.RegisterVmData) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs)

Aggregations

EventArgs (org.ovirt.engine.ui.uicompat.EventArgs)8 IEventListener (org.ovirt.engine.ui.uicompat.IEventListener)7 Inject (com.google.inject.Inject)6 List (java.util.List)5 Event (org.ovirt.engine.ui.uicompat.Event)5 ArrayList (java.util.ArrayList)4 Collection (java.util.Collection)4 Collections (java.util.Collections)4 ActionType (org.ovirt.engine.core.common.action.ActionType)4 Provider (org.ovirt.engine.core.common.businessentities.Provider)4 Frontend (org.ovirt.engine.ui.frontend.Frontend)4 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)4 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)4 Arrays (java.util.Arrays)3 HashMap (java.util.HashMap)3 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)3 OpenstackNetworkProviderProperties (org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties)3 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)3 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)3 QueryType (org.ovirt.engine.core.common.queries.QueryType)3