ListDataIntelliHints matching any part of a word in the list

This is the forum for JIDE Common Layer which is open sourced at https://github.com/jidesoft/jide-oss. Please note, JIDE technical support doesn't monitor this forum as often as other forums. Please consider subscribe for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Moderator: JIDE Support

Forum rules
Community driven forum for open source JIDE Common Layer. JIDE technical support doesn't monitor this forum as often as other forums. If you only use JIDE Common Layer, please consider subscribing for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

ListDataIntelliHints matching any part of a word in the list

Postby 4sfed » Wed Jun 08, 2016 1:09 am

Hi, i have implemented ListDataIntelliHints to display a list of items when a user types into a jTextField. This is working great using this:

ListDataIntelliHints searchBox = new ListDataIntelliHints(searchField, hintsList);
searchBox.setCaseSensitive(false);

However, the matches only occur if the users knows the exact start of the phrase, or at least the first letter(s).

is there any way that i am able to set the search to a "contains" type action so that if the user types in any part of any word then it will provide a list?

eg: user types in "Red"
That will only match any phrase starting with red. I would like it to be able to match any phrase that contains that string, like "The Ball is Red", " The Shoe is Red", "I live in Redding" should all be returned in the list of matches.

Is this possible with the current implementation?

Thanks very much.
4sfed
 
Posts: 4
Joined: Tue Jun 07, 2016 1:14 am

Re: ListDataIntelliHints matching any part of a word in the

Postby JIDE Support » Wed Jun 08, 2016 7:09 am

You can use the down arrow key to see the list of available words.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 36107
Joined: Sun Sep 14, 2003 10:49 am

Re: ListDataIntelliHints matching any part of a word in the

Postby 4sfed » Wed Jun 08, 2016 4:11 pm

Thanks. I understand this is possible but not ideal based on the fact that my list contains hundreds of entries, and i would like the user to be able to provide a part of the word they are looking for and the list of matches is narrowed down. is this achievable?
4sfed
 
Posts: 4
Joined: Tue Jun 07, 2016 1:14 am

Re: ListDataIntelliHints matching any part of a word in the

Postby JIDE Support » Thu Jun 09, 2016 2:34 pm

IntelliHint uses Searchable internally. Searchable has setFromStart method, set it to false then it will match any where in the string.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 36107
Joined: Sun Sep 14, 2003 10:49 am

Re: ListDataIntelliHints matching any part of a word in the

Postby 4sfed » Thu Jun 09, 2016 9:43 pm

Ok fantastic.

Could you give me some tips on how to implement this?

Currently all i am doing is this and it all works fine.

ListDataIntelliHints searchBox = new ListDataIntelliHints(searchField, hintsList);

How would i go about setting Searchable.setFromStart(false);

Sorry for the probable stupid question, i am still learning.

Thanks.
4sfed
 
Posts: 4
Joined: Tue Jun 07, 2016 1:14 am

Re: ListDataIntelliHints matching any part of a word in the

Postby JIDE Support » Fri Jun 10, 2016 2:42 pm

Never mind. I gave the wrong answer. It was my fault. Please override compare method on ListDataIntelliHints to change the comparison to 'contains'.

Code: Select all
    /**
     * Compares the context with the object in the completion list.
     *
     * @param context the context returned from {@link #getContext()} method.
     * @param o       the object in the completion list.
     * @return true if the context matches with the object. Otherwise false.
     */
    protected boolean compare(Object context, T o);
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 36107
Joined: Sun Sep 14, 2003 10:49 am

Re: ListDataIntelliHints matching any part of a word in the

Postby 4sfed » Sat Jun 11, 2016 12:03 am

Thanks very much. Ended up doing something like this:

if (org.apache.commons.lang3.StringUtils.containsIgnoreCase(listEntry, s)) {
match = true;
}

So far so good but i will need to continue testing.
4sfed
 
Posts: 4
Joined: Tue Jun 07, 2016 1:14 am


Return to JIDE Common Layer Open Source Project Discussion (Community Driven)

Who is online

Users browsing this forum: No registered users and 1 guest