Search in sources :

Example 6 with LexoNumericComparator

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

the class ClusterNetworkListModel method syncSearch.

@Override
protected void syncSearch() {
    if (getEntity() == null) {
        return;
    }
    super.syncSearch();
    Guid clusterId = getEntity().getId();
    IdQueryParameters tempVar = new IdQueryParameters(clusterId);
    tempVar.setRefresh(getIsQueryFirstTime());
    Frontend.getInstance().runQuery(QueryType.GetAllNetworksByClusterId, tempVar, new AsyncQuery<>((AsyncCallback<QueryReturnValue>) returnValue -> {
        final List<Network> newItems = returnValue.getReturnValue();
        Collections.sort(newItems, Comparator.comparing((Network n) -> n.getCluster().isManagement()).reversed().thenComparing(Network::getName, new LexoNumericComparator()));
        for (Network network : newItems) {
            network.getCluster().setId(new NetworkClusterId(clusterId, network.getId()));
        }
        setItems(newItems);
    }));
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) Network(org.ovirt.engine.core.common.businessentities.network.Network) LexoNumericComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator) Guid(org.ovirt.engine.core.compat.Guid) NetworkClusterId(org.ovirt.engine.core.common.businessentities.network.NetworkClusterId)

Example 7 with LexoNumericComparator

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

the class AsyncDataProvider method getNetworkLabelsByDataCenterId.

public void getNetworkLabelsByDataCenterId(Guid dataCenterId, AsyncQuery<SortedSet<String>> query) {
    query.converterCallback = returnValue -> {
        SortedSet<String> sortedSet = new TreeSet<>(new LexoNumericComparator());
        sortedSet.addAll((Collection<String>) returnValue);
        return sortedSet;
    };
    Frontend.getInstance().runQuery(QueryType.GetNetworkLabelsByDataCenterId, new IdQueryParameters(dataCenterId), query);
}
Also used : StorageDomainsAndStoragePoolIdQueryParameters(org.ovirt.engine.core.common.queries.StorageDomainsAndStoragePoolIdQueryParameters) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) TreeSet(java.util.TreeSet) LexoNumericComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator)

Example 8 with LexoNumericComparator

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

the class NetworkItemPanel method menuFor.

/**
 * Generate a Menu for the provided Network Item.
 */
private MenuBar menuFor(NetworkItemModel<?> item) {
    MenuBar menu = rootMenu(item);
    Map<NetworkOperation, List<NetworkCommand>> operationMap = item.getSetupModel().commandsFor(item);
    for (final Entry<NetworkOperation, List<NetworkCommand>> entry : operationMap.entrySet()) {
        final List<NetworkCommand> commands = entry.getValue();
        if (entry.getKey().isUnary()) {
            // $NON-NLS-1$
            assert commands.size() == 1 : "Got a NetworkCommand List with more than one Unary Operation";
            menu.addItem(entry.getKey().getVerb(item), () -> executeCommand(entry.getKey(), commands.get(0)));
        } else {
            Collections.sort(commands, Comparator.comparing(NetworkCommand::getName, new LexoNumericComparator()));
            MenuBar subMenu = subMenu();
            for (final NetworkCommand command : commands) {
                subMenu.addItem(new MenuItem(command.getName(), () -> executeCommand(entry.getKey(), command)));
            }
            menu.addItem(entry.getKey().getVerb(item), subMenu);
        }
    }
    return menu;
}
Also used : MenuBar(org.ovirt.engine.ui.common.widget.MenuBar) LexoNumericComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator) List(java.util.List) MenuItem(com.google.gwt.user.client.ui.MenuItem) NetworkCommand(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkCommand) NetworkOperation(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkOperation)

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