I have a IsearchResult
object I need to go throug (iterate) that so as to compare each result.
e.g. I look for (ctrl+H) add method.
and then I have this results' list
I neeed to iterate over this list (it was store int the ISearchResult
object) and compare each result of the query.
I have this code.
NewSearchUI.addQueryListener(new IQueryListener() {
@Override
public void queryStarting(ISearchQuery query) {
System.out.println("query start " + query);
}
@Override
public void queryRemoved(ISearchQuery query) {
}
@Override
public void queryFinished(ISearchQuery query) {
System.out.println("query finished " + query);
System.out.println("result " + query.getSearchResult().getLabel());
query.getSearchResult().addListener(new ISearchResultListener() {
@Override
public void searchResultChanged(SearchResultEvent e) {
}
});
}
@Override
public void queryAdded(ISearchQuery query) {
}
I need to iterate over the results list and compare or extract information of each result.
You can't iterate over the results.
You must add the ISearchResultListener
in the queryStarting
method and save the results as they are given to you in the searchResultChanged
call.
NewSearchUI.addQueryListener(new IQueryListener() {
@Override
public void queryStarting(ISearchQuery query) {
System.out.println("query start " + query);
// Starting listening to the search query
query.getSearchResult().addListener(new ISearchResultListener() {
@Override
public void searchResultChanged(SearchResultEvent e) {
// TODO save the results as they appear
}
});
}
@Override
public void queryRemoved(ISearchQuery query) {
}
@Override
public void queryFinished(ISearchQuery query) {
System.out.println("query finished " + query);
System.out.println("result " + query.getSearchResult().getLabel());
}
@Override
public void queryAdded(ISearchQuery query) {
}