use of edu.stanford.bmir.protege.web.shared.entity.LookupEntitiesAction in project webprotege by protegeproject.
the class CommentAutoCompleter method handleAttemptAtEntityCompletions.
private void handleAttemptAtEntityCompletions(String queryUpToCaret, EditorPosition caretPos, AutoCompletionCallback callback) {
// Last index of space or 0 if there are not spaces
int wordStart = queryUpToCaret.lastIndexOf(" ") + 1;
int wordFragmentLen = queryUpToCaret.length() - wordStart;
String wordFragment = queryUpToCaret.substring(wordStart);
if (wordFragment.isEmpty()) {
callback.completionsReady(new AutoCompletionResult());
return;
}
dispatchServiceManager.execute(new LookupEntitiesAction(projectId, lookUpEntities(wordFragment)), result -> {
List<AutoCompletionChoice> choices = new ArrayList<>();
EditorPosition pos = new EditorPosition(caretPos.getLineNumber(), caretPos.getColumnNumber() - wordFragmentLen);
for (final EntityLookupResult entity : result.getEntityLookupResults()) {
choices.add(new AutoCompletionChoice(formatReplacementTest(entity), entity.getOWLEntityData().getBrowserText(), "", pos, caretPos));
}
AutoCompletionResult autoCompletionResult = new AutoCompletionResult(choices, pos);
callback.completionsReady(autoCompletionResult);
});
}
Aggregations