use of com.intellij.openapi.options.SearchableConfigurable in project intellij-community by JetBrains.
the class SeverityEditorDialog method editColorsAndFonts.
private void editColorsAndFonts() {
final String toConfigure = getSelectedType().getSeverity(null).myName;
if (myCloseDialogWhenSettingsShown) {
doOKAction();
}
myOptionsList.clearSelection();
final DataContext dataContext = DataManager.getInstance().getDataContext(myPanel);
Settings settings = Settings.KEY.getData(dataContext);
if (settings != null) {
ColorAndFontOptions colorAndFontOptions = settings.find(ColorAndFontOptions.class);
assert colorAndFontOptions != null;
final SearchableConfigurable javaPage = colorAndFontOptions.findSubConfigurable(InspectionColorSettingsPage.class);
LOG.assertTrue(javaPage != null);
settings.select(javaPage).doWhenDone(() -> {
final Runnable runnable = javaPage.enableSearch(toConfigure);
if (runnable != null) {
SwingUtilities.invokeLater(runnable);
}
});
} else {
ColorAndFontOptions colorAndFontOptions = new ColorAndFontOptions();
final Configurable[] configurables = colorAndFontOptions.buildConfigurables();
try {
final SearchableConfigurable javaPage = colorAndFontOptions.findSubConfigurable(InspectionColorSettingsPage.class);
LOG.assertTrue(javaPage != null);
ShowSettingsUtil.getInstance().editConfigurable(CommonDataKeys.PROJECT.getData(dataContext), javaPage);
} finally {
for (Configurable configurable : configurables) {
configurable.disposeUIResources();
}
colorAndFontOptions.disposeUIResources();
}
}
}
use of com.intellij.openapi.options.SearchableConfigurable in project intellij-community by JetBrains.
the class TraverseUIStarter method startup.
public static void startup(String outputPath) throws IOException {
Map<SearchableConfigurable, Set<OptionDescription>> options = new LinkedHashMap<>();
try {
SearchUtil.processProjectConfigurables(ProjectManager.getInstance().getDefaultProject(), options);
Element root = new Element(OPTIONS);
for (SearchableConfigurable option : options.keySet()) {
SearchableConfigurable configurable = option;
Element configurableElement = new Element(CONFIGURABLE);
String id = configurable.getId();
configurableElement.setAttribute(ID, id);
configurableElement.setAttribute(CONFIGURABLE_NAME, configurable.getDisplayName());
Set<OptionDescription> sortedOptions = options.get(configurable);
writeOptions(configurableElement, sortedOptions);
if (configurable instanceof ConfigurableWrapper) {
UnnamedConfigurable wrapped = ((ConfigurableWrapper) configurable).getConfigurable();
if (wrapped instanceof SearchableConfigurable) {
configurable = (SearchableConfigurable) wrapped;
}
}
if (configurable instanceof KeymapPanel) {
processKeymap(configurableElement);
} else if (configurable instanceof OptionsContainingConfigurable) {
processOptionsContainingConfigurable((OptionsContainingConfigurable) configurable, configurableElement);
} else if (configurable instanceof PluginManagerConfigurable) {
for (OptionDescription description : wordsToOptionDescriptors(Collections.singleton(AvailablePluginsManagerMain.MANAGE_REPOSITORIES))) {
append(null, AvailablePluginsManagerMain.MANAGE_REPOSITORIES, description.getOption(), configurableElement);
}
} else if (configurable instanceof AllFileTemplatesConfigurable) {
processFileTemplates(configurableElement);
}
root.addContent(configurableElement);
}
FileUtil.ensureCanCreateFile(new File(outputPath));
JDOMUtil.writeDocument(new Document(root), outputPath, "\n");
System.out.println("Searchable options index builder completed");
} finally {
for (SearchableConfigurable configurable : options.keySet()) {
configurable.disposeUIResources();
}
}
}
use of com.intellij.openapi.options.SearchableConfigurable in project intellij-community by JetBrains.
the class JumpToColorsAndFontsAction method openSettingsAndSelectKey.
private static boolean openSettingsAndSelectKey(@NotNull Project project, @NotNull ColorSettingsPage page, @NotNull AttributesDescriptor descriptor) {
SettingsDialog dialog = (SettingsDialog) ShowSettingsUtilImpl.getDialog(project, ShowSettingsUtilImpl.getConfigurableGroups(project, true), null);
Settings settings = Settings.KEY.getData(dialog);
ColorAndFontOptions configurable0 = settings == null ? null : settings.find(ColorAndFontOptions.class);
SearchableConfigurable configurable = configurable0 == null ? null : configurable0.findSubConfigurable(page.getDisplayName());
if (configurable == null)
return false;
Runnable runnable = configurable.enableSearch(descriptor.getDisplayName());
ActionCallback callback = settings.select(configurable);
if (runnable != null)
callback.doWhenDone(runnable);
dialog.show();
return true;
}
use of com.intellij.openapi.options.SearchableConfigurable in project intellij-community by JetBrains.
the class SearchableOptionsRegistrarImpl method getConfigurables.
@Override
@NotNull
public ConfigurableHit getConfigurables(ConfigurableGroup[] groups, final DocumentEvent.EventType type, Set<Configurable> configurables, String option, Project project) {
final ConfigurableHit hits = new ConfigurableHit();
final Set<Configurable> contentHits = hits.getContentHits();
Set<String> options = getProcessedWordsWithoutStemming(option);
if (configurables == null) {
for (ConfigurableGroup group : groups) {
contentHits.addAll(SearchUtil.expandGroup(group));
}
} else {
contentHits.addAll(configurables);
}
String optionToCheck = option.trim().toLowerCase();
for (Configurable each : contentHits) {
if (each.getDisplayName() == null)
continue;
final String displayName = each.getDisplayName().toLowerCase();
final List<String> allWords = StringUtil.getWordsIn(displayName);
if (displayName.contains(optionToCheck)) {
hits.getNameFullHits().add(each);
hits.getNameHits().add(each);
}
for (String eachWord : allWords) {
if (eachWord.startsWith(optionToCheck)) {
hits.getNameHits().add(each);
break;
}
}
if (options.isEmpty()) {
hits.getNameHits().add(each);
hits.getNameFullHits().add(each);
}
}
final Set<Configurable> currentConfigurables = new HashSet<>(contentHits);
if (options.isEmpty()) {
//operate with substring
String[] components = REG_EXP.split(optionToCheck);
if (components.length > 0) {
Collections.addAll(options, components);
} else {
options.add(option);
}
}
Set<String> helpIds = null;
for (String opt : options) {
final Set<OptionDescription> optionIds = getAcceptableDescriptions(opt);
if (optionIds == null) {
contentHits.clear();
return hits;
}
final Set<String> ids = new HashSet<>();
for (OptionDescription id : optionIds) {
ids.add(id.getConfigurableId());
}
if (helpIds == null) {
helpIds = ids;
}
helpIds.retainAll(ids);
}
if (helpIds != null) {
for (Iterator<Configurable> it = contentHits.iterator(); it.hasNext(); ) {
Configurable configurable = it.next();
if (CodeStyleFacade.getInstance(project).isUnsuitableCodeStyleConfigurable(configurable)) {
it.remove();
continue;
}
if (!(configurable instanceof SearchableConfigurable && helpIds.contains(((SearchableConfigurable) configurable).getId()))) {
it.remove();
}
}
}
if (currentConfigurables.equals(contentHits) && !(configurables == null && type == DocumentEvent.EventType.CHANGE)) {
return getConfigurables(groups, DocumentEvent.EventType.CHANGE, null, option, project);
}
return hits;
}
use of com.intellij.openapi.options.SearchableConfigurable in project intellij-community by JetBrains.
the class SearchEverywhereAction method fillConfigurablesIds.
private void fillConfigurablesIds(String pathToParent, Configurable[] configurables) {
for (Configurable configurable : configurables) {
if (configurable instanceof SearchableConfigurable) {
final String id = ((SearchableConfigurable) configurable).getId();
String name = configurable.getDisplayName();
if (pathToParent != null) {
name = pathToParent + " -> " + name;
}
myConfigurables.put(id, name);
if (configurable instanceof SearchableConfigurable.Parent) {
fillConfigurablesIds(name, ((SearchableConfigurable.Parent) configurable).getConfigurables());
}
}
}
}
Aggregations