org.netbeans.spi.quicksearch.SearchProvider Java Examples
The following examples show how to use
org.netbeans.spi.quicksearch.SearchProvider.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CommandEvaluator.java From netbeans with Apache License 2.0 | 6 votes |
/** * 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); }
Example #2
Source File: ProviderModel.java From netbeans with Apache License 2.0 | 5 votes |
public List<SearchProvider> getProviders () { if (providers == null) { Collection<? extends SearchProvider> catProviders = Lookups.forPath(fo.getPath()).lookupAll(SearchProvider.class); providers = new ArrayList<SearchProvider>(catProviders); } return providers; }
Example #3
Source File: CommandEvaluator.java From netbeans with Apache License 2.0 | 5 votes |
private static Task runEvaluation (final SearchProvider provider, final SearchRequest request, final SearchResponse response, final ProviderModel.Category cat) { return RP.post(new Runnable() { @Override public void run() { provider.evaluate(request, response); } }); }
Example #4
Source File: ProviderModelTest.java From netbeans with Apache License 2.0 | 4 votes |
/** Tests ProviderModel functionality */ public void testGetProviders () throws Exception { UnitTestUtils.prepareTest(new String [] { "/org/netbeans/modules/quicksearch/resources/testGetProviders.xml" }); ProviderModel model = ProviderModel.getInstance(); System.out.println("Asking for test providers..."); List<ProviderModel.Category> categories = model.getCategories(); assertEquals(3, categories.size()); System.out.println("Testing empty providers category..."); ProviderModel.Category cat = categories.get(0); assertTrue("empty".equals(cat.getName())); assertTrue(cat.getName().equals(cat.getDisplayName())); assertTrue(cat.getCommandPrefix() == null); System.out.println("Testing category with provider which doesn't define category description..."); cat = categories.get(1); assertTrue("test1".equals(cat.getName())); assertTrue(cat.getName().equals(cat.getDisplayName())); assertTrue(cat.getCommandPrefix() == null); List<SearchProvider> providers = cat.getProviders(); assertEquals(1, providers.size()); SearchProvider sp = providers.iterator().next(); assertTrue(sp instanceof Test1Provider); System.out.println("Testing category with provider with full category description..."); cat = categories.get(2); assertTrue("test2".equals(cat.getName())); // localized FO name don't work in test, don't know why //assertTrue(DISPLAY_NAME.equals(cat.getDisplayName())); assertTrue(COMMAND_PREFIX.equals(cat.getCommandPrefix())); providers = cat.getProviders(); assertEquals(1, providers.size()); sp = providers.iterator().next(); assertTrue(sp instanceof Test2Provider); }