Triggering auto completion plugin

thomask
Posts: 3
Joined: Wed Mar 25, 2020 8:53 pm

Triggering auto completion plugin

Post by thomask » Wed Mar 25, 2020 9:10 pm

Hello to all,

I use the TEI-Completer plugin (https://github.com/BCDH/TEI-Completer) in Oxygen XML Editor 21.1. This plugin performs a http request to populate the content completion suggestions. It works without problems. As far as I can see it is invoked whenever the opening quotation marks of an attribute value are inserted in the editor. My question is: Does Oxygen trigger the content completion plugin only when the quotation marks are inserted or is it possible to configure / implement that on every keystroke the plugin is invoked and a request to the server made?
grafik.png
grafik.png (16.15 KiB) Viewed 1035 times
I confess, I do not understand the plugin code completely, so maybe my question is based on a wrong understanding, of how the process works.

Thank you for your help!
All the best,
Thomas

thomask
Posts: 3
Joined: Wed Mar 25, 2020 8:53 pm

Re: Triggering auto completion plugin

Post by thomask » Wed Mar 25, 2020 9:26 pm

I think I should clarify what I mean with "keystroke". When I enter for example "An" for the value of the attribute I want to make a request to the API which delivers all names starting with "An". The goal is to get a smaller result set which does consume less resources.

Thank you!
Thomas

alex_jitianu
Posts: 763
Joined: Wed Nov 16, 2005 11:11 am

Re: Triggering auto completion plugin

Post by alex_jitianu » Thu Mar 26, 2020 3:54 pm

Hi Thomas,

I took a look at the plugin myself. It uses the SchemaManagerFilter API to contribute possible values for attributes. Oxygen will call this API whenever it requires the proposals for an attribute value, fir example when the user types the opening quote for an attribute value.

I assume the plugin takes awhile to retrieve all the values and as a result Oxygen freezes a bit, right? The plugin's implementation of this API is called TeiCompleter. The invoked method is filterAttributeValues() and it receives a {{WhatPossibleValuesHasAttributeContext}} object as a parameter. This object has a methods getCurrentValuePrefix() which would return any text already written by the user in the attribute's value. So if you type "An" inside the attribute value and then press Ctrl + Space when the caret is after "An", the previously mentioned method will return "An" and you can use it to retrieve just a subset from server.

At a glance, I don't see the plugin using this information for anything in getAutoCompleteSuggestions(), so it probably just gets all the values from the server.

You'll still have some cases in which all attributes will be retrieved, like for example when typing the starting quote of an attribute value.

Best regards,
Alex

thomask
Posts: 3
Joined: Wed Mar 25, 2020 8:53 pm

Re: Triggering auto completion plugin

Post by thomask » Mon Mar 30, 2020 10:43 am

Hello Alex,

thank you very much for your reply.

I completely agree that it makes no sense to search for data which is a subset of information already retrieved.

Thank you again for the given information and the spent time.

Sincerely,
Thomas

Post Reply