mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
run configurations: correctly handle unloaded modules in 'Use classpath of' combobox in Remote and JUnit configurations
Previously combobox model supported only loaded modules, so if some run configuration referred to an unloaded module, it lost its value after ConfigurationModuleSelector#reset/applyTo. (IDEA-174456)
This commit is contained in:
@@ -160,7 +160,7 @@
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<componentClass value="com.intellij.application.options.ModulesComboBox"/>
|
||||
<componentClass value="com.intellij.application.options.ModuleDescriptionsComboBox"/>
|
||||
<labelLocation value="West"/>
|
||||
<text value="Search sources using m&odule's classpath:" noi18n="true"/>
|
||||
<visible value="true"/>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package com.intellij.execution.remote;
|
||||
|
||||
import com.intellij.application.options.ModulesComboBox;
|
||||
import com.intellij.application.options.ModuleDescriptionsComboBox;
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.configurations.RemoteConnection;
|
||||
import com.intellij.execution.ui.ConfigurationArgumentsHelpArea;
|
||||
@@ -53,7 +53,7 @@ public class RemoteConfigurable extends SettingsEditor<RemoteConfiguration> {
|
||||
private ConfigurationArgumentsHelpArea myHelpArea;
|
||||
@NonNls private ConfigurationArgumentsHelpArea myJDK13HelpArea;
|
||||
private ConfigurationArgumentsHelpArea myJDK14HelpArea;
|
||||
private LabeledComponent<ModulesComboBox> myModule;
|
||||
private LabeledComponent<ModuleDescriptionsComboBox> myModule;
|
||||
private String myHostName = "";
|
||||
@NonNls
|
||||
protected static final String LOCALHOST = "localhost";
|
||||
@@ -128,8 +128,9 @@ public class RemoteConfigurable extends SettingsEditor<RemoteConfiguration> {
|
||||
};
|
||||
myAddressField.addFocusListener(fieldFocusListener);
|
||||
myPortField.addFocusListener(fieldFocusListener);
|
||||
|
||||
myModuleSelector = new ConfigurationModuleSelector(project, myModule.getComponent(), "<whole project>");
|
||||
|
||||
myModule.getComponent().allowEmptySelection("<whole project>");
|
||||
myModuleSelector = new ConfigurationModuleSelector(project, myModule.getComponent());
|
||||
}
|
||||
|
||||
public void applyEditorTo(@NotNull final RemoteConfiguration configuration) throws ConfigurationException {
|
||||
|
||||
@@ -37,6 +37,7 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class ConfigurationModuleSelector {
|
||||
public static final String NO_MODULE_TEXT = "<no module>";
|
||||
private final Project myProject;
|
||||
/** this field is {@code null} if and only if {@link #myModulesList} is not null */
|
||||
private final ModuleDescriptionsComboBox myModulesDescriptionsComboBox;
|
||||
@@ -47,17 +48,22 @@ public class ConfigurationModuleSelector {
|
||||
* @deprecated use {@link #ConfigurationModuleSelector(Project, ModulesComboBox)} instead
|
||||
*/
|
||||
public ConfigurationModuleSelector(final Project project, final JComboBox<Module> modulesList) {
|
||||
this(project, modulesList, "<no module>");
|
||||
this(project, modulesList, NO_MODULE_TEXT);
|
||||
}
|
||||
|
||||
public ConfigurationModuleSelector(Project project, ModulesComboBox modulesComboBox) {
|
||||
this(project, modulesComboBox, "<no module>");
|
||||
this(project, modulesComboBox, NO_MODULE_TEXT);
|
||||
}
|
||||
|
||||
public ConfigurationModuleSelector(Project project, ModuleDescriptionsComboBox modulesDescriptionsComboBox) {
|
||||
this(project, modulesDescriptionsComboBox, NO_MODULE_TEXT);
|
||||
}
|
||||
|
||||
public ConfigurationModuleSelector(Project project, ModuleDescriptionsComboBox modulesDescriptionsComboBox, String emptySelectionText) {
|
||||
myProject = project;
|
||||
myModulesDescriptionsComboBox = modulesDescriptionsComboBox;
|
||||
myModulesList = null;
|
||||
modulesDescriptionsComboBox.allowEmptySelection(emptySelectionText);
|
||||
}
|
||||
|
||||
public ConfigurationModuleSelector(Project project, ModulesComboBox modulesComboBox, String noModule) {
|
||||
|
||||
@@ -46,6 +46,10 @@ abstract class DefaultJreSelector {
|
||||
fun fromModuleDependencies(moduleComboBox: ModulesComboBox, productionOnly: Boolean): DefaultJreSelector
|
||||
= SdkFromModuleDependencies(moduleComboBox, ModulesComboBox::getSelectedModule, {productionOnly})
|
||||
|
||||
@JvmStatic
|
||||
fun fromModuleDependencies(moduleComboBox: ModuleDescriptionsComboBox, productionOnly: Boolean): DefaultJreSelector
|
||||
= SdkFromModuleDependencies(moduleComboBox, ModuleDescriptionsComboBox::getSelectedModule, {productionOnly})
|
||||
|
||||
@JvmStatic
|
||||
fun fromSourceRootsDependencies(moduleComboBox: ModulesComboBox, classSelector: EditorTextFieldWithBrowseButton): DefaultJreSelector
|
||||
= SdkFromSourceRootDependencies(moduleComboBox, ModulesComboBox::getSelectedModule, classSelector)
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.java.execution;
|
||||
|
||||
import com.intellij.application.options.ModuleDescriptionsComboBox;
|
||||
import com.intellij.execution.CantRunException;
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.RunConfigurationConfigurableAdapter;
|
||||
@@ -62,7 +63,6 @@ import com.intellij.util.containers.ContainerUtilRt;
|
||||
import junit.framework.TestCase;
|
||||
import org.jdom.Element;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -127,12 +127,12 @@ public class ConfigurationsTest extends BaseConfigurationTestCase {
|
||||
JUnitConfiguration configuration = createConfiguration(findTestA(module2));
|
||||
editor.getComponent(); // To get all the watchers installed.
|
||||
Configurable configurable = new RunConfigurationConfigurableAdapter(editor, configuration);
|
||||
JComboBox comboBox = editor.getModulesComponent();
|
||||
ModuleDescriptionsComboBox comboBox = editor.getModulesComponent();
|
||||
configurable.reset();
|
||||
assertFalse(configurable.isModified());
|
||||
assertEquals(module2.getName(), ((Module)comboBox.getSelectedItem()).getName());
|
||||
assertEquals(module2.getName(), comboBox.getSelectedModuleName());
|
||||
assertEquals(ModuleManager.getInstance(myProject).getModules().length + 1, comboBox.getModel().getSize()); //no module
|
||||
comboBox.setSelectedItem(module1);
|
||||
comboBox.setSelectedModule(module1);
|
||||
assertTrue(configurable.isModified());
|
||||
configurable.apply();
|
||||
assertFalse(configurable.isModified());
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<componentClass value="com.intellij.application.options.ModulesComboBox"/>
|
||||
<componentClass value="com.intellij.application.options.ModuleDescriptionsComboBox"/>
|
||||
<enabled value="true"/>
|
||||
<labelLocation value="West"/>
|
||||
<text resource-bundle="messages/ExecutionBundle" key="application.configuration.use.classpath.and.jdk.of.module.label"/>
|
||||
|
||||
+3
-3
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.intellij.execution.junit2.configuration;
|
||||
|
||||
import com.intellij.application.options.ModulesComboBox;
|
||||
import com.intellij.application.options.ModuleDescriptionsComboBox;
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.MethodBrowser;
|
||||
import com.intellij.execution.configuration.BrowseModuleValueActionListener;
|
||||
@@ -94,7 +94,7 @@ public class JUnitConfigurable<T extends JUnitConfiguration> extends SettingsEdi
|
||||
private LabeledComponent<EditorTextFieldWithBrowseButton> myCategory;
|
||||
// Fields
|
||||
private JPanel myWholePanel;
|
||||
private LabeledComponent<ModulesComboBox> myModule;
|
||||
private LabeledComponent<ModuleDescriptionsComboBox> myModule;
|
||||
private CommonJavaParametersPanel myCommonJavaParameters;
|
||||
private JRadioButton myWholeProjectScope;
|
||||
private JRadioButton mySingleModuleScope;
|
||||
@@ -445,7 +445,7 @@ public class JUnitConfigurable<T extends JUnitConfiguration> extends SettingsEdi
|
||||
return new DefaultComboBoxModel(RepeatCount.ONCE.equals(myRepeatCb.getSelectedItem()) ? FORK_MODE : FORK_MODE_ALL);
|
||||
}
|
||||
|
||||
public ModulesComboBox getModulesComponent() {
|
||||
public ModuleDescriptionsComboBox getModulesComponent() {
|
||||
return myModule.getComponent();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user