use of com.haulmont.cuba.gui.components.autocomplete.impl.Option in project cuba by cuba-platform.
the class JpqlSuggestionFactory method requestHint.
public static List<Suggestion> requestHint(String query, int queryPosition, AutoCompleteSupport sender, int senderCursorPosition, @Nullable HintProvider provider) {
DomainModelBuilder builder = AppBeans.get(DomainModelWithCaptionsBuilder.NAME);
DomainModel domainModel = builder.produce();
if (provider == null) {
provider = new HintProvider(domainModel);
}
try {
HintRequest request = new HintRequest();
request.setQuery(query);
request.setPosition(queryPosition);
HintResponse response = provider.requestHint(request);
String prefix = response.getLastWord();
List<Option> options = response.getOptionObjects();
List<Suggestion> result = new ArrayList<>();
for (Option option : options) {
Suggestion suggestion = JpqlSuggestionFactory.produce(sender, option.getValue(), option.getDescription(), senderCursorPosition, prefix == null ? 0 : prefix.length());
result.add(suggestion);
}
return result;
} catch (org.antlr.runtime.RecognitionException e) {
throw new RuntimeException(e);
}
}
Aggregations