本文整理汇总了Java中org.netbeans.spi.quicksearch.SearchResponse类的典型用法代码示例。如果您正苦于以下问题:Java SearchResponse类的具体用法?Java SearchResponse怎么用?Java SearchResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SearchResponse类属于org.netbeans.spi.quicksearch包,在下文中一共展示了SearchResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evaluate
import org.netbeans.spi.quicksearch.SearchResponse; //导入依赖的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);
}
示例2: evaluate
import org.netbeans.spi.quicksearch.SearchResponse; //导入依赖的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);
}
}
示例3: evaluate
import org.netbeans.spi.quicksearch.SearchResponse; //导入依赖的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;
}
}
}
}
}
}
}
示例4: work
import org.netbeans.spi.quicksearch.SearchResponse; //导入依赖的package包/类
@Messages({"# {0} - server label", "# {1} - job name", "search_response=Hudson job {1} on {0}"})
private void work(String text, SearchResponse response) {
for (final HudsonInstance instance : HudsonManager.getAllInstances()) {
for (HudsonJob job : instance.getJobs()) {
final String name = job.getName();
// XXX could also search for text in instance name, and/or Maven modules
if (name.toLowerCase(Locale.ENGLISH).contains(text.toLowerCase(Locale.ENGLISH))) {
if (!response.addResult(new Runnable() {
@Override public void run() {
UI.selectNode(instance.getUrl(), name);
}
}, Bundle.search_response(instance.getName(), name))) {
return;
}
}
}
}
}
示例5: findMatches
import org.netbeans.spi.quicksearch.SearchResponse; //导入依赖的package包/类
private List<InputNode> findMatches(String name, String value, InputGraph inputGraph, SearchResponse response) {
try {
RegexpPropertyMatcher matcher = new RegexpPropertyMatcher(name, value, Pattern.CASE_INSENSITIVE);
Properties.PropertySelector<InputNode> selector = new Properties.PropertySelector<>(inputGraph.getNodes());
List<InputNode> matches = selector.selectMultiple(matcher);
return matches.size() == 0 ? null : matches;
} catch (Exception e) {
final String msg = e.getMessage();
response.addResult(new Runnable() {
@Override
public void run() {
Message desc = new NotifyDescriptor.Message("An exception occurred during the search, "
+ "perhaps due to a malformed query string:\n" + msg,
NotifyDescriptor.WARNING_MESSAGE);
DialogDisplayer.getDefault().notify(desc);
}
},
"(Error during search)"
);
}
return null;
}
示例6: evaluate
import org.netbeans.spi.quicksearch.SearchResponse; //导入依赖的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;
}
}
}
}
示例7: doEvaluation
import org.netbeans.spi.quicksearch.SearchResponse; //导入依赖的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;
}
示例8: evaluate
import org.netbeans.spi.quicksearch.SearchResponse; //导入依赖的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;
}
}
示例9: evaluate
import org.netbeans.spi.quicksearch.SearchResponse; //导入依赖的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.SearchResponse; //导入依赖的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: addClearAction
import org.netbeans.spi.quicksearch.SearchResponse; //导入依赖的package包/类
@NbBundle.Messages("RecentSearches.clear=(Clear recent searches)")
private void addClearAction(SearchResponse response) {
boolean add = response.addResult(new Runnable() {
@Override
public void run() {
RecentSearches.getDefault().clear();
}
}, "<html><i>" + Bundle.RecentSearches_clear() + "</i></html>");//NOI18N
}
示例12: evaluate
import org.netbeans.spi.quicksearch.SearchResponse; //导入依赖的package包/类
public void evaluate(SearchRequest request, SearchResponse response) {
try {
Thread.sleep(5000);
} catch (InterruptedException ex) {
System.err.println("SlowProvider interrupted...");
}
}
示例13: evaluate
import org.netbeans.spi.quicksearch.SearchResponse; //导入依赖的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;
}
}
}
示例14: evaluate
import org.netbeans.spi.quicksearch.SearchResponse; //导入依赖的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;
}
}
}
示例15: evaluate
import org.netbeans.spi.quicksearch.SearchResponse; //导入依赖的package包/类
@Override public void evaluate(SearchRequest request, SearchResponse response) {
String text = request.getText();
if (text == null) {
return;
}
if (!Utilities.isHudsonSupportActive()) {
return;
}
work(text, response);
}