Autocomplete TextCellEditor in Eclipse SWT / JFace?

I would like a TextCellEditor with the standard automatic full behavior that any user that currently expects when entering inside an input cell with a list of suggested strings is expecting. For a good working example of what I need, in Javascript see this jQuery autocomplete widget .

I could not find a good example. I found (except for a few small options) this TextCellEditorWithContentProposal fragment . But this leaves much to be desired:

  • It lists all words, regardless of the "partial word" entered in the cell (without partial matching)
  • When the selected word is selected, it is added to the partial word, and does not replace it
  • The interaction is ugly and non-intuitive. For example, one would expect the Escape key to cancel a list of offers; again see the Javascript example; here he also deletes the printed letters.

It seems strange to me that such a standard and useful component is not available. Or maybe it is available? Can someone point me to a more suitable snippet or example?

+6
source share
1 answer

The example you are referring to is a piece of code designed to demonstrate the API and direct you to customize the control to your preference.

Some of your complaints are either invalid or can be easily fixed using the public API.

.

,

, org.eclipse.jface.fieldassist.SimpleContentProposalProvider:

IContentProposalProvider contentProposalProvider = new SimpleContentProposalProvider(new String[] { "red",
                    "green", "blue" });
cellEditor = new TextCellEditorWithContentProposal(viewer.getTable(), contentProposalProvider, null, null);

javadoc, :

, : contentProposalProvider.setFiltering(true);

- org.eclipse.jface.fieldassist.IContentProposalProvider.

,

org.eclipse.jface.fieldassist.ContentProposalAdapter. org.eclipse.jface.fieldassist.ContentProposalAdapter.setProposalAcceptanceStyle(int) :

contentProposalAdapter = new ContentProposalAdapter(text, new TextContentAdapter(), contentProposalProvider, keyStroke, autoActivationCharacters);
contentProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);

, API, ContentProposalAdapter ContentProposalPopup, .

ContentProposalAdapter, ContentProposalAdapter.ContentProposalPopup.filterText.


, org.eclipse.jface.fieldassist.AutoCompleteField.

+2

All Articles