Search in sources :

Example 1 with JdkListConfigurable

use of com.intellij.openapi.roots.ui.configuration.projectRoot.JdkListConfigurable in project intellij-community by JetBrains.

the class JdkComboBox method setSetupButton.

public void setSetupButton(final JButton setUpButton, @Nullable final Project project, final ProjectSdksModel jdksModel, final JdkComboBoxItem firstItem, @Nullable final Condition<Sdk> additionalSetup, final String actionGroupTitle) {
    mySetUpButton = setUpButton;
    mySetUpButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            DefaultActionGroup group = new DefaultActionGroup();
            jdksModel.createAddActions(group, JdkComboBox.this, getSelectedJdk(), jdk -> {
                if (project != null) {
                    final JdkListConfigurable configurable = JdkListConfigurable.getInstance(project);
                    configurable.addJdkNode(jdk, false);
                }
                reloadModel(new ActualJdkComboBoxItem(jdk), project);
                setSelectedJdk(jdk);
                if (additionalSetup != null) {
                    if (additionalSetup.value(jdk)) {
                        setSelectedJdk(firstItem.getJdk());
                    }
                }
            }, myCreationFilter);
            final DataContext dataContext = DataManager.getInstance().getDataContext(JdkComboBox.this);
            if (group.getChildrenCount() > 1) {
                JBPopupFactory.getInstance().createActionGroupPopup(actionGroupTitle, group, dataContext, JBPopupFactory.ActionSelectionAid.MNEMONICS, false).showUnderneathOf(setUpButton);
            } else {
                final AnActionEvent event = new AnActionEvent(null, dataContext, ActionPlaces.UNKNOWN, new Presentation(""), ActionManager.getInstance(), 0);
                group.getChildren(event)[0].actionPerformed(event);
            }
        }
    });
}
Also used : Arrays(java.util.Arrays) ActionListener(java.awt.event.ActionListener) Computable(com.intellij.openapi.util.Computable) ContainerUtil(com.intellij.util.containers.ContainerUtil) JBUI(com.intellij.util.ui.JBUI) ComboBoxWithWidePopup(com.intellij.openapi.ui.ComboBoxWithWidePopup) Project(com.intellij.openapi.project.Project) Conditions(com.intellij.openapi.util.Conditions) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) DataManager(com.intellij.ide.DataManager) JdkListConfigurable(com.intellij.openapi.roots.ui.configuration.projectRoot.JdkListConfigurable) ProjectSdksModel(com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel) SdkTypeId(com.intellij.openapi.projectRoots.SdkTypeId) EmptyIcon(com.intellij.util.ui.EmptyIcon) ProjectBundle(com.intellij.openapi.project.ProjectBundle) StringUtil(com.intellij.openapi.util.text.StringUtil) Collection(java.util.Collection) ScreenUtil(com.intellij.ui.ScreenUtil) ActionEvent(java.awt.event.ActionEvent) Sdk(com.intellij.openapi.projectRoots.Sdk) java.awt(java.awt) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) Nullable(org.jetbrains.annotations.Nullable) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) ColoredListCellRenderer(com.intellij.ui.ColoredListCellRenderer) OrderEntryAppearanceService(com.intellij.openapi.roots.ui.OrderEntryAppearanceService) SdkType(com.intellij.openapi.projectRoots.SdkType) NotNull(org.jetbrains.annotations.NotNull) Condition(com.intellij.openapi.util.Condition) javax.swing(javax.swing) ActionListener(java.awt.event.ActionListener) JdkListConfigurable(com.intellij.openapi.roots.ui.configuration.projectRoot.JdkListConfigurable) ActionEvent(java.awt.event.ActionEvent)

Aggregations

DataManager (com.intellij.ide.DataManager)1 com.intellij.openapi.actionSystem (com.intellij.openapi.actionSystem)1 Project (com.intellij.openapi.project.Project)1 ProjectBundle (com.intellij.openapi.project.ProjectBundle)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 SdkType (com.intellij.openapi.projectRoots.SdkType)1 SdkTypeId (com.intellij.openapi.projectRoots.SdkTypeId)1 OrderEntryAppearanceService (com.intellij.openapi.roots.ui.OrderEntryAppearanceService)1 JdkListConfigurable (com.intellij.openapi.roots.ui.configuration.projectRoot.JdkListConfigurable)1 ProjectSdksModel (com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel)1 ComboBoxWithWidePopup (com.intellij.openapi.ui.ComboBoxWithWidePopup)1 JBPopupFactory (com.intellij.openapi.ui.popup.JBPopupFactory)1 Computable (com.intellij.openapi.util.Computable)1 Condition (com.intellij.openapi.util.Condition)1 Conditions (com.intellij.openapi.util.Conditions)1 StringUtil (com.intellij.openapi.util.text.StringUtil)1 ColoredListCellRenderer (com.intellij.ui.ColoredListCellRenderer)1 ScreenUtil (com.intellij.ui.ScreenUtil)1 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)1 ContainerUtil (com.intellij.util.containers.ContainerUtil)1