mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
option to choose shortening command line method (IDEA-154486; IDEA-165929)
This commit is contained in:
+13
@@ -37,4 +37,17 @@ public interface CommonJavaRunConfigurationParameters extends CommonProgramRunCo
|
||||
|
||||
@Nullable
|
||||
String getPackage();
|
||||
|
||||
/**
|
||||
* @return null if option was not selected explicitly, legacy user-local options to be used
|
||||
*/
|
||||
@Nullable
|
||||
default ShortenClasspath getShortenClasspath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from UI, when user explicitly selects method to be used to shorten the command line or from the deserialization
|
||||
*/
|
||||
default void setShortenClasspath(ShortenClasspath mode) {}
|
||||
}
|
||||
|
||||
@@ -21,15 +21,21 @@ import com.intellij.execution.configurations.ModuleBasedConfiguration;
|
||||
import com.intellij.execution.configurations.RefactoringListenerProvider;
|
||||
import com.intellij.execution.testframework.TestSearchScope;
|
||||
import com.intellij.execution.testframework.sm.runner.SMRunnerConsolePropertiesProvider;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class JavaTestConfigurationBase extends ModuleBasedConfiguration<JavaRunConfigurationModule>
|
||||
implements CommonJavaRunConfigurationParameters, RefactoringListenerProvider, SMRunnerConsolePropertiesProvider {
|
||||
private ShortenClasspath myShortenClasspath = null;
|
||||
|
||||
public JavaTestConfigurationBase(String name,
|
||||
@NotNull JavaRunConfigurationModule configurationModule,
|
||||
@NotNull ConfigurationFactory factory) {
|
||||
@@ -57,4 +63,27 @@ public abstract class JavaTestConfigurationBase extends ModuleBasedConfiguration
|
||||
}
|
||||
|
||||
public abstract TestSearchScope getTestSearchScope();
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ShortenClasspath getShortenClasspath() {
|
||||
return myShortenClasspath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShortenClasspath(ShortenClasspath shortenClasspath) {
|
||||
myShortenClasspath = shortenClasspath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readExternal(Element element) throws InvalidDataException {
|
||||
super.readExternal(element);
|
||||
setShortenClasspath(ShortenClasspath.readShortenClasspathMethod(element));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExternal(Element element) throws WriteExternalException {
|
||||
super.writeExternal(element);
|
||||
ShortenClasspath.writeShortenClasspathMethod(element, myShortenClasspath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,10 +194,10 @@ public abstract class JavaTestFrameworkRunnableState<T extends
|
||||
@Override
|
||||
protected JavaParameters createJavaParameters() throws ExecutionException {
|
||||
final JavaParameters javaParameters = new JavaParameters();
|
||||
javaParameters.setUseClasspathJar(true);
|
||||
Project project = getConfiguration().getProject();
|
||||
javaParameters.setShortenClasspath(getConfiguration().getShortenClasspath(), project);
|
||||
final Module module = getConfiguration().getConfigurationModule().getModule();
|
||||
|
||||
Project project = getConfiguration().getProject();
|
||||
Sdk jdk = module == null ? ProjectRootManager.getInstance(project).getProjectSdk() : ModuleRootManager.getInstance(module).getSdk();
|
||||
javaParameters.setJdk(jdk);
|
||||
|
||||
|
||||
+11
-2
@@ -3,7 +3,7 @@
|
||||
<grid id="93687" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="8" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="53" y="36" width="708" height="319"/>
|
||||
<xy x="53" y="36" width="708" height="326"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -63,11 +63,20 @@
|
||||
</vspacer>
|
||||
<vspacer id="7cceb">
|
||||
<constraints>
|
||||
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
|
||||
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="-1" height="10"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="c452d2" class="com.intellij.openapi.ui.LabeledComponent" binding="myShortenClasspathModeCombo" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="5" 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>
|
||||
<labelLocation value="West"/>
|
||||
<text resource-bundle="messages/ExecutionBundle" key="application.configuration.shorten.command.line.label"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
+9
-1
@@ -18,6 +18,7 @@ package com.intellij.execution.application;
|
||||
import com.intellij.application.options.ModuleDescriptionsComboBox;
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.JavaExecutionUtil;
|
||||
import com.intellij.execution.ShortenClasspath;
|
||||
import com.intellij.execution.configurations.ConfigurationUtil;
|
||||
import com.intellij.execution.ui.*;
|
||||
import com.intellij.execution.util.JreVersionDetector;
|
||||
@@ -43,6 +44,7 @@ public class ApplicationConfigurable extends SettingsEditor<ApplicationConfigura
|
||||
private CommonJavaParametersPanel myCommonProgramParameters;
|
||||
private LabeledComponent<EditorTextFieldWithBrowseButton> myMainClass;
|
||||
private LabeledComponent<ModuleDescriptionsComboBox> myModule;
|
||||
private LabeledComponent<ShortenClasspathModeCombo> myShortenClasspathModeCombo;
|
||||
private JPanel myWholePanel;
|
||||
|
||||
private final ConfigurationModuleSelector myModuleSelector;
|
||||
@@ -65,7 +67,8 @@ public class ApplicationConfigurable extends SettingsEditor<ApplicationConfigura
|
||||
ClassBrowser.createApplicationClassBrowser(project, myModuleSelector).setField(getMainClassField());
|
||||
myVersionDetector = new JreVersionDetector();
|
||||
|
||||
myAnchor = UIUtil.mergeComponentsWithAnchor(myMainClass, myCommonProgramParameters, myJrePathEditor, myModule);
|
||||
myAnchor = UIUtil.mergeComponentsWithAnchor(myMainClass, myCommonProgramParameters, myJrePathEditor, myModule,
|
||||
myShortenClasspathModeCombo);
|
||||
}
|
||||
|
||||
public void applyEditorTo(@NotNull final ApplicationConfiguration configuration) throws ConfigurationException {
|
||||
@@ -77,6 +80,7 @@ public class ApplicationConfigurable extends SettingsEditor<ApplicationConfigura
|
||||
configuration.ALTERNATIVE_JRE_PATH = myJrePathEditor.getJrePathOrName();
|
||||
configuration.ALTERNATIVE_JRE_PATH_ENABLED = myJrePathEditor.isAlternativeJreSelected();
|
||||
configuration.ENABLE_SWING_INSPECTOR = (myVersionDetector.isJre50Configured(configuration) || myVersionDetector.isModuleJre50Configured(configuration)) && myShowSwingInspectorCheckbox.isSelected();
|
||||
configuration.setShortenClasspath((ShortenClasspath)myShortenClasspathModeCombo.getComponent().getSelectedItem());
|
||||
|
||||
updateShowSwingInspector(configuration);
|
||||
}
|
||||
@@ -86,6 +90,7 @@ public class ApplicationConfigurable extends SettingsEditor<ApplicationConfigura
|
||||
myModuleSelector.reset(configuration);
|
||||
getMainClassField().setText(configuration.MAIN_CLASS_NAME != null ? configuration.MAIN_CLASS_NAME.replaceAll("\\$", "\\.") : "");
|
||||
myJrePathEditor.setPathOrName(configuration.ALTERNATIVE_JRE_PATH, configuration.ALTERNATIVE_JRE_PATH_ENABLED);
|
||||
myShortenClasspathModeCombo.getComponent().setSelectedItem(configuration.getShortenClasspath());
|
||||
|
||||
updateShowSwingInspector(configuration);
|
||||
}
|
||||
@@ -130,6 +135,8 @@ public class ApplicationConfigurable extends SettingsEditor<ApplicationConfigura
|
||||
return Visibility.NOT_VISIBLE;
|
||||
}
|
||||
}));
|
||||
myShortenClasspathModeCombo = new LabeledComponent<>();
|
||||
myShortenClasspathModeCombo.setComponent(new ShortenClasspathModeCombo(myProject));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -144,5 +151,6 @@ public class ApplicationConfigurable extends SettingsEditor<ApplicationConfigura
|
||||
myCommonProgramParameters.setAnchor(anchor);
|
||||
myJrePathEditor.setAnchor(anchor);
|
||||
myModule.setAnchor(anchor);
|
||||
myShortenClasspathModeCombo.setAnchor(anchor);
|
||||
}
|
||||
}
|
||||
|
||||
+18
-1
@@ -61,6 +61,8 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
|
||||
public String ALTERNATIVE_JRE_PATH;
|
||||
public boolean ENABLE_SWING_INSPECTOR;
|
||||
|
||||
private ShortenClasspath myShortenClasspath = null;
|
||||
|
||||
public String ENV_VARIABLES;
|
||||
private final Map<String,String> myEnvs = new LinkedHashMap<>();
|
||||
public boolean PASS_PARENT_ENVS = true;
|
||||
@@ -243,6 +245,7 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
|
||||
DefaultJDOMExternalizer.readExternal(this, element);
|
||||
readModule(element);
|
||||
EnvironmentVariablesComponent.readExternal(element, getEnvs());
|
||||
setShortenClasspath(ShortenClasspath.readShortenClasspathMethod(element));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -257,6 +260,19 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
|
||||
//if (!envs.isEmpty()) {
|
||||
EnvironmentVariablesComponent.writeExternal(element, envs);
|
||||
//}
|
||||
|
||||
ShortenClasspath.writeShortenClasspathMethod(element, myShortenClasspath);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ShortenClasspath getShortenClasspath() {
|
||||
return myShortenClasspath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShortenClasspath(ShortenClasspath mode) {
|
||||
myShortenClasspath = mode;
|
||||
}
|
||||
|
||||
public static class JavaApplicationCommandLineState<T extends ApplicationConfiguration> extends BaseJavaApplicationCommandLineState<T> {
|
||||
@@ -267,7 +283,8 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
|
||||
@Override
|
||||
protected JavaParameters createJavaParameters() throws ExecutionException {
|
||||
final JavaParameters params = new JavaParameters();
|
||||
params.setUseClasspathJar(true);
|
||||
T configuration = getConfiguration();
|
||||
params.setShortenClasspath(configuration.getShortenClasspath(), configuration.getProject());
|
||||
|
||||
final JavaRunConfigurationModule module = myConfiguration.getConfigurationModule();
|
||||
final String jreHome = myConfiguration.ALTERNATIVE_JRE_PATH_ENABLED ? myConfiguration.ALTERNATIVE_JRE_PATH : null;
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution.ui;
|
||||
|
||||
import com.intellij.execution.ShortenClasspath;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.ComboBox;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class ShortenClasspathModeCombo extends ComboBox<ShortenClasspath> {
|
||||
private final Project myProject;
|
||||
|
||||
public ShortenClasspathModeCombo(Project project) {
|
||||
myProject = project;
|
||||
addItem(null);
|
||||
for (ShortenClasspath mode : ShortenClasspath.values()) {
|
||||
addItem(mode);
|
||||
}
|
||||
setRenderer(new ColoredListCellRenderer<ShortenClasspath>() {
|
||||
@Override
|
||||
protected void customizeCellRenderer(@NotNull JList<? extends ShortenClasspath> list,
|
||||
ShortenClasspath value,
|
||||
int index,
|
||||
boolean selected,
|
||||
boolean hasFocus) {
|
||||
if (value == null) {
|
||||
ShortenClasspath defaultMode = ShortenClasspath.getDefaultMethod(myProject);
|
||||
append("user-local default: " + defaultMode.getPresentableName()).append(" - " + defaultMode.getDescription(), SimpleTextAttributes.GRAYED_ATTRIBUTES);
|
||||
}
|
||||
else {
|
||||
append(value.getPresentableName()).append(" - " + value.getDescription(), SimpleTextAttributes.GRAYED_ATTRIBUTES);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user