use of com.intellij.openapi.options.MasterDetails in project intellij-community by JetBrains.
the class ConfigurableCardPanel method createConfigurableComponent.
/**
* Creates UI component for the specified configurable.
* If a component is created successfully the configurable will be reset.
* If the configurable implements {@link MasterDetails},
* created component will not have the following modifications.
* If the configurable does not implement {@link Configurable.NoMargin},
* this method sets an empty border with default margins for created component.
* If the configurable does not implement {@link Configurable.NoScroll},
* this method adds a scroll bars for created component.
*/
public static JComponent createConfigurableComponent(Configurable configurable) {
return configurable == null ? null : ApplicationManager.getApplication().runReadAction(new Computable<JComponent>() {
@Override
public JComponent compute() {
JComponent component = null;
long time = System.currentTimeMillis();
try {
component = configurable.createComponent();
} catch (Exception unexpected) {
LOG.error("cannot create configurable component", unexpected);
} finally {
warn(configurable, "create", time);
}
if (component != null) {
reset(configurable);
if (ConfigurableWrapper.cast(MasterDetails.class, configurable) == null) {
if (ConfigurableWrapper.cast(Configurable.NoMargin.class, configurable) == null) {
if (!component.getClass().equals(JPanel.class)) {
// some custom components do not support borders
JPanel panel = new JPanel(new BorderLayout());
panel.add(BorderLayout.CENTER, component);
component = panel;
}
component.setBorder(JBUI.Borders.empty(5, 10, 10, 10));
}
if (ConfigurableWrapper.cast(Configurable.NoScroll.class, configurable) == null) {
JScrollPane scroll = ScrollPaneFactory.createScrollPane(null, true);
scroll.setViewport(new GradientViewport(component, JBUI.insetsTop(5), true));
component = scroll;
}
}
}
return component;
}
});
}
use of com.intellij.openapi.options.MasterDetails in project intellij-community by JetBrains.
the class SearchUtil method processConfigurables.
private static void processConfigurables(Configurable[] configurables, Map<SearchableConfigurable, Set<OptionDescription>> options) {
for (Configurable configurable : configurables) {
if (configurable instanceof SearchableConfigurable) {
//ignore invisible root nodes
if (configurable instanceof SearchableConfigurable.Parent && !((SearchableConfigurable.Parent) configurable).isVisible()) {
continue;
}
Set<OptionDescription> configurableOptions = new TreeSet<>();
options.put((SearchableConfigurable) configurable, configurableOptions);
if (configurable instanceof MasterDetails) {
final MasterDetails md = (MasterDetails) configurable;
md.initUi();
processComponent(configurable, configurableOptions, md.getMaster());
processComponent(configurable, configurableOptions, md.getDetails().getComponent());
} else {
processComponent(configurable, configurableOptions, configurable.createComponent());
}
}
}
}
Aggregations