use of com.intellij.ide.ui.search.OptionDescription in project intellij-community by JetBrains.
the class GotoActionAction method openOptionOrPerformAction.
public static void openOptionOrPerformAction(@NotNull Object element, final String enteredText, @Nullable final Project project, Component component, @Nullable AnActionEvent e) {
if (element instanceof OptionDescription) {
OptionDescription optionDescription = (OptionDescription) element;
final String configurableId = optionDescription.getConfigurableId();
Disposable disposable = project != null ? project : ApplicationManager.getApplication();
TransactionGuard guard = TransactionGuard.getInstance();
if (optionDescription.hasExternalEditor()) {
guard.submitTransactionLater(disposable, () -> optionDescription.invokeInternalEditor());
} else {
guard.submitTransactionLater(disposable, () -> ShowSettingsUtilImpl.showSettingsDialog(project, configurableId, enteredText));
}
} else {
ApplicationManager.getApplication().invokeLater(() -> IdeFocusManager.getInstance(project).doWhenFocusSettlesDown(() -> performAction(element, component, e)));
}
}
use of com.intellij.ide.ui.search.OptionDescription in project intellij-community by JetBrains.
the class PluginOptionsTopHitProvider method getOptions.
@NotNull
@Override
public Collection<OptionDescription> getOptions(@Nullable Project project) {
ArrayList<OptionDescription> options = new ArrayList<>();
ApplicationInfoEx applicationInfo = ApplicationInfoEx.getInstanceEx();
for (IdeaPluginDescriptor pluginDescriptor : PluginManagerCore.getPlugins()) {
if (applicationInfo.isEssentialPlugin(pluginDescriptor.getPluginId().getIdString())) {
continue;
}
options.add(new PluginBooleanOptionDescriptor(pluginDescriptor.getPluginId()));
}
return options;
}
use of com.intellij.ide.ui.search.OptionDescription in project intellij-community by JetBrains.
the class InspectionsTopHitProvider method getOptions.
@NotNull
@Override
public Collection<OptionDescription> getOptions(@Nullable Project project) {
if (project == null)
return ContainerUtil.emptyList();
List<OptionDescription> result = ContainerUtil.newArrayList();
List<Tools> tools = InspectionProjectProfileManager.getInstance(project).getCurrentProfile().getAllEnabledInspectionTools(project);
for (Tools tool : tools) {
result.add(new ToolOptionDescription(tool, project));
}
return result;
}
use of com.intellij.ide.ui.search.OptionDescription in project intellij-community by JetBrains.
the class OptionsTopHitProvider method consumeTopHits.
@Override
public final void consumeTopHits(@NonNls String pattern, Consumer<Object> collector, Project project) {
if (!pattern.startsWith("#"))
return;
pattern = pattern.substring(1);
final List<String> parts = StringUtil.split(pattern, " ");
if (parts.size() == 0) {
return;
}
String id = parts.get(0);
if (getId().startsWith(id) || pattern.startsWith(" ")) {
if (pattern.startsWith(" ")) {
pattern = pattern.trim();
} else {
pattern = pattern.substring(id.length()).trim().toLowerCase();
}
final MinusculeMatcher matcher = NameUtil.buildMatcher("*" + pattern, NameUtil.MatchingCaseSensitivity.NONE);
for (OptionDescription option : getOptions(project)) {
if (matcher.matches(option.getOption())) {
collector.consume(option);
}
}
}
}
use of com.intellij.ide.ui.search.OptionDescription in project intellij-community by JetBrains.
the class GotoActionItemProvider method processOptions.
private boolean processOptions(String pattern, Processor<MatchedValue> consumer, DataContext dataContext) {
Map<String, String> map = myModel.getConfigurablesNames();
SearchableOptionsRegistrarImpl registrar = (SearchableOptionsRegistrarImpl) SearchableOptionsRegistrar.getInstance();
List<Comparable> options = ContainerUtil.newArrayList();
final Set<String> words = registrar.getProcessedWords(pattern);
Set<OptionDescription> optionDescriptions = null;
final String actionManagerName = myActionManager.getComponentName();
for (String word : words) {
final Set<OptionDescription> descriptions = registrar.getAcceptableDescriptions(word);
if (descriptions != null) {
for (Iterator<OptionDescription> iterator = descriptions.iterator(); iterator.hasNext(); ) {
OptionDescription description = iterator.next();
if (actionManagerName.equals(description.getPath())) {
iterator.remove();
}
}
if (!descriptions.isEmpty()) {
if (optionDescriptions == null) {
optionDescriptions = descriptions;
} else {
optionDescriptions.retainAll(descriptions);
}
}
} else {
optionDescriptions = null;
break;
}
}
if (!StringUtil.isEmptyOrSpaces(pattern)) {
Matcher matcher = NameUtil.buildMatcher("*" + pattern).build();
if (optionDescriptions == null)
optionDescriptions = ContainerUtil.newTroveSet();
for (Map.Entry<String, String> entry : map.entrySet()) {
if (matcher.matches(entry.getValue())) {
optionDescriptions.add(new OptionDescription(null, entry.getKey(), entry.getValue(), null, entry.getValue()));
}
}
}
if (optionDescriptions != null && !optionDescriptions.isEmpty()) {
Set<String> currentHits = new HashSet<>();
for (Iterator<OptionDescription> iterator = optionDescriptions.iterator(); iterator.hasNext(); ) {
OptionDescription description = iterator.next();
final String hit = description.getHit();
if (hit == null || !currentHits.add(hit.trim())) {
iterator.remove();
}
}
for (OptionDescription description : optionDescriptions) {
for (ActionFromOptionDescriptorProvider converter : ActionFromOptionDescriptorProvider.EP.getExtensions()) {
AnAction action = converter.provide(description);
if (action != null)
options.add(new ActionWrapper(action, null, MatchMode.NAME, dataContext));
options.add(description);
}
}
}
return processItems(pattern, JBIterable.from(options), consumer);
}
Aggregations