diff --git a/java/execution/impl/src/com/intellij/execution/application/ApplicationConfigurable.java b/java/execution/impl/src/com/intellij/execution/application/ApplicationConfigurable.java index 5120973d1109..b8a7db8003c8 100644 --- a/java/execution/impl/src/com/intellij/execution/application/ApplicationConfigurable.java +++ b/java/execution/impl/src/com/intellij/execution/application/ApplicationConfigurable.java @@ -67,7 +67,7 @@ public class ApplicationConfigurable extends SettingsEditor { private final Project myProject; - public ShortenCommandLineModeCombo(Project project, JrePathEditor pathEditor) { + public ShortenCommandLineModeCombo(Project project, + JrePathEditor pathEditor, + ModuleDescriptionsComboBox component) { myProject = project; - initModel(null, pathEditor); + initModel(null, pathEditor, component.getSelectedModule()); setRenderer(new ColoredListCellRenderer() { @Override protected void customizeCellRenderer(@NotNull JList list, @@ -27,7 +33,7 @@ public class ShortenCommandLineModeCombo extends ComboBox { boolean selected, boolean hasFocus) { if (value == null) { - ShortenCommandLine defaultMode = ShortenCommandLine.getDefaultMethod(myProject, getJdkRoot(pathEditor)); + ShortenCommandLine defaultMode = ShortenCommandLine.getDefaultMethod(myProject, getJdkRoot(pathEditor, component.getSelectedModule())); append("user-local default: " + defaultMode.getPresentableName()).append(" - " + defaultMode.getDescription(), SimpleTextAttributes.GRAYED_ATTRIBUTES); } else { @@ -35,16 +41,18 @@ public class ShortenCommandLineModeCombo extends ComboBox { } } }); - pathEditor.addActionListener(e -> { + ActionListener updateModelListener = e -> { Object item = getSelectedItem(); - initModel((ShortenCommandLine)item, pathEditor); - }); + initModel((ShortenCommandLine)item, pathEditor, component.getSelectedModule()); + }; + pathEditor.addActionListener(updateModelListener); + component.addActionListener(updateModelListener); } - private void initModel(ShortenCommandLine preselection, JrePathEditor pathEditor) { + private void initModel(ShortenCommandLine preselection, JrePathEditor pathEditor, Module module) { removeAllItems(); - String jdkRoot = getJdkRoot(pathEditor); + String jdkRoot = getJdkRoot(pathEditor, module); addItem(null); for (ShortenCommandLine mode : ShortenCommandLine.values()) { if (mode.isApplicable(jdkRoot)) { @@ -56,7 +64,11 @@ public class ShortenCommandLineModeCombo extends ComboBox { } @Nullable - private static String getJdkRoot(JrePathEditor pathEditor) { + private static String getJdkRoot(JrePathEditor pathEditor, Module module) { + if (!pathEditor.isAlternativeJreSelected() && module != null) { + Sdk sdk = ModuleRootManager.getInstance(module).getSdk(); + return sdk != null ? sdk.getHomePath() : null; + } String jrePathOrName = pathEditor.getJrePathOrName(); if (jrePathOrName != null) { Sdk configuredJdk = ProjectJdkTable.getInstance().findJdk(jrePathOrName); diff --git a/plugins/junit/src/com/intellij/execution/junit2/configuration/JUnitConfigurable.java b/plugins/junit/src/com/intellij/execution/junit2/configuration/JUnitConfigurable.java index 03c9c53a86ae..cc125632cea0 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/configuration/JUnitConfigurable.java +++ b/plugins/junit/src/com/intellij/execution/junit2/configuration/JUnitConfigurable.java @@ -279,7 +279,7 @@ public class JUnitConfigurable extends SettingsEdi model.addElement(changeList.getName()); } - myShortenClasspathModeCombo.setComponent(new ShortenCommandLineModeCombo(myProject, myJrePathEditor)); + myShortenClasspathModeCombo.setComponent(new ShortenCommandLineModeCombo(myProject, myJrePathEditor, myModule.getComponent())); } private static void addRadioButtonsListeners(final JRadioButton[] radioButtons, ChangeListener listener) { diff --git a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfigurationEditor.form b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfigurationEditor.form index 53c87cef5bdb..e2af53ca655b 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfigurationEditor.form +++ b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfigurationEditor.form @@ -153,7 +153,7 @@ - + diff --git a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfigurationEditor.java b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfigurationEditor.java index bf888824e9cb..a30a1e42b697 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfigurationEditor.java +++ b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfigurationEditor.java @@ -16,7 +16,7 @@ package com.theoryinpractice.testng.configuration; -import com.intellij.application.options.ModulesComboBox; +import com.intellij.application.options.ModuleDescriptionsComboBox; import com.intellij.execution.ExecutionBundle; import com.intellij.execution.JavaExecutionUtil; import com.intellij.execution.MethodBrowser; @@ -76,7 +76,7 @@ public class TestNGConfigurationEditor extends Se private JPanel panel; private LabeledComponent classField; - private LabeledComponent moduleClasspath; + private LabeledComponent moduleClasspath; private JrePathEditor alternateJDK; private final ConfigurationModuleSelector moduleSelector; private JComboBox myTestKind; @@ -203,7 +203,7 @@ public class TestNGConfigurationEditor extends Se commonJavaParameters.setProgramParametersLabel(ExecutionBundle.message("junit.configuration.test.runner.parameters.label")); - myShortenCommandLineCombo.setComponent(new ShortenCommandLineModeCombo(project, alternateJDK)); + myShortenCommandLineCombo.setComponent(new ShortenCommandLineModeCombo(project, alternateJDK, getModulesComponent())); setAnchor(outputDirectory.getLabel()); alternateJDK.setAnchor(moduleClasspath.getLabel()); commonJavaParameters.setAnchor(moduleClasspath.getLabel()); @@ -275,7 +275,7 @@ public class TestNGConfigurationEditor extends Se return classField.getComponent().getText(); } - public ModulesComboBox getModulesComponent() { + public ModuleDescriptionsComboBox getModulesComponent() { return moduleClasspath.getComponent(); } @@ -421,7 +421,6 @@ public class TestNGConfigurationEditor extends Se outputDirectoryButton.addBrowseFolderListener("TestNG", "Select test output directory", project, FileChooserDescriptorFactory.createSingleFolderDescriptor()); moduleClasspath.setEnabled(true); - moduleClasspath.setComponent(new ModulesComboBox()); propertiesTableModel = new TestNGParametersTableModel(); listenerModel = new TestNGListenersTableModel();