本文整理汇总了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();
}
示例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);
}
示例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);
}
}
示例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;
}
}
}
}
}
}
}
示例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;
}
}
}
}
示例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;
}
示例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;
}
}
示例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;
}
示例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() );
}
示例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);
}
});
}
示例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...");
}
}
示例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;
}
}
}
示例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;
}
}
}
示例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);
}
示例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);
}
}
}