use of org.ovirt.engine.core.common.businessentities.comparators.NameableComparator in project ovirt-engine by oVirt.
the class RoleListModel method syncSearch.
@Override
protected void syncSearch() {
super.syncSearch();
QueryParametersBase tempVar = new QueryParametersBase();
tempVar.setRefresh(getIsQueryFirstTime());
Frontend.getInstance().runQuery(QueryType.GetAllRoles, tempVar, new AsyncQuery<QueryReturnValue>(returnValue -> {
ArrayList<Role> filteredList = new ArrayList<>();
for (Role item : (ArrayList<Role>) returnValue.getReturnValue()) {
// ignore CONSUME_QUOTA_ROLE in UI
if (item.getId().equals(ApplicationGuids.quotaConsumer.asGuid())) {
continue;
}
if (getItemsFilter() == null || getItemsFilter() == item.getType()) {
filteredList.add(item);
}
}
Collections.sort(filteredList, new NameableComparator());
setItems(filteredList);
}));
setIsQueryFirstTime(false);
}
use of org.ovirt.engine.core.common.businessentities.comparators.NameableComparator in project ovirt-engine by oVirt.
the class ProviderModel method updateDatacentersForExternalProvider.
protected void updateDatacentersForExternalProvider() {
AsyncDataProvider.getInstance().getDataCenterList(new AsyncQuery<>(new AsyncCallback<List<StoragePool>>() {
@Override
public void onSuccess(List<StoragePool> dataCenters) {
StoragePool prevDataCenter = getPreviousDataCenter(dataCenters);
Collections.sort(dataCenters, new NameableComparator());
// any data center
dataCenters.add(0, null);
getDataCenter().setItems(dataCenters);
getDataCenter().setSelectedItem(prevDataCenter);
if (getDataCenter().getSelectedItem() == null) {
getProxyHostPropertiesModel().disableProxyHost();
}
}
private StoragePool getPreviousDataCenter(List<StoragePool> dataCenters) {
Guid previousDataCenterId = getProxyHostPropertiesModel().getLastStoragePoolId();
for (StoragePool dataCenter : dataCenters) {
if (dataCenter.getId().equals(previousDataCenterId)) {
return dataCenter;
}
}
return null;
}
}));
}
use of org.ovirt.engine.core.common.businessentities.comparators.NameableComparator in project ovirt-engine by oVirt.
the class ImportRepoImageModel method filterStorageDomains.
@Override
protected List<StorageDomain> filterStorageDomains(List<StorageDomain> storageDomains) {
List<StorageDomain> availableStorageDomains = new ArrayList<>();
// Filtering out domains that are not active
for (StorageDomain storageDomainItem : storageDomains) {
if (Linq.isDataActiveStorageDomain(storageDomainItem)) {
availableStorageDomains.add(storageDomainItem);
}
}
// Sorting by name
Collections.sort(availableStorageDomains, new NameableComparator());
return availableStorageDomains;
}
use of org.ovirt.engine.core.common.businessentities.comparators.NameableComparator in project ovirt-engine by oVirt.
the class VmModelBehaviorBase method postInitStorageDomains.
protected void postInitStorageDomains() {
if (getModel().getDisks() == null) {
return;
}
ActionGroup actionGroup = getModel().isCreateInstanceOnly() ? ActionGroup.CREATE_INSTANCE : ActionGroup.CREATE_VM;
StoragePool dataCenter = getModel().getSelectedDataCenter();
AsyncDataProvider.getInstance().getPermittedStorageDomainsByStoragePoolId(new AsyncQuery<>(storageDomains -> {
ArrayList<StorageDomain> activeStorageDomains = filterStorageDomains(storageDomains);
boolean provisioning = getModel().getProvisioning().getEntity();
ArrayList<DiskModel> disks = (ArrayList<DiskModel>) getModel().getDisks();
activeStorageDomains.sort(new NameableComparator());
List<DiskModel> diskImages = Linq.filterDisksByType(disks, DiskStorageType.IMAGE);
for (DiskModel diskModel : diskImages) {
List<StorageDomain> availableDiskStorageDomains;
diskModel.getQuota().setItems(getModel().getQuota().getItems());
List<Guid> storageIds = ((DiskImage) diskModel.getDisk()).getStorageIds();
// Active storage domains that the disk resides on
List<StorageDomain> activeDiskStorageDomains = Linq.getStorageDomainsByIds(storageIds, activeStorageDomains);
// Set target storage domains
availableDiskStorageDomains = provisioning ? activeStorageDomains : activeDiskStorageDomains;
availableDiskStorageDomains.sort(new NameableComparator());
diskModel.getStorageDomain().setItems(availableDiskStorageDomains);
diskModel.getStorageDomain().setChangeProhibitionReason(constants.noActiveTargetStorageDomainAvailableMsg());
diskModel.getStorageDomain().setIsChangeable(!availableDiskStorageDomains.isEmpty());
}
List<DiskModel> cinderDisks = Linq.filterDisksByType(disks, DiskStorageType.CINDER);
Collection<StorageDomain> cinderStorageDomains = Linq.filterStorageDomainsByStorageType(storageDomains, StorageType.CINDER);
initStorageDomainsForCinderDisks(cinderDisks, cinderStorageDomains);
}), dataCenter.getId(), actionGroup);
}
use of org.ovirt.engine.core.common.businessentities.comparators.NameableComparator in project ovirt-engine by oVirt.
the class AffinityLabelListWidget method createItems.
@Override
protected void createItems() {
List<Label> selectedLabels = getModel().getSelectedItems();
boolean noLabelsSelected = selectedLabels == null || selectedLabels.isEmpty();
if (noLabelsSelected) {
addNoLabelsMessage();
return;
}
itemList.clear();
Collections.sort(selectedLabels, new NameableComparator());
selectedLabels.forEach(label -> {
ItemListItem labelListItem = new ItemListItem();
labelListItem.init(label.getName());
labelListItem.getDeactivationAnchor().addClickHandler(event -> {
getModel().getSelectedItems().remove(label);
refreshItems();
});
itemList.add(labelListItem);
});
itemListPanel.add(itemList);
}
Aggregations