本文整理汇总了Java中org.netbeans.spi.quicksearch.SearchRequest.getText方法的典型用法代码示例。如果您正苦于以下问题:Java SearchRequest.getText方法的具体用法?Java SearchRequest.getText怎么用?Java SearchRequest.getText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.spi.quicksearch.SearchRequest
的用法示例。
在下文中一共展示了SearchRequest.getText方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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包/类
@Override public void evaluate(SearchRequest request, SearchResponse response) {
String text = request.getText();
if (text == null) {
return;
}
if (!Utilities.isHudsonSupportActive()) {
return;
}
work(text, response);
}
示例3: 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);
}
}
}