ShortenCommandLine naming

This commit is contained in:
Anna.Kozlova
2017-10-05 11:51:53 +02:00
parent 072d1a1e8a
commit 96b43f3b6a
11 changed files with 69 additions and 70 deletions
@@ -33,8 +33,8 @@ import org.jetbrains.annotations.Nullable;
import java.util.List;
public abstract class JavaTestConfigurationBase extends ModuleBasedConfiguration<JavaRunConfigurationModule>
implements CommonJavaRunConfigurationParameters, ConfigurationWithClasspathShortener, RefactoringListenerProvider, SMRunnerConsolePropertiesProvider {
private ShortenClasspath myShortenClasspath = null;
implements CommonJavaRunConfigurationParameters, ConfigurationWithCommandLineShortener, RefactoringListenerProvider, SMRunnerConsolePropertiesProvider {
private ShortenCommandLine myShortenCommandLine = null;
public JavaTestConfigurationBase(String name,
@NotNull JavaRunConfigurationModule configurationModule,
@@ -66,24 +66,24 @@ public abstract class JavaTestConfigurationBase extends ModuleBasedConfiguration
@Nullable
@Override
public ShortenClasspath getShortenClasspath() {
return myShortenClasspath;
public ShortenCommandLine getShortenCommandLine() {
return myShortenCommandLine;
}
@Override
public void setShortenClasspath(ShortenClasspath shortenClasspath) {
myShortenClasspath = shortenClasspath;
public void setShortenCommandLine(ShortenCommandLine shortenCommandLine) {
myShortenCommandLine = shortenCommandLine;
}
@Override
public void readExternal(Element element) throws InvalidDataException {
super.readExternal(element);
setShortenClasspath(ShortenClasspath.readShortenClasspathMethod(element));
setShortenCommandLine(ShortenCommandLine.readShortenClasspathMethod(element));
}
@Override
public void writeExternal(Element element) throws WriteExternalException {
super.writeExternal(element);
ShortenClasspath.writeShortenClasspathMethod(element, myShortenClasspath);
ShortenCommandLine.writeShortenClasspathMethod(element, myShortenCommandLine);
}
}
@@ -74,7 +74,7 @@ import java.util.Map;
public abstract class JavaTestFrameworkRunnableState<T extends
ModuleBasedConfiguration<JavaRunConfigurationModule>
& CommonJavaRunConfigurationParameters
& ConfigurationWithClasspathShortener
& ConfigurationWithCommandLineShortener
& SMRunnerConsolePropertiesProvider> extends JavaCommandLineState implements RemoteConnectionCreator {
private static final Logger LOG = Logger.getInstance(JavaTestFrameworkRunnableState.class);
protected ServerSocket myServerSocket;
@@ -196,7 +196,7 @@ public abstract class JavaTestFrameworkRunnableState<T extends
protected JavaParameters createJavaParameters() throws ExecutionException {
final JavaParameters javaParameters = new JavaParameters();
Project project = getConfiguration().getProject();
javaParameters.setShortenClasspath(getConfiguration().getShortenClasspath(), project);
javaParameters.setShortenCommandLine(getConfiguration().getShortenCommandLine(), project);
final Module module = getConfiguration().getConfigurationModule().getModule();
Sdk jdk = module == null ? ProjectRootManager.getInstance(project).getProjectSdk() : ModuleRootManager.getInstance(module).getSdk();
@@ -18,7 +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.ShortenCommandLine;
import com.intellij.execution.configurations.ConfigurationUtil;
import com.intellij.execution.ui.*;
import com.intellij.execution.util.JreVersionDetector;
@@ -44,7 +44,7 @@ public class ApplicationConfigurable extends SettingsEditor<ApplicationConfigura
private CommonJavaParametersPanel myCommonProgramParameters;
private LabeledComponent<EditorTextFieldWithBrowseButton> myMainClass;
private LabeledComponent<ModuleDescriptionsComboBox> myModule;
private LabeledComponent<ShortenClasspathModeCombo> myShortenClasspathModeCombo;
private LabeledComponent<ShortenCommandLineModeCombo> myShortenClasspathModeCombo;
private JPanel myWholePanel;
private final ConfigurationModuleSelector myModuleSelector;
@@ -67,7 +67,7 @@ public class ApplicationConfigurable extends SettingsEditor<ApplicationConfigura
ClassBrowser.createApplicationClassBrowser(project, myModuleSelector).setField(getMainClassField());
myVersionDetector = new JreVersionDetector();
myShortenClasspathModeCombo.setComponent(new ShortenClasspathModeCombo(myProject, myJrePathEditor));
myShortenClasspathModeCombo.setComponent(new ShortenCommandLineModeCombo(myProject, myJrePathEditor));
myAnchor = UIUtil.mergeComponentsWithAnchor(myMainClass, myCommonProgramParameters, myJrePathEditor, myModule,
myShortenClasspathModeCombo);
}
@@ -81,7 +81,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());
configuration.setShortenCommandLine((ShortenCommandLine)myShortenClasspathModeCombo.getComponent().getSelectedItem());
updateShowSwingInspector(configuration);
}
@@ -91,7 +91,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());
myShortenClasspathModeCombo.getComponent().setSelectedItem(configuration.getShortenCommandLine());
updateShowSwingInspector(configuration);
}
@@ -51,7 +51,7 @@ import java.util.LinkedHashMap;
import java.util.Map;
public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunConfigurationModule>
implements CommonJavaRunConfigurationParameters, ConfigurationWithClasspathShortener, SingleClassConfiguration, RefactoringListenerProvider {
implements CommonJavaRunConfigurationParameters, ConfigurationWithCommandLineShortener, SingleClassConfiguration, RefactoringListenerProvider {
public String MAIN_CLASS_NAME;
public String VM_PARAMETERS;
@@ -61,7 +61,7 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
public String ALTERNATIVE_JRE_PATH;
public boolean ENABLE_SWING_INSPECTOR;
private ShortenClasspath myShortenClasspath = null;
private ShortenCommandLine myShortenCommandLine = null;
public String ENV_VARIABLES;
private final Map<String,String> myEnvs = new LinkedHashMap<>();
@@ -245,7 +245,7 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
DefaultJDOMExternalizer.readExternal(this, element);
readModule(element);
EnvironmentVariablesComponent.readExternal(element, getEnvs());
setShortenClasspath(ShortenClasspath.readShortenClasspathMethod(element));
setShortenCommandLine(ShortenCommandLine.readShortenClasspathMethod(element));
}
@Override
@@ -261,18 +261,18 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
EnvironmentVariablesComponent.writeExternal(element, envs);
//}
ShortenClasspath.writeShortenClasspathMethod(element, myShortenClasspath);
ShortenCommandLine.writeShortenClasspathMethod(element, myShortenCommandLine);
}
@Nullable
@Override
public ShortenClasspath getShortenClasspath() {
return myShortenClasspath;
public ShortenCommandLine getShortenCommandLine() {
return myShortenCommandLine;
}
@Override
public void setShortenClasspath(ShortenClasspath mode) {
myShortenClasspath = mode;
public void setShortenCommandLine(ShortenCommandLine mode) {
myShortenCommandLine = mode;
}
public static class JavaApplicationCommandLineState<T extends ApplicationConfiguration> extends BaseJavaApplicationCommandLineState<T> {
@@ -284,7 +284,7 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
protected JavaParameters createJavaParameters() throws ExecutionException {
final JavaParameters params = new JavaParameters();
T configuration = getConfiguration();
params.setShortenClasspath(configuration.getShortenClasspath(), configuration.getProject());
params.setShortenCommandLine(configuration.getShortenCommandLine(), configuration.getProject());
final JavaRunConfigurationModule module = myConfiguration.getConfigurationModule();
final String jreHome = myConfiguration.ALTERNATIVE_JRE_PATH_ENABLED ? myConfiguration.ALTERNATIVE_JRE_PATH : null;
@@ -1,7 +1,7 @@
// 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.execution.ShortenCommandLine;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.ProjectJdkTable;
import com.intellij.openapi.projectRoots.Sdk;
@@ -13,21 +13,21 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
public class ShortenClasspathModeCombo extends ComboBox<ShortenClasspath> {
public class ShortenCommandLineModeCombo extends ComboBox<ShortenCommandLine> {
private final Project myProject;
public ShortenClasspathModeCombo(Project project, JrePathEditor pathEditor) {
public ShortenCommandLineModeCombo(Project project, JrePathEditor pathEditor) {
myProject = project;
initModel(null, pathEditor);
setRenderer(new ColoredListCellRenderer<ShortenClasspath>() {
setRenderer(new ColoredListCellRenderer<ShortenCommandLine>() {
@Override
protected void customizeCellRenderer(@NotNull JList<? extends ShortenClasspath> list,
ShortenClasspath value,
protected void customizeCellRenderer(@NotNull JList<? extends ShortenCommandLine> list,
ShortenCommandLine value,
int index,
boolean selected,
boolean hasFocus) {
if (value == null) {
ShortenClasspath defaultMode = ShortenClasspath.getDefaultMethod(myProject, getJdkRoot(pathEditor));
ShortenCommandLine defaultMode = ShortenCommandLine.getDefaultMethod(myProject, getJdkRoot(pathEditor));
append("user-local default: " + defaultMode.getPresentableName()).append(" - " + defaultMode.getDescription(), SimpleTextAttributes.GRAYED_ATTRIBUTES);
}
else {
@@ -37,16 +37,16 @@ public class ShortenClasspathModeCombo extends ComboBox<ShortenClasspath> {
});
pathEditor.addActionListener(e -> {
Object item = getSelectedItem();
initModel((ShortenClasspath)item, pathEditor);
initModel((ShortenCommandLine)item, pathEditor);
});
}
private void initModel(ShortenClasspath preselection, JrePathEditor pathEditor) {
private void initModel(ShortenCommandLine preselection, JrePathEditor pathEditor) {
removeAllItems();
String jdkRoot = getJdkRoot(pathEditor);
addItem(null);
for (ShortenClasspath mode : ShortenClasspath.values()) {
for (ShortenCommandLine mode : ShortenCommandLine.values()) {
if (mode.isApplicable(jdkRoot)) {
addItem(mode);
}
@@ -57,17 +57,16 @@ public class ShortenClasspathModeCombo extends ComboBox<ShortenClasspath> {
@Nullable
private static String getJdkRoot(JrePathEditor pathEditor) {
String rootPath = null;
String jrePathOrName = pathEditor.getJrePathOrName();
if (jrePathOrName != null) {
Sdk configuredJdk = ProjectJdkTable.getInstance().findJdk(jrePathOrName);
if (configuredJdk != null) {
rootPath = configuredJdk.getHomePath();
return configuredJdk.getHomePath();
}
else {
rootPath = jrePathOrName;
return jrePathOrName;
}
}
return rootPath;
return null;
}
}