Search in sources :

Example 6 with Settings

use of com.intellij.openapi.options.ex.Settings in project intellij-community by JetBrains.

the class ScopeColorsPageFactory method createChooseScopePanel.

private static JPanel createChooseScopePanel() {
    Project[] projects = ProjectManager.getInstance().getOpenProjects();
    JPanel panel = new JPanel(new GridBagLayout());
    //panel.setBorder(new LineBorder(Color.red));
    if (projects.length == 0)
        return panel;
    GridBagConstraints gc = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.emptyInsets(), 0, 0);
    JButton button = new JButton("Manage Scopes...");
    button.setPreferredSize(new Dimension(230, button.getPreferredSize().height));
    panel.add(button, gc);
    gc.gridx = GridBagConstraints.REMAINDER;
    gc.weightx = 1;
    panel.add(new JPanel(), gc);
    gc.gridy++;
    gc.gridx = 0;
    gc.weighty = 1;
    panel.add(new JPanel(), gc);
    button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(@NotNull ActionEvent e) {
            DataContext context = DataManager.getInstance().getDataContext(panel);
            Settings settings = Settings.KEY.getData(context);
            Project project = CommonDataKeys.PROJECT.getData(context);
            if (settings != null) {
                try {
                    if (settings.select(settings.find(ScopeChooserConfigurable.PROJECT_SCOPES)).isRejected()) {
                        EditScopesDialog.showDialog(project, null);
                    }
                } catch (IllegalStateException ex) {
                    EditScopesDialog.showDialog(project, null);
                }
            }
        }
    });
    return panel;
}
Also used : ActionEvent(java.awt.event.ActionEvent) Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext) ActionListener(java.awt.event.ActionListener) Settings(com.intellij.openapi.options.ex.Settings)

Example 7 with Settings

use of com.intellij.openapi.options.ex.Settings in project intellij-community by JetBrains.

the class LongLineInspection method createOptionsPanel.

@Nullable
@Override
public JComponent createOptionsPanel() {
    final HyperlinkLabel codeStyleHyperlink = new HyperlinkLabel("Edit Code Style settings");
    codeStyleHyperlink.addHyperlinkListener(new HyperlinkListener() {

        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            DataManager.getInstance().getDataContextFromFocus().doWhenDone(new Consumer<DataContext>() {

                @Override
                public void consume(DataContext context) {
                    if (context != null) {
                        final Settings settings = Settings.KEY.getData(context);
                        if (settings != null) {
                            settings.select(settings.find(CodeStyleSchemesConfigurable.class));
                        } else {
                            ShowSettingsUtil.getInstance().showSettingsDialog(CommonDataKeys.PROJECT.getData(context), CodeStyleSchemesConfigurable.class);
                        }
                    }
                }
            });
        }
    });
    final JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(codeStyleHyperlink, BorderLayout.NORTH);
    return panel;
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) CodeStyleSchemesConfigurable(com.intellij.application.options.CodeStyleSchemesConfigurable) HyperlinkEvent(javax.swing.event.HyperlinkEvent) Consumer(com.intellij.util.Consumer) HyperlinkListener(javax.swing.event.HyperlinkListener) HyperlinkLabel(com.intellij.ui.HyperlinkLabel) Settings(com.intellij.openapi.options.ex.Settings) Nullable(org.jetbrains.annotations.Nullable)

Example 8 with Settings

use of com.intellij.openapi.options.ex.Settings in project android by JetBrains.

the class SdkUpdaterConfigurable method isModified.

@Override
public boolean isModified() {
    if (myPanel.isModified()) {
        return true;
    }
    // If the user modifies the channel, comes back here, and then applies the change, we want to be able to update
    // right away. Thus we mark ourselves as modified if UpdateSettingsConfigurable is modified, and then reload in
    // apply().
    DataContext dataContext = DataManager.getInstance().getDataContext(myPanel.getComponent());
    Settings data = Settings.KEY.getData(dataContext);
    if (data != null) {
        Configurable updatesConfigurable = data.find("preferences.updates");
        if (updatesConfigurable != null) {
            return updatesConfigurable.isModified();
        }
    }
    return false;
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) Configurable(com.intellij.openapi.options.Configurable) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable) Settings(com.intellij.openapi.options.ex.Settings)

Example 9 with Settings

use of com.intellij.openapi.options.ex.Settings in project intellij-elixir by KronicDeth.

the class ElixirCompilerOptionsConfigurable method setupUiListeners.

private void setupUiListeners() {
    myConfigureMixButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            DataContext context = DataManager.getInstance().getDataContext(myConfigureMixButton);
            Settings settings = ObjectUtils.assertNotNull(Settings.KEY.getData(context));
            Configurable configurable = settings.find(ElixirExternalToolsConfigurable.ELIXIR_RELATED_TOOLS);
            if (configurable != null) {
                settings.select(configurable);
            }
        }
    });
    myRootPanel.addAncestorListener(new AncestorAdapter() {

        @Override
        public void ancestorAdded(AncestorEvent event) {
            reset();
        }
    });
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) AncestorAdapter(org.elixir_lang.utils.AncestorAdapter) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) CompilerConfigurable(com.intellij.compiler.options.CompilerConfigurable) ElixirExternalToolsConfigurable(org.elixir_lang.settings.ElixirExternalToolsConfigurable) Configurable(com.intellij.openapi.options.Configurable) AncestorEvent(javax.swing.event.AncestorEvent) Settings(com.intellij.openapi.options.ex.Settings) MixSettings(org.elixir_lang.mix.settings.MixSettings)

Example 10 with Settings

use of com.intellij.openapi.options.ex.Settings in project intellij-community by JetBrains.

