Search in sources :

Example 21 with ListModel

use of org.ovirt.engine.ui.uicommonweb.models.ListModel in project ovirt-engine by oVirt.

the class VolumeModel method clusterSelectedItemChanged.

private void clusterSelectedItemChanged() {
    setBricks(new ListModel<EntityModel<GlusterBrickEntity>>());
    if (getCluster().getSelectedItem() != null) {
        final Cluster cluster = getCluster().getSelectedItem();
        updateArbiterAvailability();
        updateDefaults();
        AsyncDataProvider.getInstance().isAnyHostUpInCluster(new AsyncQuery<>(returnValue -> {
            // In case the result of previous call is returned after selecting some other cluster
            if (!getCluster().getSelectedItem().getId().equals(cluster.getId())) {
                return;
            }
            if (returnValue) {
                getAddBricksCommand().setIsExecutionAllowed(true);
                setMessage(null);
            } else {
                getAddBricksCommand().setIsExecutionAllowed(false);
                setMessage(ConstantsManager.getInstance().getConstants().volumeEmptyClusterValidationMsg());
            }
        }), cluster.getName());
    } else {
        getAddBricksCommand().setIsExecutionAllowed(false);
        setMessage(null);
    }
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) GlusterVolumeType(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeType) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) VolumeListModel(org.ovirt.engine.ui.uicommonweb.models.volumes.VolumeListModel) Version(org.ovirt.engine.core.compat.Version) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Model(org.ovirt.engine.ui.uicommonweb.models.Model) Iterator(java.util.Iterator) Linq(org.ovirt.engine.ui.uicommonweb.Linq) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ApplicationModeHelper(org.ovirt.engine.ui.uicommonweb.models.ApplicationModeHelper) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) AsciiNameValidation(org.ovirt.engine.ui.uicommonweb.validation.AsciiNameValidation) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) VDS(org.ovirt.engine.core.common.businessentities.VDS) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) Cluster(org.ovirt.engine.core.common.businessentities.Cluster)

Example 22 with ListModel

use of org.ovirt.engine.ui.uicommonweb.models.ListModel in project ovirt-engine by oVirt.

the class GlusterClusterSnapshotConfigModel method clusterSelectedItemChanged.

