mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
run configurations: refactoring
This commit is contained in:
+5
-11
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.execution.application.ApplicationConfigurable">
|
||||
<grid id="93687" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="7" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="10">
|
||||
<grid id="93687" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="6" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="10">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="53" y="36" width="470" height="424"/>
|
||||
@@ -10,7 +10,7 @@
|
||||
<children>
|
||||
<vspacer id="eeb03">
|
||||
<constraints>
|
||||
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="50b09" class="com.intellij.execution.ui.CommonJavaParametersPanel" binding="myCommonProgramParameters">
|
||||
@@ -30,7 +30,7 @@
|
||||
</component>
|
||||
<component id="c45d2" class="com.intellij.openapi.ui.LabeledComponent" binding="myModule">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="2" 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="javax.swing.JComboBox"/>
|
||||
@@ -39,23 +39,17 @@
|
||||
</component>
|
||||
<component id="e88bd" class="com.intellij.execution.ui.AlternativeJREPanel" binding="myAlternativeJREPanel">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</component>
|
||||
<component id="b45cf" class="javax.swing.JCheckBox" binding="myShowSwingInspectorCheckbox">
|
||||
<constraints>
|
||||
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/ExecutionBundle" key="show.swing.inspector"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="2e57d" class="com.intellij.execution.configuration.EnvironmentVariablesComponent" binding="myEnvVariablesComponent">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
-8
@@ -16,7 +16,6 @@
|
||||
package com.intellij.execution.application;
|
||||
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.configuration.EnvironmentVariablesComponent;
|
||||
import com.intellij.execution.ui.AlternativeJREPanel;
|
||||
import com.intellij.execution.ui.ClassBrowser;
|
||||
import com.intellij.execution.ui.CommonJavaParametersPanel;
|
||||
@@ -42,7 +41,6 @@ public class ApplicationConfigurable extends SettingsEditor<ApplicationConfigura
|
||||
private final ConfigurationModuleSelector myModuleSelector;
|
||||
private AlternativeJREPanel myAlternativeJREPanel;
|
||||
private JCheckBox myShowSwingInspectorCheckbox;
|
||||
private EnvironmentVariablesComponent myEnvVariablesComponent;
|
||||
private final JreVersionDetector myVersionDetector = new JreVersionDetector();
|
||||
|
||||
public ApplicationConfigurable(final Project project) {
|
||||
@@ -63,9 +61,6 @@ public class ApplicationConfigurable extends SettingsEditor<ApplicationConfigura
|
||||
configuration.ALTERNATIVE_JRE_PATH_ENABLED = myAlternativeJREPanel.isPathEnabled();
|
||||
configuration.ENABLE_SWING_INSPECTOR = myVersionDetector.isJre50Configured(configuration) && myShowSwingInspectorCheckbox.isSelected();
|
||||
|
||||
configuration.setEnvs(myEnvVariablesComponent.getEnvs());
|
||||
configuration.PASS_PARENT_ENVS = myEnvVariablesComponent.isPassParentEnvs();
|
||||
|
||||
updateShowSwingInspector(configuration);
|
||||
}
|
||||
|
||||
@@ -75,9 +70,6 @@ public class ApplicationConfigurable extends SettingsEditor<ApplicationConfigura
|
||||
getMainClassField().setText(configuration.MAIN_CLASS_NAME);
|
||||
myAlternativeJREPanel.init(configuration.ALTERNATIVE_JRE_PATH, configuration.ALTERNATIVE_JRE_PATH_ENABLED);
|
||||
|
||||
myEnvVariablesComponent.setEnvs(configuration.getEnvs());
|
||||
myEnvVariablesComponent.setPassParentEnvs(configuration.PASS_PARENT_ENVS);
|
||||
|
||||
updateShowSwingInspector(configuration);
|
||||
}
|
||||
|
||||
|
||||
+16
-8
@@ -169,6 +169,22 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
|
||||
return ExternalizablePath.localPathValue(WORKING_DIRECTORY);
|
||||
}
|
||||
|
||||
public void setPassParentEnvs(boolean passParentEnvs) {
|
||||
PASS_PARENT_ENVS = passParentEnvs;
|
||||
}
|
||||
|
||||
public Map<String, String> getEnvs() {
|
||||
return myEnvs;
|
||||
}
|
||||
|
||||
public void setEnvs(final Map<String, String> envs) {
|
||||
this.myEnvs = envs;
|
||||
}
|
||||
|
||||
public boolean isPassParentEnvs() {
|
||||
return PASS_PARENT_ENVS;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getRunClass() {
|
||||
return MAIN_CLASS_NAME;
|
||||
@@ -221,14 +237,6 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
|
||||
PathMacroManager.getInstance(getProject()).collapsePathsRecursively(element);
|
||||
}
|
||||
|
||||
public Map<String, String> getEnvs() {
|
||||
return myEnvs;
|
||||
}
|
||||
|
||||
public void setEnvs(final Map<String, String> envs) {
|
||||
this.myEnvs = envs;
|
||||
}
|
||||
|
||||
private class MyJavaCommandLineState extends JavaCommandLineState {
|
||||
public MyJavaCommandLineState(final ExecutionEnvironment environment) {
|
||||
super(environment);
|
||||
|
||||
@@ -20,8 +20,6 @@ import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.openapi.ui.LabeledComponent;
|
||||
import com.intellij.ui.RawCommandLineEditor;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class CommonJavaParametersPanel extends CommonProgramParametersPanel {
|
||||
private LabeledComponent<RawCommandLineEditor> myVMParameters;
|
||||
|
||||
@@ -30,16 +28,13 @@ public class CommonJavaParametersPanel extends CommonProgramParametersPanel {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addComponents(GridBagConstraints c) {
|
||||
protected void addComponents() {
|
||||
myVMParameters = LabeledComponent.create(new RawCommandLineEditor(),
|
||||
ExecutionBundle.message("run.configuration.java.vm.parameters.label"));
|
||||
copyDialogCaption(myVMParameters);
|
||||
|
||||
|
||||
c.gridy++;
|
||||
add(myVMParameters, c);
|
||||
|
||||
super.addComponents(c);
|
||||
add(myVMParameters);
|
||||
super.addComponents();
|
||||
}
|
||||
|
||||
public void setVMParameters(String text) {
|
||||
|
||||
@@ -33,7 +33,6 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiFile;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -51,18 +50,14 @@ public class JavaParametersUtil {
|
||||
String vmParameters = configuration.getVMParameters();
|
||||
if (vmParameters != null) {
|
||||
vmParameters = ProgramParametersUtil.expandPath(vmParameters, module, project);
|
||||
}
|
||||
if (parameters.getEnv() != null) {
|
||||
final Map<String, String> envs = new HashMap<String, String>();
|
||||
for (String env : parameters.getEnv().keySet()) {
|
||||
final String value = ProgramParametersUtil.expandPath(parameters.getEnv().get(env), module, project);
|
||||
envs.put(env, value);
|
||||
if (vmParameters != null) {
|
||||
vmParameters = StringUtil.replace(vmParameters, "$" + env + "$", value, false); //replace env usages
|
||||
|
||||
if (parameters.getEnv() != null) {
|
||||
for (Map.Entry<String, String> each : parameters.getEnv().entrySet()) {
|
||||
vmParameters = StringUtil.replace(vmParameters, "$" + each.getKey() + "$", each.getValue(), false); //replace env usages
|
||||
}
|
||||
}
|
||||
parameters.setEnv(envs);
|
||||
}
|
||||
|
||||
parameters.getVMParametersList().addParametersString(vmParameters);
|
||||
}
|
||||
|
||||
@@ -71,8 +66,8 @@ public class JavaParametersUtil {
|
||||
final Module module = configurationModule.getModule();
|
||||
if (module == null) throw CantRunException.noModuleConfigured(configurationModule.getModuleName());
|
||||
final PsiClass psiClass = JavaExecutionUtil.findMainClass(module, mainClassName);
|
||||
if (psiClass == null) {
|
||||
if ( ! classMustHaveSource ) return JavaParameters.JDK_AND_CLASSES_AND_TESTS;
|
||||
if (psiClass == null) {
|
||||
if (!classMustHaveSource) return JavaParameters.JDK_AND_CLASSES_AND_TESTS;
|
||||
throw CantRunException.classNotFound(mainClassName, module);
|
||||
}
|
||||
final PsiFile psiFile = psiClass.getContainingFile();
|
||||
@@ -96,7 +91,8 @@ public class JavaParametersUtil {
|
||||
parameters.configureByModule(module, classPathType, createModuleJdk(module, jreHome));
|
||||
}
|
||||
|
||||
public static void configureProject(Project project, final JavaParameters parameters, final int classPathType, final String jreHome) throws CantRunException {
|
||||
public static void configureProject(Project project, final JavaParameters parameters, final int classPathType, final String jreHome)
|
||||
throws CantRunException {
|
||||
parameters.configureByProject(project, classPathType, createProjectJdk(project, jreHome));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user