the class SingleInspectionProfilePanel method createInspectionProfileSettingsPanel.

private JPanel createInspectionProfileSettingsPanel() {
    myBrowser = new JEditorPane(UIUtil.HTML_MIME, EMPTY_HTML);
    myBrowser.setEditable(false);
    myBrowser.setBorder(IdeBorderFactory.createEmptyBorder(5, 5, 5, 5));
    myBrowser.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        protected void hyperlinkActivated(HyperlinkEvent e) {
            String description = e.getDescription();
            if (description.startsWith(SETTINGS)) {
                String configId = description.substring(SETTINGS.length());
                DataContext context = DataManager.getInstance().getDataContextFromFocus().getResult();
                if (context != null) {
                    Settings settings = Settings.KEY.getData(context);
                    if (settings != null) {
                        settings.select(settings.find(configId));
                    }
                }
            } else {
                BrowserUtil.browse(description);
            }
        }
    });
    initToolStates();
    fillTreeData(myProfileFilter != null ? myProfileFilter.getFilter() : null, true);
    JPanel descriptionPanel = new JPanel(new BorderLayout());
    descriptionPanel.setBorder(IdeBorderFactory.createTitledBorder(InspectionsBundle.message("inspection.description.title"), false, new JBInsets(2, 2, 0, 0)));
    descriptionPanel.add(ScrollPaneFactory.createScrollPane(myBrowser), BorderLayout.CENTER);
    JBSplitter rightSplitter = new JBSplitter(true, "SingleInspectionProfilePanel.HORIZONTAL_DIVIDER_PROPORTION", DIVIDER_PROPORTION_DEFAULT);
    rightSplitter.setFirstComponent(descriptionPanel);
    myOptionsPanel = new JPanel(new GridBagLayout());
    initOptionsAndDescriptionPanel();
    rightSplitter.setSecondComponent(myOptionsPanel);
    rightSplitter.setHonorComponentsMinimumSize(true);
    final JScrollPane tree = initTreeScrollPane();
    final JPanel northPanel = new JPanel(new GridBagLayout());
    northPanel.setBorder(IdeBorderFactory.createEmptyBorder(2, 0, 2, 0));
    myProfileFilter.setPreferredSize(new Dimension(20, myProfileFilter.getPreferredSize().height));
    northPanel.add(myProfileFilter, new GridBagConstraints(0, 0, 1, 1, 0.5, 1, GridBagConstraints.BASELINE_TRAILING, GridBagConstraints.HORIZONTAL, JBUI.emptyInsets(), 0, 0));
    northPanel.add(createTreeToolbarPanel().getComponent(), new GridBagConstraints(1, 0, 1, 1, 1, 1, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL, JBUI.emptyInsets(), 0, 0));
    JBSplitter mainSplitter = new OnePixelSplitter(false, DIVIDER_PROPORTION_DEFAULT, 0.01f, 0.99f);
    mainSplitter.setSplitterProportionKey("SingleInspectionProfilePanel.VERTICAL_DIVIDER_PROPORTION");
    mainSplitter.setFirstComponent(tree);
    mainSplitter.setSecondComponent(rightSplitter);
    mainSplitter.setHonorComponentsMinimumSize(false);
    final JPanel inspectionTreePanel = new JPanel(new BorderLayout());
    inspectionTreePanel.add(northPanel, BorderLayout.NORTH);
    inspectionTreePanel.add(mainSplitter, BorderLayout.CENTER);
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(inspectionTreePanel, BorderLayout.CENTER);
    final JBCheckBox disableNewInspectionsCheckBox = new JBCheckBox("Disable new inspections by default", getProfile().isProfileLocked());
    panel.add(disableNewInspectionsCheckBox, BorderLayout.SOUTH);
    disableNewInspectionsCheckBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            final boolean enabled = disableNewInspectionsCheckBox.isSelected();
            final InspectionProfileImpl profile = getProfile();
            if (profile != null) {
                profile.lockProfile(enabled);
            }
        }
    });
    return panel;
}
Also used : ItemEvent(java.awt.event.ItemEvent) JBInsets(com.intellij.util.ui.JBInsets) JBCheckBox(com.intellij.ui.components.JBCheckBox) ItemListener(java.awt.event.ItemListener) Settings(com.intellij.openapi.options.ex.Settings)

Aggregations

Settings (com.intellij.openapi.options.ex.Settings)10 DataContext (com.intellij.openapi.actionSystem.DataContext)5 SearchableConfigurable (com.intellij.openapi.options.SearchableConfigurable)4 Configurable (com.intellij.openapi.options.Configurable)3 Project (com.intellij.openapi.project.Project)3 KeymapGroup (com.intellij.openapi.keymap.KeymapGroup)2 SettingsDialog (com.intellij.openapi.options.newEditor.SettingsDialog)2 ActionCallback (com.intellij.openapi.util.ActionCallback)2 Pair (com.intellij.openapi.util.Pair)2 MouseEvent (java.awt.event.MouseEvent)2 Map (java.util.Map)2 javax.swing (javax.swing)2 CodeStyleSchemesConfigurable (com.intellij.application.options.CodeStyleSchemesConfigurable)1 ColorAndFontOptions (com.intellij.application.options.colors.ColorAndFontOptions)1 HighlightInfo (com.intellij.codeInsight.daemon.impl.HighlightInfo)1 HintManager (com.intellij.codeInsight.hint.HintManager)1 CompilerConfigurable (com.intellij.compiler.options.CompilerConfigurable)1 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)1 AllIcons (com.intellij.icons.AllIcons)1 DataManager (com.intellij.ide.DataManager)1