use of com.intellij.openapi.options.Configurable 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.Configurable in project intellij-community by JetBrains.
the class ConfigurableEditor method requestUpdate.
private void requestUpdate() {
final Configurable configurable = myConfigurable;
myQueue.queue(new Update(this) {
@Override
public void run() {
updateIfCurrent(configurable);
}
@Override
public boolean isExpired() {
return myConfigurable != configurable;
}
});
}
use of com.intellij.openapi.options.Configurable in project intellij-community by JetBrains.
the class ConfigurableEditor method getString.
private static String getString(Configurable configurable, String key) {
JBIterable<Configurable> it = JBIterable.of(configurable).append(JBIterable.of(configurable instanceof Configurable.Composite ? ((Configurable.Composite) configurable).getConfigurables() : null));
ResourceBundle bundle = ConfigurableExtensionPointUtil.getBundle(key, it, null);
return bundle != null ? bundle.getString(key) : null;
}
use of com.intellij.openapi.options.Configurable in project intellij-community by JetBrains.
the class ConfigurableEditor method createDefaultContent.
private JComponent createDefaultContent(Configurable configurable) {
JComponent content = new JPanel(new BorderLayout());
content.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
String key = configurable == null ? null : ConfigurableVisitor.ByID.getID(configurable) + ".settings.description";
String description = key == null ? null : getString(configurable, key);
if (description == null) {
description = "Select configuration element in the tree to edit its settings";
content.add(BorderLayout.CENTER, new JLabel(description, SwingConstants.CENTER));
content.setPreferredSize(JBUI.size(800, 600));
} else {
content.add(BorderLayout.NORTH, new JLabel(description));
if (configurable instanceof Configurable.Composite) {
Configurable.Composite composite = (Configurable.Composite) configurable;
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
content.add(BorderLayout.CENTER, panel);
panel.add(Box.createVerticalStrut(10));
for (Configurable current : composite.getConfigurables()) {
LinkLabel label = LinkLabel.create(current.getDisplayName(), () -> openLink(current));
label.setBorder(BorderFactory.createEmptyBorder(1, 17, 3, 1));
panel.add(label);
}
}
}
return content;
}
use of com.intellij.openapi.options.Configurable in project intellij-community by JetBrains.
the class ConfigurableVisitor method add.
private void add(List<Configurable> list, Configurable... configurables) {
for (Configurable configurable : configurables) {
if (accept(configurable)) {
list.add(configurable);
}
if (configurable instanceof Configurable.Composite) {
Configurable.Composite composite = (Configurable.Composite) configurable;
add(list, composite.getConfigurables());
}
}
}
Aggregations