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;
}
Aggregations