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