Search in sources :

Example 1 with SearchResponse

use of org.netbeans.spi.quicksearch.SearchResponse in project netbeans-rcp-lite by outersky.

the class CommandEvaluator method evaluate.

/**
 * Runs evaluation.
 *
 * @param command text to evauate, to search for
 *
 * @return task of this evaluation, which waits for all providers to complete
 * execution. Use returned instance to recognize if this evaluation still
 * runs and when it actually will finish.
 */
public static org.openide.util.Task evaluate(String command, ResultsModel model) {
    List<CategoryResult> l = new ArrayList<CategoryResult>();
    String[] commands = parseCommand(command);
    SearchRequest sRequest = Accessor.DEFAULT.createRequest(commands[1], null);
    List<Task> tasks = new ArrayList<Task>();
    List<Category> provCats = new ArrayList<Category>();
    boolean allResults = getProviderCategories(commands, provCats);
    for (ProviderModel.Category curCat : provCats) {
        CategoryResult catResult = new CategoryResult(curCat, allResults);
        SearchResponse sResponse = Accessor.DEFAULT.createResponse(catResult, sRequest);
        for (SearchProvider provider : curCat.getProviders()) {
            Task t = runEvaluation(provider, sRequest, sResponse, curCat);
            if (t != null) {
                tasks.add(t);
            }
        }
        l.add(catResult);
    }
    model.setContent(l);
    return new Wait4AllTask(tasks);
}
Also used : SearchRequest(org.netbeans.spi.quicksearch.SearchRequest) Task(org.openide.util.RequestProcessor.Task) Category(org.netbeans.modules.quicksearch.ProviderModel.Category) ArrayList(java.util.ArrayList) SearchProvider(org.netbeans.spi.quicksearch.SearchProvider) Category(org.netbeans.modules.quicksearch.ProviderModel.Category) SearchResponse(org.netbeans.spi.quicksearch.SearchResponse)

Aggregations

ArrayList (java.util.ArrayList)1 Category (org.netbeans.modules.quicksearch.ProviderModel.Category)1 SearchProvider (org.netbeans.spi.quicksearch.SearchProvider)1 SearchRequest (org.netbeans.spi.quicksearch.SearchRequest)1 SearchResponse (org.netbeans.spi.quicksearch.SearchResponse)1 Task (org.openide.util.RequestProcessor.Task)1