Search in sources :

Example 1 with Completion

use of com.jgoodies.completion.text.Completion in project kindergarten by clear-group-ausbildung.

the class VendorFieldSearchProcessor method search.

/**
 * {@inheritDoc}
 */
@Override
public // ignored
boolean search(// ignored
String content, // ignored
int caretPosition, CompletionPublisher publisher, CompletionState state) {
    String trimmedContent = content.trim();
    sleep(1000);
    Format format = new VendorAppliance.ExtrasHTMLFormat();
    List<VendorBean> vendors = new ArrayList<>(VendorService.getInstance().getAll());
    // Check the name
    for (Iterator<VendorBean> i = vendors.iterator(); i.hasNext(); ) {
        VendorBean vendor = i.next();
        String name = vendor.getFirstName();
        sleep(100);
        if (UIFStringUtils.startsWithIgnoreCase(name, trimmedContent)) {
            Completion completion = new DefaultCompletion(name, null, null, format.format(vendor), null, 0, name.equals(content), CaretPosition.END);
            publisher.publish(completion);
            i.remove();
        }
    }
    // Check the display string
    for (Iterator<VendorBean> i = vendors.iterator(); i.hasNext(); ) {
        VendorBean vendor = i.next();
        String display = getDisplayString(vendor);
        sleep(100);
        if (display.equals(trimmedContent)) {
            Completion completion = new DefaultCompletion(display, null, null, format.format(vendor), null, 0, true, CaretPosition.END);
            publisher.publish(completion);
            i.remove();
        }
    }
    return true;
}
Also used : Format(java.text.Format) DefaultCompletion(com.jgoodies.completion.text.DefaultCompletion) Completion(com.jgoodies.completion.text.Completion) VendorBean(de.clearit.kindergarten.domain.VendorBean) ArrayList(java.util.ArrayList) DefaultCompletion(com.jgoodies.completion.text.DefaultCompletion)

Aggregations

Completion (com.jgoodies.completion.text.Completion)1 DefaultCompletion (com.jgoodies.completion.text.DefaultCompletion)1 VendorBean (de.clearit.kindergarten.domain.VendorBean)1 Format (java.text.Format)1 ArrayList (java.util.ArrayList)1