use of org.netbeans.modules.quicksearch.ProviderModel.Category in project netbeans-rcp-lite by outersky.
the class RecentSearches method storeRecentToPrefs.
private void storeRecentToPrefs() {
Iterator<ItemResult> it = recent.iterator();
for (int i = 0; i < MAX_ITEMS; i++) {
if (it.hasNext()) {
ItemResult td = it.next();
CategoryResult cr = td.getCategory();
Category category = cr == null ? null : cr.getCategory();
String categoryName = category == null ? null : stripHTMLnames(category.getDisplayName());
prefs().put(RECENT_SEARCHES + i, stripHTMLnames(td.getDisplayName()) + dateSep + td.getDate().getTime() + (categoryName == null ? "" : dateSep + categoryName));
} else {
prefs().put(RECENT_SEARCHES + i, "");
}
}
}
use of org.netbeans.modules.quicksearch.ProviderModel.Category in project netbeans-rcp-lite by outersky.
the class CommandEvaluator method evaluate.
/**
* 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);
}
use of org.netbeans.modules.quicksearch.ProviderModel.Category in project netbeans-rcp-lite by outersky.
the class AbstractQuickSearchComboBar method setShowHint.
private void setShowHint(boolean showHint) {
// remember orig color on first invocation
if (origForeground == null) {
origForeground = command.getForeground();
}
if (showHint) {
command.setForeground(command.getDisabledTextColor());
Set<Category> evalCats = CommandEvaluator.getEvalCats();
if (evalCats.size() < 3 && !CommandEvaluator.isTemporaryCatSpecified()) {
Category bestFound = null;
for (Category c : evalCats) {
if (bestFound == null || CommandEvaluator.RECENT.equals(bestFound.getName())) {
bestFound = c;
}
}
command.setText(getHintText(bestFound));
} else {
command.setText(getHintText(null));
}
} else {
command.setForeground(origForeground);
command.setText("");
}
}
use of org.netbeans.modules.quicksearch.ProviderModel.Category in project netbeans-rcp-lite by outersky.
the class AbstractQuickSearchComboBar method computePrefWidth.
protected int computePrefWidth() {
FontMetrics fm = command.getFontMetrics(command.getFont());
ProviderModel pModel = ProviderModel.getInstance();
int maxWidth = 0;
for (Category cat : pModel.getCategories()) {
// skip recent category
if (CommandEvaluator.RECENT.equals(cat.getName())) {
continue;
}
maxWidth = Math.max(maxWidth, fm.stringWidth(getHintText(cat)));
}
// don't allow width grow too much
return Math.min(350, maxWidth);
}
Aggregations