use of com.google.gerrit.client.ui.HighlightSuggestion in project gerrit by GerritCodeReview.
the class GroupSuggestOracle method requestSuggestions.
@Override
public void requestSuggestions(final Request req, final Callback done) {
if (req.getQuery().length() < chars) {
responseEmptySuggestion(req, done);
return;
}
RestApi rest = new RestApi("/groups/").addParameter("suggest", req.getQuery());
if (req.getLimit() > 0) {
rest.addParameter("n", req.getLimit());
}
rest.get(new AsyncCallback<NativeMap<JavaScriptObject>>() {
@Override
public void onSuccess(NativeMap<JavaScriptObject> result) {
List<String> keys = result.sortedKeys();
List<Suggestion> suggestions = new ArrayList<>(keys.size());
for (String g : keys) {
suggestions.add(new HighlightSuggestion(req.getQuery(), g));
}
done.onSuggestionsReady(req, new Response(suggestions));
}
@Override
public void onFailure(Throwable caught) {
responseEmptySuggestion(req, done);
}
});
}
Aggregations