use of com.intellij.openapi.options.ConfigurableGroup in project intellij-community by JetBrains.
the class SearchableOptionsTest method testFindCodeTemplates.
public void testFindCodeTemplates() {
ConfigurableGroup[] groups = ShowSettingsUtilImpl.getConfigurableGroups(getProject(), false);
ConfigurableHit configurables = SearchableOptionsRegistrar.getInstance().getConfigurables(groups, DocumentEvent.EventType.INSERT, null, "method", getProject());
Set<Configurable> configurableSet = configurables.getAll();
for (Configurable configurable : configurableSet) {
if (configurable.getDisplayName().equals(new AllFileTemplatesConfigurable(getProject()).getDisplayName())) {
return;
}
}
fail("File Templates are not found");
}
use of com.intellij.openapi.options.ConfigurableGroup 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.ConfigurableGroup in project android by JetBrains.
the class IdeSettingsDialogFixture method getProjectSettingsNames.
@NotNull
public List<String> getProjectSettingsNames() {
List<String> names = Lists.newArrayList();
JPanel optionsEditor = field("myEditor").ofType(JPanel.class).in(getDialogWrapper()).get();
List<JComponent> trees = findComponentsOfType(optionsEditor, "com.intellij.openapi.options.newEditor.SettingsTreeView");
assertThat(trees).hasSize(1);
JComponent tree = trees.get(0);
CachingSimpleNode root = field("myRoot").ofType(CachingSimpleNode.class).in(tree).get();
ConfigurableGroup[] groups = field("myGroups").ofType(ConfigurableGroup[].class).in(root).get();
for (ConfigurableGroup current : groups) {
Configurable[] configurables = current.getConfigurables();
for (Configurable configurable : configurables) {
names.add(configurable.getDisplayName());
}
}
return names;
}
use of com.intellij.openapi.options.ConfigurableGroup in project intellij-community by JetBrains.
the class ShowSettingsUtilImpl method showSettingsDialog.
public <T extends Configurable> void showSettingsDialog(@Nullable Project project, @NotNull Class<T> configurableClass, @Nullable Consumer<T> additionalConfiguration) {
assert Configurable.class.isAssignableFrom(configurableClass) : "Not a configurable: " + configurableClass.getName();
ConfigurableGroup[] groups = getConfigurableGroups(project, true);
Configurable config = new ConfigurableVisitor.ByType(configurableClass).find(groups);
assert config != null : "Cannot find configurable: " + configurableClass.getName();
if (additionalConfiguration != null) {
T toConfigure = ConfigurableWrapper.cast(configurableClass, config);
assert toConfigure != null : "Wrong configurable found: " + config.getClass();
additionalConfiguration.accept(toConfigure);
}
getDialog(project, groups, config).show();
}
use of com.intellij.openapi.options.ConfigurableGroup in project intellij-community by JetBrains.
the class ShowSettingsUtilImpl method getConfigurables.
/**
* @param project a project used to load project settings or {@code null}
* @param withIdeSettings specifies whether to load application settings or not
* @return all configurables as a plain list except the root configurable group
*/
@NotNull
public static Configurable[] getConfigurables(@Nullable Project project, boolean withIdeSettings) {
ConfigurableGroup group = ConfigurableExtensionPointUtil.getConfigurableGroup(project, withIdeSettings);
List<Configurable> list = new ArrayList<>();
collect(list, group.getConfigurables());
return list.toArray(new Configurable[0]);
}
Aggregations