private void clusterSelectedItemChanged() {
    Cluster selectedCluster = getClusters().getSelectedItem();
    if (selectedCluster == null) {
        return;
    }
    AsyncDataProvider.getInstance().getGlusterSnapshotConfig(new AsyncQuery<>(new AsyncCallback<QueryReturnValue>() {

        @Override
        public void onSuccess(QueryReturnValue returnValue) {
            Pair<List<GlusterVolumeSnapshotConfig>, List<GlusterVolumeSnapshotConfig>> configs = returnValue.getReturnValue();
            if (configs != null) {
                List<GlusterVolumeSnapshotConfig> clusterConfigOptions = configs.getFirst();
                Collections.sort(clusterConfigOptions, Comparator.comparing(GlusterVolumeSnapshotConfig::getParamName));
                setModelItems(getClusterConfigOptions(), clusterConfigOptions, existingClusterConfigs);
            } else {
                getClusterConfigOptions().setItems(null);
            }
        }

        private void setModelItems(ListModel<EntityModel<GlusterVolumeSnapshotConfig>> listModel, List<GlusterVolumeSnapshotConfig> cfgs, Map<String, String> fetchedCfgsBackup) {
            List<EntityModel<GlusterVolumeSnapshotConfig>> coll = new ArrayList<>();
            for (GlusterVolumeSnapshotConfig cfg : cfgs) {
                EntityModel<GlusterVolumeSnapshotConfig> cfgModel = new EntityModel<>();
                cfgModel.setEntity(cfg);
                fetchedCfgsBackup.put(cfg.getParamName(), cfg.getParamValue());
                coll.add(cfgModel);
            }
            // set the entity items
            listModel.setItems(coll);
        }
    }), selectedCluster.getId(), null);
}
Also used : GlusterVolumeSnapshotConfig(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 23 with ListModel

use of org.ovirt.engine.ui.uicommonweb.models.ListModel in project ovirt-engine by oVirt.

the class PreviewSnapshotModel method updateDiskSnapshotsMap.

private void updateDiskSnapshotsMap() {
    if (snapshots.getItems() == null) {
        return;
    }
    for (SnapshotModel snapshotModel : (List<SnapshotModel>) snapshots.getItems()) {
        for (DiskImage diskImage : snapshotModel.getEntity().getDiskImages()) {
            ListModel disksListModel;
            if (diskSnapshotsMap.containsKey(diskImage.getId())) {
                disksListModel = diskSnapshotsMap.get(diskImage.getId());
                ((ArrayList<DiskImage>) disksListModel.getItems()).add(diskImage);
            } else {
                disksListModel = new ListModel();
                disksListModel.setItems(new ArrayList<>(Arrays.asList(diskImage)));
            }
            diskSnapshotsMap.put(diskImage.getId(), disksListModel);
        }
    }
}
Also used : ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 24 with ListModel

use of org.ovirt.engine.ui.uicommonweb.models.ListModel in project ovirt-engine by oVirt.

the class PreviewSnapshotModel method selectSnapshot.

public void selectSnapshot(Guid id) {
    SnapshotModel snapshotModel = getSnapshotModelById(id);
    if (snapshotModel == null) {
        return;
    }
    for (SnapshotModel model : getSnapshots().getItems()) {
        if (model.getEntity().getId().equals(id) && model.getLeaseExists().getEntity() != null) {
            model.getLeaseExists().setEntity(true);
        } else if (model.getLeaseExists().getEntity() != null) {
            model.getLeaseExists().setEntity(false);
        }
    }
    getSnapshots().setSelectedItem(snapshotModel);
    setSnapshotModel(snapshotModel);
    for (DiskImage diskImage : snapshotModel.getDisks()) {
        ListModel diskListModel = diskSnapshotsMap.get(diskImage.getId());
        diskListModel.setSelectedItem(diskImage);
    }
}
Also used : ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 25 with ListModel

use of org.ovirt.engine.ui.uicommonweb.models.ListModel in project ovirt-engine by oVirt.

the class NewHostModel method updateDiscoveredHostList.

private void updateDiscoveredHostList(String searchFilter) {
    Provider provider = getProviders().getSelectedItem();
    if (provider != null) {
        AsyncDataProvider.getInstance().getExternalProviderHostList(new AsyncQuery<>(hosts -> {
            ListModel<VDS> hostNameListModel = getExternalHostName();
            hostNameListModel.setItems(hosts);
            hostNameListModel.setIsChangeable(true);
            setEnableSearchHost(true);
        }), provider.getId(), true, searchFilter);
    } else {
        getExternalHostName().setItems(null);
        getExternalHostName().setIsChangeable(false);
        setEnableSearchHost(false);
    }
}
Also used : ApplicationModeHelper(org.ovirt.engine.ui.uicommonweb.models.ApplicationModeHelper) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) List(java.util.List) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ExternalHostGroup(org.ovirt.engine.core.common.businessentities.ExternalHostGroup) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ExternalDiscoveredHost(org.ovirt.engine.core.common.businessentities.ExternalDiscoveredHost) Provider(org.ovirt.engine.core.common.businessentities.Provider) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) VDS(org.ovirt.engine.core.common.businessentities.VDS) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) ArrayList(java.util.ArrayList) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Provider(org.ovirt.engine.core.common.businessentities.Provider) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)

Aggregations

ListModel (org.ovirt.engine.ui.uicommonweb.models.ListModel)43 ArrayList (java.util.ArrayList)29 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)19 List (java.util.List)17 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)11 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)11 SearchableListModel (org.ovirt.engine.ui.uicommonweb.models.SearchableListModel)9 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)8 EntityModelCellTable (org.ovirt.engine.ui.common.widget.editor.EntityModelCellTable)8 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)8 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)7 TreeItem (com.google.gwt.user.client.ui.TreeItem)6 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)6 Model (org.ovirt.engine.ui.uicommonweb.models.Model)6 Provider (org.ovirt.engine.core.common.businessentities.Provider)5 QueryType (org.ovirt.engine.core.common.queries.QueryType)5 PropertyChangedEventArgs (org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs)5 Collections (java.util.Collections)4 ApplicationMode (org.ovirt.engine.core.common.mode.ApplicationMode)4 Linq (org.ovirt.engine.ui.uicommonweb.Linq)4