Search in sources :

Example 1 with LexoNumericComparator

use of org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator in project ovirt-engine by oVirt.

the class ClusterPolicyListModel method fetchClusterPolicies.

private void fetchClusterPolicies() {
    AsyncQuery<QueryReturnValue> asyncQuery = new AsyncQuery<>(returnValue -> {
        ArrayList<ClusterPolicy> list = returnValue.getReturnValue();
        Collections.sort(list, Comparator.comparing(ClusterPolicy::isLocked).reversed().thenComparing(ClusterPolicy::getName, new LexoNumericComparator()));
        setItems(list);
    });
    QueryParametersBase parametersBase = new QueryParametersBase();
    parametersBase.setRefresh(getIsQueryFirstTime());
    Frontend.getInstance().runQuery(QueryType.GetClusterPolicies, parametersBase, asyncQuery);
    setIsQueryFirstTime(false);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) LexoNumericComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy)

Example 2 with LexoNumericComparator

use of org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator in project ovirt-engine by oVirt.

the class StorageDataCenterListModel method syncSearch.

@Override
protected void syncSearch() {
    if (getEntity() == null) {
        return;
    }
    super.syncSearch();
    IdQueryParameters tempVar = new IdQueryParameters(getEntity().getId());
    tempVar.setRefresh(getIsQueryFirstTime());
    Frontend.getInstance().runQuery(QueryType.GetStorageDomainListById, tempVar, new AsyncQuery<QueryReturnValue>(returnValue -> {
        ArrayList<StorageDomain> domains = returnValue.getReturnValue();
        for (StorageDomain domain : domains) {
            domain.setId(domain.getStoragePoolId());
        }
        Collections.sort(domains, Comparator.comparing(StorageDomain::getStoragePoolName, new LexoNumericComparator()));
        setItems(domains);
        setIsEmpty(getItems().size() == 0);
    }));
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) LexoNumericComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) StorageDomainPoolParametersBase(org.ovirt.engine.core.common.action.StorageDomainPoolParametersBase) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Model(org.ovirt.engine.ui.uicommonweb.models.Model) AttachStorageDomainToPoolParameters(org.ovirt.engine.core.common.action.AttachStorageDomainToPoolParameters) RemoveStorageDomainParameters(org.ovirt.engine.core.common.action.RemoveStorageDomainParameters) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) ActionUtils(org.ovirt.engine.core.common.ActionUtils) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) StoragePoolStatus(org.ovirt.engine.core.common.businessentities.StoragePoolStatus) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) StorageDomainSharedStatus(org.ovirt.engine.core.common.businessentities.StorageDomainSharedStatus) List(java.util.List) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) Comparator(java.util.Comparator) Collections(java.util.Collections) DeactivateStorageDomainWithOvfUpdateParameters(org.ovirt.engine.core.common.action.DeactivateStorageDomainWithOvfUpdateParameters) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) DetachStorageDomainFromPoolParameters(org.ovirt.engine.core.common.action.DetachStorageDomainFromPoolParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) LexoNumericComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator)

Example 3 with LexoNumericComparator

use of org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator in project ovirt-engine by oVirt.

the class HostSetupNetworksModel method initNextBondName.

private void initNextBondName(List<String> bondNames) {
    Collections.sort(bondNames, new LexoNumericComparator());
    nextBondName = BusinessEntitiesDefinitions.BOND_NAME_PREFIX + 0;
    for (int i = 0; i < bondNames.size(); ++i) {
        if (nextBondName.equals(bondNames.get(i))) {
            nextBondName = BusinessEntitiesDefinitions.BOND_NAME_PREFIX + (i + 1);
        } else {
            break;
        }
    }
}
Also used : LexoNumericComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator)

Example 4 with LexoNumericComparator

use of org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator in project ovirt-engine by oVirt.

the class VfsNicLabelModel method initLabelModels.

protected void initLabelModels() {
    Collections.sort(originalLabels, new LexoNumericComparator());
    LinkedList<ListModel<String>> items = new LinkedList<>();
    for (String label : originalLabels) {
        ListModel<String> labelModel = new ListModel<>();
        labelModel.setItems(suggestedLabels);
        labelModel.setSelectedItem(label);
        items.add(labelModel);
    }
    setItems(items);
    suggestedLabelsCache = new TreeSet<>(suggestedLabels);
}
Also used : ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) LexoNumericComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator) LinkedList(java.util.LinkedList)

Example 5 with LexoNumericComparator

use of org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator in project ovirt-engine by oVirt.

the class ClusterNetworkListModel method createNetworkList.

private ClusterNetworkManageModel createNetworkList(List<Network> dcNetworks) {
    final List<ClusterNetworkModel> networkList = new ArrayList<>();
    final List<Network> clusterNetworks = new ArrayList<>(getItems());
    for (Network network : dcNetworks) {
        ClusterNetworkModel networkManageModel;
        int index = clusterNetworks.indexOf(network);
        if (index >= 0) {
            Network clusterNetwork = clusterNetworks.get(index);
            networkManageModel = new ClusterNetworkModel((Network) Cloner.clone(clusterNetwork));
        } else {
            networkManageModel = new ClusterNetworkModel((Network) Cloner.clone(network));
        }
        networkManageModel.setCluster((Cluster) Cloner.clone(getEntity()));
        networkList.add(networkManageModel);
    }
    Collections.sort(networkList, Comparator.comparing(ClusterNetworkModel::isManagement).reversed().thenComparing(ClusterNetworkModel::getNetworkName, new LexoNumericComparator()));
    ClusterNetworkManageModel listModel = new ClusterNetworkManageModel(this);
    listModel.setItems(networkList);
    return listModel;
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) ArrayList(java.util.ArrayList) LexoNumericComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator)

Aggregations

LexoNumericComparator (org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator)8 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Network (org.ovirt.engine.core.common.businessentities.network.Network)2 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)2 ListModel (org.ovirt.engine.ui.uicommonweb.models.ListModel)2 MenuItem (com.google.gwt.user.client.ui.MenuItem)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 LinkedList (java.util.LinkedList)1 TreeSet (java.util.TreeSet)1 ActionUtils (org.ovirt.engine.core.common.ActionUtils)1 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 AttachStorageDomainToPoolParameters (org.ovirt.engine.core.common.action.AttachStorageDomainToPoolParameters)1 DeactivateStorageDomainWithOvfUpdateParameters (org.ovirt.engine.core.common.action.DeactivateStorageDomainWithOvfUpdateParameters)1 DetachStorageDomainFromPoolParameters (org.ovirt.engine.core.common.action.DetachStorageDomainFromPoolParameters)1 RemoveStorageDomainParameters (org.ovirt.engine.core.common.action.RemoveStorageDomainParameters)1 StorageDomainPoolParametersBase (org.ovirt.engine.core.common.action.StorageDomainPoolParametersBase)1