Search in sources :

Example 26 with Configurable

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;
}
Also used : ModuleAttachProcessor(com.intellij.platform.ModuleAttachProcessor) AllIcons(com.intellij.icons.AllIcons) HashMap(java.util.HashMap) ContainerUtil(com.intellij.util.containers.ContainerUtil) Nls(org.jetbrains.annotations.Nls) Map(java.util.Map) Project(com.intellij.openapi.project.Project) Module(com.intellij.openapi.module.Module) ListSelectionEvent(javax.swing.event.ListSelectionEvent) Splitter(com.intellij.openapi.ui.Splitter) JBList(com.intellij.ui.components.JBList) UnnamedConfigurable(com.intellij.openapi.options.UnnamedConfigurable) Configurable(com.intellij.openapi.options.Configurable) CollectionListModel(com.intellij.ui.CollectionListModel) JBScrollPane(com.intellij.ui.components.JBScrollPane) java.awt(java.awt) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) Function(com.intellij.util.Function) ConfigurationException(com.intellij.openapi.options.ConfigurationException) NotNull(org.jetbrains.annotations.NotNull) ListSelectionListener(javax.swing.event.ListSelectionListener) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable) ListSpeedSearch(com.intellij.ui.ListSpeedSearch) javax.swing(javax.swing) Splitter(com.intellij.openapi.ui.Splitter) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ListSelectionListener(javax.swing.event.ListSelectionListener) ListSpeedSearch(com.intellij.ui.ListSpeedSearch) JBList(com.intellij.ui.components.JBList) Module(com.intellij.openapi.module.Module) CollectionListModel(com.intellij.ui.CollectionListModel) JBScrollPane(com.intellij.ui.components.JBScrollPane)

Example 27 with Configurable

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);
}
Also used : Configurable(com.intellij.openapi.options.Configurable)

Example 28 with 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();
        }
    }
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) ColorAndFontOptions(com.intellij.application.options.colors.ColorAndFontOptions) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable) Configurable(com.intellij.openapi.options.Configurable) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable) Settings(com.intellij.openapi.options.ex.Settings)

Example 29 with Configurable

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);
    }
}
Also used : ExtensionsArea(com.intellij.openapi.extensions.ExtensionsArea) Project(com.intellij.openapi.project.Project) ExtensionPoint(com.intellij.openapi.extensions.ExtensionPoint) ArrayList(java.util.ArrayList) Configurable(com.intellij.openapi.options.Configurable) Module(com.intellij.openapi.module.Module)

Example 30 with Configurable

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;
}
Also used : com.intellij.openapi.util(com.intellij.openapi.util) VirtualFileWindow(com.intellij.injected.editor.VirtualFileWindow) UIUtil(com.intellij.util.ui.UIUtil) AbstractTableCellEditor(com.intellij.util.ui.AbstractTableCellEditor) java.util(java.util) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) javax.swing.table(javax.swing.table) LanguagePerFileMappings(com.intellij.lang.LanguagePerFileMappings) PerFileMappingsBase(com.intellij.lang.PerFileMappingsBase) ContainerUtil(com.intellij.util.containers.ContainerUtil) JBLabel(com.intellij.ui.components.JBLabel) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) JBUI(com.intellij.util.ui.JBUI) Project(com.intellij.openapi.project.Project) SpeedSearchUtil(com.intellij.ui.speedSearch.SpeedSearchUtil) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) Messages(com.intellij.openapi.ui.Messages) PerFileMappings(com.intellij.lang.PerFileMappings) FileUtil(com.intellij.openapi.util.io.FileUtil) ComboBoxAction(com.intellij.openapi.actionSystem.ex.ComboBoxAction) TIntArrayList(gnu.trove.TIntArrayList) CustomComponentAction(com.intellij.openapi.actionSystem.ex.CustomComponentAction) VfsUtilCore(com.intellij.openapi.vfs.VfsUtilCore) StringUtil(com.intellij.openapi.util.text.StringUtil) Configurable(com.intellij.openapi.options.Configurable) KeymapUtil(com.intellij.openapi.keymap.KeymapUtil) com.intellij.ui(com.intellij.ui) Collectors(java.util.stream.Collectors) JBPopup(com.intellij.openapi.ui.popup.JBPopup) MouseEvent(java.awt.event.MouseEvent) File(java.io.File) java.awt(java.awt) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) JBTable(com.intellij.ui.table.JBTable) Nullable(org.jetbrains.annotations.Nullable) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) List(java.util.List) IdeBorderFactory(com.intellij.ui.IdeBorderFactory) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) ConfigurationException(com.intellij.openapi.options.ConfigurationException) com.intellij.util(com.intellij.util) NotNull(org.jetbrains.annotations.NotNull) SimpleDataContext(com.intellij.openapi.actionSystem.impl.SimpleDataContext) FileChooser(com.intellij.openapi.fileChooser.FileChooser) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable) javax.swing(javax.swing) MouseEvent(java.awt.event.MouseEvent) JBLabel(com.intellij.ui.components.JBLabel) JBTable(com.intellij.ui.table.JBTable) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Configurable (com.intellij.openapi.options.Configurable)66 SearchableConfigurable (com.intellij.openapi.options.SearchableConfigurable)32 BaseConfigurable (com.intellij.openapi.options.BaseConfigurable)8 NotNull (org.jetbrains.annotations.NotNull)8 ConfigurableGroup (com.intellij.openapi.options.ConfigurableGroup)7 UnnamedConfigurable (com.intellij.openapi.options.UnnamedConfigurable)7 Nullable (org.jetbrains.annotations.Nullable)6 Project (com.intellij.openapi.project.Project)5 ArrayList (java.util.ArrayList)5 ConfigurationException (com.intellij.openapi.options.ConfigurationException)4 ArtifactsStructureConfigurable (com.intellij.openapi.roots.ui.configuration.artifacts.ArtifactsStructureConfigurable)4 ApplicationConfigurable (com.intellij.execution.application.ApplicationConfigurable)3 JUnitConfigurable (com.intellij.execution.junit2.configuration.JUnitConfigurable)3 DataContext (com.intellij.openapi.actionSystem.DataContext)3 Module (com.intellij.openapi.module.Module)3 TabbedConfigurable (com.intellij.openapi.options.TabbedConfigurable)3 Settings (com.intellij.openapi.options.ex.Settings)3 ActionCallback (com.intellij.openapi.util.ActionCallback)3 ExtensionsArea (com.intellij.openapi.extensions.ExtensionsArea)2 CompositeConfigurable (com.intellij.openapi.options.CompositeConfigurable)2