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);
}
}
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);
}
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);
}
}
}
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);
}
}
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);
}
}
Aggregations