use of com.intellij.openapi.options.Configurable in project intellij-community by JetBrains.
the class ModuleAwareProjectConfigurable method createComponent.
@Override
public JComponent createComponent() {
if (myProject.isDefault()) {
T configurable = createDefaultProjectConfigurable();
if (configurable != null) {
myModuleConfigurables.put(null, configurable);
return configurable.createComponent();
}
}
final List<Module> modules = ContainerUtil.filter(ModuleAttachProcessor.getSortedModules(myProject), module -> isSuitableForModule(module));
final T projectConfigurable = createProjectConfigurable();
if (modules.size() == 1 && projectConfigurable == null) {
Module module = modules.get(0);
final T configurable = createModuleConfigurable(module);
myModuleConfigurables.put(module, configurable);
return configurable.createComponent();
}
final Splitter splitter = new Splitter(false, 0.25f);
CollectionListModel<Module> listDataModel = new CollectionListModel<>(modules);
final JBList moduleList = new JBList(listDataModel);
new ListSpeedSearch(moduleList, (Function<Object, String>) o -> {
if (o == null) {
return getProjectConfigurableItemName();
} else if (o instanceof Module) {
return ((Module) o).getName();
}
return null;
});
moduleList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
moduleList.setCellRenderer(new ModuleListCellRenderer() {
@Override
public void customize(JList list, Module module, int index, boolean selected, boolean hasFocus) {
if (module == null) {
setText(getProjectConfigurableItemName());
setIcon(getProjectConfigurableItemIcon());
} else {
super.customize(list, module, index, selected, hasFocus);
}
}
});
splitter.setFirstComponent(new JBScrollPane(moduleList));
final CardLayout layout = new CardLayout();
final JPanel cardPanel = new JPanel(layout);
splitter.setSecondComponent(cardPanel);
if (projectConfigurable != null) {
myModuleConfigurables.put(null, projectConfigurable);
final JComponent component = projectConfigurable.createComponent();
cardPanel.add(component, PROJECT_ITEM_KEY);
listDataModel.add(0, null);
}
for (Module module : modules) {
final T configurable = createModuleConfigurable(module);
myModuleConfigurables.put(module, configurable);
final JComponent component = configurable.createComponent();
cardPanel.add(component, module.getName());
}
moduleList.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
final Module value = (Module) moduleList.getSelectedValue();
layout.show(cardPanel, value == null ? PROJECT_ITEM_KEY : value.getName());
}
});
if (moduleList.getItemsCount() > 0) {
moduleList.setSelectedIndex(0);
Module module = listDataModel.getElementAt(0);
layout.show(cardPanel, module == null ? PROJECT_ITEM_KEY : module.getName());
}
return splitter;
}
use of com.intellij.openapi.options.Configurable in project intellij-community by JetBrains.
the class TabbedLanguageCodeStylePanel method createTab.
/**
* Creates and adds a tab from CodeStyleSettingsProvider. The provider may return false in hasSettingsPage() method in order not to be
* shown at top level of code style settings.
* @param provider The provider used to create a settings page.
*/
protected final void createTab(CodeStyleSettingsProvider provider) {
if (provider.hasSettingsPage())
return;
Configurable configurable = provider.createSettingsPage(getCurrentSettings(), getSettings());
addTab(configurable);
}
use of com.intellij.openapi.options.Configurable 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.Configurable in project intellij-community by JetBrains.
the class DumpExtensionsAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
List<ExtensionsArea> areas = new ArrayList<>();
areas.add(Extensions.getRootArea());
final Project project = e.getData(CommonDataKeys.PROJECT);
if (project != null) {
areas.add(Extensions.getArea(project));
final Module[] modules = ModuleManager.getInstance(project).getModules();
if (modules.length > 0) {
areas.add(Extensions.getArea(modules[0]));
}
}
System.out.print(areas.size() + " extension areas: ");
for (ExtensionsArea area : areas) {
System.out.print(area.getAreaClass() + " ");
}
System.out.println("\n");
List<ExtensionPoint> points = new ArrayList<>();
for (ExtensionsArea area : areas) {
points.addAll(Arrays.asList(area.getExtensionPoints()));
}
System.out.println(points.size() + " extension points: ");
for (ExtensionPoint point : points) {
System.out.println(" " + point.getName());
}
List<Object> extensions = new ArrayList<>();
for (ExtensionPoint point : points) {
extensions.addAll(Arrays.asList(point.getExtensions()));
}
System.out.println("\n" + extensions.size() + " extensions:");
for (Object extension : extensions) {
if (extension instanceof Configurable) {
System.out.println("!!!! Configurable extension found. Kill it !!!");
}
System.out.println(extension);
}
}
use of com.intellij.openapi.options.Configurable in project intellij-community by JetBrains.
the class PerFileConfigurableBase method createComponent.
@NotNull
@Override
public JComponent createComponent() {
//todo multi-editing, separate project/ide combos _if_ needed by specific configurable (SQL, no Web)
myPanel = new JPanel(new BorderLayout());
myTable = new JBTable(myModel = new MyModel<>(param(TARGET_TITLE), param(MAPPING_TITLE))) {
@Override
public String getToolTipText(@NotNull MouseEvent event) {
Point point = event.getPoint();
int row = rowAtPoint(point);
int col = columnAtPoint(point);
if (row != -1 && col == 1) {
return getToolTipFor((T) getValueAt(convertRowIndexToModel(row), col));
}
return super.getToolTipText(event);
}
};
setupPerFileTable();
JPanel tablePanel = ToolbarDecorator.createDecorator(myTable).disableUpAction().disableDownAction().setAddAction(button -> doAddAction(button)).setRemoveAction(button -> doRemoveAction(button)).setEditAction(button -> doEditAction(button)).setEditActionUpdater(e -> myTable.getSelectedRows().length > 0).createPanel();
myTable.getEmptyText().setText(param(EMPTY_TEXT).replace("$addShortcut", KeymapUtil.getFirstKeyboardShortcutText(CommonActionsPanel.getCommonShortcut(CommonActionsPanel.Buttons.ADD))));
JBLabel label = new JBLabel(param(DESCRIPTION));
label.setBorder(BorderFactory.createEmptyBorder(TITLED_BORDER_TOP_INSET, TITLED_BORDER_INDENT, TITLED_BORDER_BOTTOM_INSET, 0));
label.setComponentStyle(UIUtil.ComponentStyle.SMALL);
JComponent north = createDefaultMappingComponent();
if (north != null) {
myPanel.add(north, BorderLayout.NORTH);
}
myPanel.add(label, BorderLayout.SOUTH);
myPanel.add(tablePanel, BorderLayout.CENTER);
return myPanel;
}
Aggregations