当前位置: 首页>>代码示例>>Java>>正文


Java SearchRequest类代码示例

本文整理汇总了Java中org.netbeans.spi.quicksearch.SearchRequest的典型用法代码示例。如果您正苦于以下问题:Java SearchRequest类的具体用法?Java SearchRequest怎么用?Java SearchRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SearchRequest类属于org.netbeans.spi.quicksearch包,在下文中一共展示了SearchRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: highlightSubstring

import org.netbeans.spi.quicksearch.SearchRequest; //导入依赖的package包/类
private String highlightSubstring (String text, SearchRequest sRequest) {
    if (text.startsWith(HTML)) {
        // provider handles highliting itself, okay
        return text;
    }
    // try to find substring
    String searchedText = sRequest.getText();
    int index = text.toLowerCase(Locale.ENGLISH).indexOf(searchedText.toLowerCase(Locale.ENGLISH));
    if (index == -1) {
        return HTML + safeEscape(text);
    }
    // found, bold it
    int endIndex = index + searchedText.length();
    StringBuilder sb = new StringBuilder(HTML);
    if (index > 0) {
        sb.append(safeEscape(text.substring(0, index)));
    }
    sb.append("<b>");
    sb.append(safeEscape(text.substring(index, endIndex)));
    sb.append("</b>");
    if (endIndex < text.length()) {
        sb.append(safeEscape(text.substring(endIndex, text.length())));
    }
    return sb.toString();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:ResultsModel.java

示例2: evaluate

import org.netbeans.spi.quicksearch.SearchRequest; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:CommandEvaluator.java

示例3: evaluate

import org.netbeans.spi.quicksearch.SearchRequest; //导入依赖的package包/类
@Override
public void evaluate(SearchRequest request, SearchResponse response) {
    boolean atLeastOne = false;
    boolean limitReached = false;
    for (ItemResult itemR : RecentSearches.getDefault().getSearches()) {
        if (itemR.getDisplayName().toLowerCase().indexOf(request.getText().toLowerCase()) != -1) {
            if (!response.addResult(itemR.getAction(), itemR.getDisplayName(),
                    itemR.getDisplayHint(), itemR.getShortcut())) {
                limitReached = true;
                break;
            } else {
                atLeastOne = true;
            }
        }
    }
    if (atLeastOne && !limitReached && request.getText().isEmpty()) {
        addClearAction(response);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:RecentProvider.java

示例4: evaluate

import org.netbeans.spi.quicksearch.SearchRequest; //导入依赖的package包/类
@Override
   public void evaluate(SearchRequest request, SearchResponse response) {
readKeywordsFromNewAnnotation();
       for (Lookup.Item<OptionsCategory> entry : getODCategories()) {
           for (Map.Entry<String, Set<String>> kw : getKeywords(entry).entrySet()) {
               for (String keywords : kw.getValue()) {
	    for (String keyword : Arrays.asList(keywords.split(","))) {
		if (keyword.toLowerCase().indexOf(request.getText().toLowerCase()) > -1) {
		    String path = entry.getId().substring(entry.getId().indexOf("/") + 1);  // NOI18N
		    if (kw.getKey().contains("/")) {
			path = path + kw.getKey().substring(kw.getKey().indexOf("/")); //NOI18N
		    }
		    if (!response.addResult(new OpenOption(path), keyword)) {
			return;
		    }
		}
	    }
               }
           }
       }
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:QuickSearchProvider.java

示例5: evaluate

import org.netbeans.spi.quicksearch.SearchRequest; //导入依赖的package包/类
@Override
public void evaluate(SearchRequest request, SearchResponse response) {
    final String searchText = request.getText().toLowerCase();

    for (final Project project : OpenProjects.getDefault().getOpenProjects()) {
        final ProjectInformation info = ProjectUtils.getInformation(project);
        if (info == null || info.getDisplayName() == null) {
            continue;
        }
        final String projectName = info.getDisplayName();
        final String projectNameLower = projectName.toLowerCase();

        if (projectNameLower.contains(searchText)) {
            final boolean result = response.addResult(new Runnable() {
                @Override
                public void run() {
                    //see http://forums.netbeans.org/post-140855.html#140855
                    ProjectUtilities.selectAndExpandProject(project);
                    ProjectUtilities.makeProjectTabVisible();
                }
            }, projectName);
            if (!result) {
                break;
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:SearchForProjectsQuickSearch.java

示例6: doEvaluation

import org.netbeans.spi.quicksearch.SearchRequest; //导入依赖的package包/类
private boolean doEvaluation(String name, SearchRequest request,
        ActionInfo actInfo, SearchResponse response, List<ActionInfo> possibleResults, Map<Object, String> duplicateCheck) {
    int index = name.toLowerCase().indexOf(request.getText().toLowerCase());
    if (index == 0) {
        return addAction(actInfo, response, duplicateCheck);
    } else if (index != -1) {
        // typed text is contained in action name, but not as prefix,
        // store such actions if there are not enough "prefix" actions
        possibleResults.add(actInfo);
    }
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:ActionsSearchProvider.java

示例7: evaluate

import org.netbeans.spi.quicksearch.SearchRequest; //导入依赖的package包/类
public void evaluate(SearchRequest request, SearchResponse response) {
    synchronized( this ) {
        if( null == query ) {
            query = JavaHelpQuery.getDefault();
        }
    }
    List<SearchTOCItem> res = query.search( request.getText() );
    for( SearchTOCItem item : res ) {
        if( !response.addResult( createAction( item.getURL() ), item.getName() ) )
            return;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:JavaHelpQuickSearchProviderImpl.java

示例8: ItemResult

import org.netbeans.spi.quicksearch.SearchRequest; //导入依赖的package包/类
public ItemResult (CategoryResult category, SearchRequest sRequest, 
        Runnable action, String displayName, List<? extends KeyStroke> shortcut,
        String displayHint) {
    this.category = category;
    this.action = action;
    this.displayName = sRequest != null ?
        highlightSubstring(displayName, sRequest) : displayName;
    this.shortcut = shortcut;
    this.displayHint = displayHint;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ResultsModel.java

示例9: evaluate

import org.netbeans.spi.quicksearch.SearchRequest; //导入依赖的package包/类
public void evaluate(SearchRequest request, SearchResponse response) {
    if( null == query ) {
        query = Query.getDefault();
    }
    Result res = query.search( request.getText() );
    do {
        for( Item item : res.getItems() ) {
            if( !response.addResult( createAction( item.getUrl() ), item.getTitle() ) )
                return;
        }
        res = query.searchMore( request.getText() );
    } while( !res.isSearchFinished() );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:WebQuickSearchProviderImpl.java

示例10: runEvaluation

import org.netbeans.spi.quicksearch.SearchRequest; //导入依赖的package包/类
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);
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:CommandEvaluator.java

示例11: evaluate

import org.netbeans.spi.quicksearch.SearchRequest; //导入依赖的package包/类
public void evaluate(SearchRequest request, SearchResponse response) {
    try {
        Thread.sleep(5000);
    } catch (InterruptedException ex) {
        System.err.println("SlowProvider interrupted...");
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:SlowProviderTest.java

示例12: evaluate

import org.netbeans.spi.quicksearch.SearchRequest; //导入依赖的package包/类
@Override
public void evaluate(SearchRequest request, SearchResponse response) {
    String text = removeNonJavaChars(request.getText());
    if(text.length() == 0) {
        return;
    }

    final GoToTypeWorker newWorker = new GoToTypeWorker(text);
    final GoToTypeWorker toCancel = workerRef.getAndSet(newWorker);
    if (toCancel != null) {
        toCancel.cancel();
    }
    try {
        newWorker.run();
    } finally {
        workerRef.compareAndSet(newWorker, null);
    }
    
    for (TypeDescriptor td : newWorker.getTypes()) {
        String displayHint = td.getFileDisplayPath();
        String htmlDisplayName = td.getSimpleName() + td.getContextName();
        final String projectName = td.getProjectName();
        if (projectName != null && !projectName.isEmpty()) {
            htmlDisplayName = String.format(
                "%s [%s]",  //NOI18N
                htmlDisplayName,
                projectName);
        }
        if (!response.addResult(new GoToTypeCommand(td),
                                htmlDisplayName,
                                displayHint,
                                null)) {
            break;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:JavaTypeSearchProvider.java

示例13: evaluate

import org.netbeans.spi.quicksearch.SearchRequest; //导入依赖的package包/类
public void evaluate(SearchRequest request, SearchResponse response) {
    String text = removeNonJavaChars(request.getText());
    if(text.length() == 0) {
        return;
    }
    GoToSymbolWorker local;
    synchronized(this) {
        if (worker!=null) {
            worker.cancel();
        }
        worker = new GoToSymbolWorker(text);
        local = worker;
    }
    local.run();
    
    for (SymbolDescriptor td : local.getTypes()) {
        String displayHint = td.getFileDisplayPath();
        String htmlDisplayName = escapeLtGt(td.getSymbolName()) + " " + NbBundle.getMessage(GoToSymbolAction.class, "MSG_DeclaredIn",escapeLtGt(td.getOwnerName()));
        final String projectName = td.getProjectName();
        if (projectName != null && !projectName.isEmpty()) {
            htmlDisplayName = String.format(
                "%s [%s]",  //NOI18N
                htmlDisplayName,
                projectName);
        }
        if (!response.addResult(new GoToSymbolCommand(td),
                                htmlDisplayName,
                                displayHint,
                                null)) {
            break;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:GoToSymbolProvider.java

示例14: evaluate

import org.netbeans.spi.quicksearch.SearchRequest; //导入依赖的package包/类
@Override public void evaluate(SearchRequest request, SearchResponse response) {
    String text = request.getText();
    if (text == null) {
        return;
    }
    if (!Utilities.isHudsonSupportActive()) {
        return;
    }
    work(text, response);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:SearchProviderImpl.java

示例15: evaluate

import org.netbeans.spi.quicksearch.SearchRequest; //导入依赖的package包/类
/**
 * Shows search results on search bar.
 */
@Override
public void evaluate(SearchRequest request, SearchResponse response) {
    List<FileObject> foundFiles;
    Project project = ProjectUtils.getCurrentProject();
    if (project != null) {
        FileObject projectDirectory = project.getProjectDirectory();
        String fileName = request.getText();
        foundFiles = searchFile(projectDirectory, fileName);
        for (FileObject foundFile : foundFiles) {
            String foundFileName = foundFile.getNameExt();
            response.addResult(new SearchResult(foundFile), foundFileName);
        }
    }
}
 
开发者ID:fundacionjala,项目名称:oblivion-netbeans-plugin,代码行数:18,代码来源:SalesforceSearchProvider.java


注:本文中的org.netbeans.spi.quicksearch.SearchRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。