Fix creator

This commit is contained in:
Alexey Kulish 2017-03-29 11:48:46 +03:00
parent a7decd24cb
commit 904f70c6f2

View file

@ -47,6 +47,8 @@ public class SearchUICore {
private ThreadPoolExecutor singleThreadedExecutor; private ThreadPoolExecutor singleThreadedExecutor;
private LinkedBlockingQueue<Runnable> taskQueue; private LinkedBlockingQueue<Runnable> taskQueue;
private Runnable onSearchStart = null;
private Runnable onResultsComplete = null;
private AtomicInteger requestNumber = new AtomicInteger(); private AtomicInteger requestNumber = new AtomicInteger();
private int totalLimit = -1; // -1 unlimited - not used private int totalLimit = -1; // -1 unlimited - not used
@ -306,6 +308,14 @@ public class SearchUICore {
return phrase; return phrase;
} }
public void setOnSearchStart(Runnable onSearchStart) {
this.onSearchStart = onSearchStart;
}
public void setOnResultsComplete(Runnable onResultsComplete) {
this.onResultsComplete = onResultsComplete;
}
public SearchSettings getSearchSettings() { public SearchSettings getSearchSettings() {
return searchSettings; return searchSettings;
} }
@ -356,6 +366,9 @@ public class SearchUICore {
@Override @Override
public void run() { public void run() {
try { try {
if (onSearchStart != null) {
onSearchStart.run();
}
SearchResultMatcher rm = new SearchResultMatcher(matcher, phrase, request, requestNumber, totalLimit); SearchResultMatcher rm = new SearchResultMatcher(matcher, phrase, request, requestNumber, totalLimit);
rm.searchStarted(phrase); rm.searchStarted(phrase);
if (TIMEOUT_BETWEEN_CHARS > 0 && delayedExecution) { if (TIMEOUT_BETWEEN_CHARS > 0 && delayedExecution) {
@ -374,6 +387,9 @@ public class SearchUICore {
LOG.info(">> Search phrase " + phrase + " " + rm.getRequestResults().size()); LOG.info(">> Search phrase " + phrase + " " + rm.getRequestResults().size());
currentSearchResult = collection; currentSearchResult = collection;
rm.searchFinished(phrase); rm.searchFinished(phrase);
if (onResultsComplete != null) {
onResultsComplete.run();
}
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();