summaryrefslogtreecommitdiff
path: root/java/execution/impl/src/com/intellij/execution
diff options
context:
space:
mode:
Diffstat (limited to 'java/execution/impl/src/com/intellij/execution')
-rw-r--r--java/execution/impl/src/com/intellij/execution/actions/JavaRerunFailedTestsAction.java7
-rw-r--r--java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java46
-rw-r--r--java/execution/impl/src/com/intellij/execution/application/BaseJavaApplicationCommandLineState.java70
-rw-r--r--java/execution/impl/src/com/intellij/execution/impl/DefaultJavaProgramRunner.java12
-rw-r--r--java/execution/impl/src/com/intellij/execution/jar/JarApplicationCommandLineState.java43
-rw-r--r--java/execution/impl/src/com/intellij/execution/jar/JarApplicationConfigurable.form49
-rw-r--r--java/execution/impl/src/com/intellij/execution/jar/JarApplicationConfigurable.java93
-rw-r--r--java/execution/impl/src/com/intellij/execution/jar/JarApplicationConfiguration.java223
-rw-r--r--java/execution/impl/src/com/intellij/execution/jar/JarApplicationConfigurationProducer.java63
-rw-r--r--java/execution/impl/src/com/intellij/execution/jar/JarApplicationConfigurationType.java54
-rw-r--r--java/execution/impl/src/com/intellij/execution/jar/JarApplicationDebuggerRunner.java37
-rw-r--r--java/execution/impl/src/com/intellij/execution/junit/InheritorChooser.java8
-rw-r--r--java/execution/impl/src/com/intellij/execution/runners/ProcessProxyFactoryImpl.java7
-rw-r--r--java/execution/impl/src/com/intellij/execution/util/JavaParametersUtil.java3
14 files changed, 658 insertions, 57 deletions
diff --git a/java/execution/impl/src/com/intellij/execution/actions/JavaRerunFailedTestsAction.java b/java/execution/impl/src/com/intellij/execution/actions/JavaRerunFailedTestsAction.java
index 76e7175b87ff..3be2960bfcf7 100644
--- a/java/execution/impl/src/com/intellij/execution/actions/JavaRerunFailedTestsAction.java
+++ b/java/execution/impl/src/com/intellij/execution/actions/JavaRerunFailedTestsAction.java
@@ -22,6 +22,7 @@ package com.intellij.execution.actions;
import com.intellij.execution.testframework.Filter;
import com.intellij.execution.testframework.JavaAwareFilter;
+import com.intellij.execution.testframework.TestConsoleProperties;
import com.intellij.execution.testframework.actions.AbstractRerunFailedTestsAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComponentContainer;
@@ -29,9 +30,10 @@ import com.intellij.psi.search.GlobalSearchScope;
import org.jetbrains.annotations.NotNull;
public class JavaRerunFailedTestsAction extends AbstractRerunFailedTestsAction {
-
- protected JavaRerunFailedTestsAction(@NotNull ComponentContainer componentContainer) {
+ public JavaRerunFailedTestsAction(@NotNull ComponentContainer componentContainer, @NotNull TestConsoleProperties consoleProperties) {
super(componentContainer);
+
+ init(consoleProperties);
}
@NotNull
@@ -39,5 +41,4 @@ public class JavaRerunFailedTestsAction extends AbstractRerunFailedTestsAction {
protected Filter getFilter(Project project, GlobalSearchScope searchScope) {
return super.getFilter(project, searchScope).and(JavaAwareFilter.METHOD(project, searchScope));
}
-
}
diff --git a/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java b/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java
index 578d5fbba6ea..b736d9f0b127 100644
--- a/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java
+++ b/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java
@@ -21,20 +21,16 @@ import com.intellij.execution.configuration.EnvironmentVariablesComponent;
import com.intellij.execution.configurations.*;
import com.intellij.execution.filters.TextConsoleBuilderFactory;
import com.intellij.execution.junit.RefactoringListeners;
-import com.intellij.execution.process.KillableColoredProcessHandler;
-import com.intellij.execution.process.OSProcessHandler;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.util.JavaParametersUtil;
import com.intellij.execution.util.ProgramParametersUtil;
import com.intellij.openapi.components.PathMacroManager;
-import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.options.SettingsEditorGroup;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.DefaultJDOMExternalizer;
import com.intellij.openapi.util.InvalidDataException;
-import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
@@ -81,7 +77,7 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
@Override
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException {
- final JavaCommandLineState state = new JavaApplicationCommandLineState(this, env);
+ final JavaCommandLineState state = new JavaApplicationCommandLineState<ApplicationConfiguration>(this, env);
JavaRunConfigurationModule module = getConfigurationModule();
state.setConsoleBuilder(TextConsoleBuilderFactory.getInstance().createBuilder(getProject(), module.getSearchScope()));
return state;
@@ -253,14 +249,9 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
PathMacroManager.getInstance(getProject()).collapsePathsRecursively(element);
}
- public static class JavaApplicationCommandLineState extends JavaCommandLineState {
-
- private final ApplicationConfiguration myConfiguration;
-
- public JavaApplicationCommandLineState(@NotNull final ApplicationConfiguration configuration,
- final ExecutionEnvironment environment) {
- super(environment);
- myConfiguration = configuration;
+ public static class JavaApplicationCommandLineState<T extends ApplicationConfiguration> extends BaseJavaApplicationCommandLineState<T> {
+ public JavaApplicationCommandLineState(@NotNull final T configuration, final ExecutionEnvironment environment) {
+ super(environment, configuration);
}
@Override
@@ -269,37 +260,14 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
final JavaRunConfigurationModule module = myConfiguration.getConfigurationModule();
final int classPathType = JavaParametersUtil.getClasspathType(module,
- myConfiguration.MAIN_CLASS_NAME,
+ myConfiguration.MAIN_CLASS_NAME,
false);
- final String jreHome = myConfiguration.ALTERNATIVE_JRE_PATH_ENABLED ? myConfiguration.ALTERNATIVE_JRE_PATH
- : null;
+ final String jreHome = myConfiguration.ALTERNATIVE_JRE_PATH_ENABLED ? myConfiguration.ALTERNATIVE_JRE_PATH : null;
JavaParametersUtil.configureModule(module, params, classPathType, jreHome);
- JavaParametersUtil.configureConfiguration(params, myConfiguration);
-
params.setMainClass(myConfiguration.MAIN_CLASS_NAME);
- for(RunConfigurationExtension ext: Extensions.getExtensions(RunConfigurationExtension.EP_NAME)) {
- ext.updateJavaParameters(myConfiguration, params, getRunnerSettings());
- }
+ setupJavaParameters(params);
return params;
}
-
- @NotNull
- @Override
- protected OSProcessHandler startProcess() throws ExecutionException {
- OSProcessHandler handler = SystemInfo.isWindows ? super.startProcess() : KillableColoredProcessHandler.create(createCommandLine());
- RunnerSettings runnerSettings = getRunnerSettings();
- JavaRunConfigurationExtensionManager.getInstance().attachExtensionsToProcess(myConfiguration, handler, runnerSettings);
- return handler;
- }
-
- @Override
- protected boolean ansiColoringEnabled() {
- return true;
- }
-
- protected ApplicationConfiguration getConfiguration() {
- return myConfiguration;
- }
}
}
diff --git a/java/execution/impl/src/com/intellij/execution/application/BaseJavaApplicationCommandLineState.java b/java/execution/impl/src/com/intellij/execution/application/BaseJavaApplicationCommandLineState.java
new file mode 100644
index 000000000000..d9caa6ebc149
--- /dev/null
+++ b/java/execution/impl/src/com/intellij/execution/application/BaseJavaApplicationCommandLineState.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.execution.application;
+
+import com.intellij.execution.CommonJavaRunConfigurationParameters;
+import com.intellij.execution.ExecutionException;
+import com.intellij.execution.JavaRunConfigurationExtensionManager;
+import com.intellij.execution.RunConfigurationExtension;
+import com.intellij.execution.configurations.JavaCommandLineState;
+import com.intellij.execution.configurations.JavaParameters;
+import com.intellij.execution.configurations.RunConfigurationBase;
+import com.intellij.execution.configurations.RunnerSettings;
+import com.intellij.execution.process.KillableColoredProcessHandler;
+import com.intellij.execution.process.OSProcessHandler;
+import com.intellij.execution.runners.ExecutionEnvironment;
+import com.intellij.execution.util.JavaParametersUtil;
+import com.intellij.openapi.extensions.Extensions;
+import com.intellij.openapi.util.SystemInfo;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author nik
+ */
+public abstract class BaseJavaApplicationCommandLineState<T extends RunConfigurationBase&CommonJavaRunConfigurationParameters> extends JavaCommandLineState {
+ protected final T myConfiguration;
+
+ public BaseJavaApplicationCommandLineState(ExecutionEnvironment environment, @NotNull final T configuration) {
+ super(environment);
+ myConfiguration = configuration;
+ }
+
+ protected void setupJavaParameters(JavaParameters params) throws ExecutionException {
+ JavaParametersUtil.configureConfiguration(params, myConfiguration);
+
+ for(RunConfigurationExtension ext: Extensions.getExtensions(RunConfigurationExtension.EP_NAME)) {
+ ext.updateJavaParameters(getConfiguration(), params, getRunnerSettings());
+ }
+ }
+
+ @NotNull
+ @Override
+ protected OSProcessHandler startProcess() throws ExecutionException {
+ OSProcessHandler handler = SystemInfo.isWindows ? super.startProcess() : KillableColoredProcessHandler.create(createCommandLine());
+ RunnerSettings runnerSettings = getRunnerSettings();
+ JavaRunConfigurationExtensionManager.getInstance().attachExtensionsToProcess(getConfiguration(), handler, runnerSettings);
+ return handler;
+ }
+
+ @Override
+ protected boolean ansiColoringEnabled() {
+ return true;
+ }
+
+ protected T getConfiguration() {
+ return myConfiguration;
+ }
+}
diff --git a/java/execution/impl/src/com/intellij/execution/impl/DefaultJavaProgramRunner.java b/java/execution/impl/src/com/intellij/execution/impl/DefaultJavaProgramRunner.java
index 626a47509144..0b8f32964d59 100644
--- a/java/execution/impl/src/com/intellij/execution/impl/DefaultJavaProgramRunner.java
+++ b/java/execution/impl/src/com/intellij/execution/impl/DefaultJavaProgramRunner.java
@@ -34,7 +34,6 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Disposer;
import com.intellij.unscramble.AnalyzeStacktraceUtil;
import com.intellij.unscramble.ThreadDumpConsoleFactory;
import com.intellij.unscramble.ThreadDumpParser;
@@ -97,7 +96,6 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
onProcessStarted(env.getRunnerSettings(), executionResult);
final RunContentBuilder contentBuilder = new RunContentBuilder(executionResult, env);
- Disposer.register(env.getProject(), contentBuilder);
if (shouldAddDefaultActions) {
addDefaultActions(contentBuilder);
}
@@ -116,7 +114,7 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
final ExecutionResult executionResult = contentBuilder.getExecutionResult();
final ExecutionConsole executionConsole = executionResult.getExecutionConsole();
final JComponent consoleComponent = executionConsole != null ? executionConsole.getComponent() : null;
- final ControlBreakAction controlBreakAction = new ControlBreakAction(contentBuilder.getProcessHandler());
+ final ControlBreakAction controlBreakAction = new ControlBreakAction(executionResult.getProcessHandler());
if (consoleComponent != null) {
controlBreakAction.registerCustomShortcutSet(controlBreakAction.getShortcutSet(), consoleComponent);
final ProcessHandler processHandler = executionResult.getProcessHandler();
@@ -130,7 +128,7 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
});
}
contentBuilder.addAction(controlBreakAction);
- contentBuilder.addAction(new SoftExitAction(contentBuilder.getProcessHandler()));
+ contentBuilder.addAction(new SoftExitAction(executionResult.getProcessHandler()));
}
@@ -143,7 +141,7 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
}
@Override
- public void update(final AnActionEvent event) {
+ public void update(@NotNull final AnActionEvent event) {
final Presentation presentation = event.getPresentation();
if (!isVisible()) {
presentation.setVisible(false);
@@ -172,7 +170,7 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
}
@Override
- public void actionPerformed(final AnActionEvent e) {
+ public void actionPerformed(@NotNull final AnActionEvent e) {
ProcessProxy proxy = ProcessProxyFactory.getInstance().getAttachedProxy(myProcessHandler);
if (proxy != null) {
final WiseDumpThreadsListener wiseListener = Boolean.TRUE.equals(Boolean.getBoolean(ourWiseThreadDumpProperty)) ?
@@ -254,7 +252,7 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
}
@Override
- public void actionPerformed(final AnActionEvent e) {
+ public void actionPerformed(@NotNull final AnActionEvent e) {
ProcessProxy proxy = ProcessProxyFactory.getInstance().getAttachedProxy(myProcessHandler);
if (proxy != null) {
proxy.sendStop();
diff --git a/java/execution/impl/src/com/intellij/execution/jar/JarApplicationCommandLineState.java b/java/execution/impl/src/com/intellij/execution/jar/JarApplicationCommandLineState.java
new file mode 100644
index 000000000000..c93ab85d4cec
--- /dev/null
+++ b/java/execution/impl/src/com/intellij/execution/jar/JarApplicationCommandLineState.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.execution.jar;
+
+import com.intellij.execution.ExecutionException;
+import com.intellij.execution.application.BaseJavaApplicationCommandLineState;
+import com.intellij.execution.configurations.JavaParameters;
+import com.intellij.execution.runners.ExecutionEnvironment;
+import com.intellij.execution.util.JavaParametersUtil;
+import com.intellij.openapi.util.io.FileUtil;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author nik
+ */
+public class JarApplicationCommandLineState extends BaseJavaApplicationCommandLineState<JarApplicationConfiguration> {
+ public JarApplicationCommandLineState(@NotNull final JarApplicationConfiguration configuration, final ExecutionEnvironment environment) {
+ super(environment, configuration);
+ }
+
+ @Override
+ protected JavaParameters createJavaParameters() throws ExecutionException {
+ final JavaParameters params = new JavaParameters();
+ final String jreHome = myConfiguration.isAlternativeJrePathEnabled() ? myConfiguration.getAlternativeJrePath() : null;
+ params.setJdk(JavaParametersUtil.createProjectJdk(myConfiguration.getProject(), jreHome));
+ setupJavaParameters(params);
+ params.setJarPath(FileUtil.toSystemDependentName(myConfiguration.getJarPath()));
+ return params;
+ }
+}
diff --git a/java/execution/impl/src/com/intellij/execution/jar/JarApplicationConfigurable.form b/java/execution/impl/src/com/intellij/execution/jar/JarApplicationConfigurable.form
new file mode 100644
index 000000000000..db191dde6fa3
--- /dev/null
+++ b/java/execution/impl/src/com/intellij/execution/jar/JarApplicationConfigurable.form
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.execution.jar.JarApplicationConfigurable">
+ <grid id="27dc6" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="5" 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="20" y="20" width="530" height="400"/>
+ </constraints>
+ <properties/>
+ <border type="none"/>
+ <children>
+ <component id="73391" class="com.intellij.execution.ui.CommonJavaParametersPanel" binding="myCommonProgramParameters">
+ <constraints>
+ <grid row="1" 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>
+ <vspacer id="9634c">
+ <constraints>
+ <grid row="4" 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="a09fc" class="com.intellij.execution.ui.AlternativeJREPanel" binding="myAlternativeJREPanel">
+ <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>
+ <component id="cab16" class="com.intellij.openapi.ui.LabeledComponent" binding="myJarPathComponent" custom-create="true">
+ <constraints>
+ <grid row="0" 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>
+ <labelLocation value="West"/>
+ <text value="Path to &amp;JAR"/>
+ </properties>
+ </component>
+ <component id="6fe96" class="com.intellij.openapi.ui.LabeledComponent" binding="myModuleComponent">
+ <constraints>
+ <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>
+ <properties>
+ <componentClass value="com.intellij.application.options.ModulesComboBox"/>
+ <labelLocation value="West"/>
+ <text value="Search sources using m&amp;odule's classpath"/>
+ </properties>
+ </component>
+ </children>
+ </grid>
+</form>
diff --git a/java/execution/impl/src/com/intellij/execution/jar/JarApplicationConfigurable.java b/java/execution/impl/src/com/intellij/execution/jar/JarApplicationConfigurable.java
new file mode 100644
index 000000000000..03758cd031cb
--- /dev/null
+++ b/java/execution/impl/src/com/intellij/execution/jar/JarApplicationConfigurable.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.execution.jar;
+
+import com.intellij.application.options.ModulesComboBox;
+import com.intellij.execution.ui.AlternativeJREPanel;
+import com.intellij.execution.ui.CommonJavaParametersPanel;
+import com.intellij.openapi.fileChooser.FileChooserDescriptor;
+import com.intellij.openapi.options.ConfigurationException;
+import com.intellij.openapi.options.SettingsEditor;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.LabeledComponent;
+import com.intellij.openapi.ui.TextFieldWithBrowseButton;
+import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.ui.PanelWithAnchor;
+import com.intellij.util.ui.UIUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+
+public class JarApplicationConfigurable extends SettingsEditor<JarApplicationConfiguration> implements PanelWithAnchor {
+ private CommonJavaParametersPanel myCommonProgramParameters;
+ private LabeledComponent<TextFieldWithBrowseButton> myJarPathComponent;
+ private LabeledComponent<ModulesComboBox> myModuleComponent;
+ private JPanel myWholePanel;
+
+ private AlternativeJREPanel myAlternativeJREPanel;
+ private final Project myProject;
+ private JComponent myAnchor;
+
+ public JarApplicationConfigurable(final Project project) {
+ myProject = project;
+ myAnchor = UIUtil.mergeComponentsWithAnchor(myJarPathComponent, myCommonProgramParameters, myAlternativeJREPanel);
+ ModulesComboBox modulesComboBox = myModuleComponent.getComponent();
+ modulesComboBox.allowEmptySelection("<whole project>");
+ modulesComboBox.fillModules(project);
+ }
+
+ public void applyEditorTo(final JarApplicationConfiguration configuration) throws ConfigurationException {
+ myCommonProgramParameters.applyTo(configuration);
+ configuration.setAlternativeJrePath(myAlternativeJREPanel.getPath());
+ configuration.setAlternativeJrePathEnabled(myAlternativeJREPanel.isPathEnabled());
+ configuration.setJarPath(FileUtil.toSystemIndependentName(myJarPathComponent.getComponent().getText()));
+ configuration.setModule(myModuleComponent.getComponent().getSelectedModule());
+ }
+
+ public void resetEditorFrom(final JarApplicationConfiguration configuration) {
+ myCommonProgramParameters.reset(configuration);
+ myJarPathComponent.getComponent().setText(FileUtil.toSystemDependentName(configuration.getJarPath()));
+ myAlternativeJREPanel.init(configuration.getAlternativeJrePath(), configuration.isAlternativeJrePathEnabled());
+ myModuleComponent.getComponent().setSelectedModule(configuration.getModule());
+ }
+
+ @NotNull
+ public JComponent createEditor() {
+ return myWholePanel;
+ }
+
+ private void createUIComponents() {
+ myJarPathComponent = new LabeledComponent<TextFieldWithBrowseButton>();
+ TextFieldWithBrowseButton textFieldWithBrowseButton = new TextFieldWithBrowseButton();
+ textFieldWithBrowseButton.addBrowseFolderListener("Choose JAR File", null, myProject,
+ new FileChooserDescriptor(false, false, true, true, false, false));
+ myJarPathComponent.setComponent(textFieldWithBrowseButton);
+ }
+
+ @Override
+ public JComponent getAnchor() {
+ return myAnchor;
+ }
+
+ @Override
+ public void setAnchor(@Nullable JComponent anchor) {
+ myAnchor = anchor;
+ myCommonProgramParameters.setAnchor(anchor);
+ myAlternativeJREPanel.setAnchor(anchor);
+ myJarPathComponent.setAnchor(anchor);
+ }
+}
diff --git a/java/execution/impl/src/com/intellij/execution/jar/JarApplicationConfiguration.java b/java/execution/impl/src/com/intellij/execution/jar/JarApplicationConfiguration.java
new file mode 100644
index 000000000000..c76b5873389a
--- /dev/null
+++ b/java/execution/impl/src/com/intellij/execution/jar/JarApplicationConfiguration.java
@@ -0,0 +1,223 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.execution.jar;
+
+import com.intellij.diagnostic.logging.LogConfigurationPanel;
+import com.intellij.execution.*;
+import com.intellij.execution.configuration.EnvironmentVariablesComponent;
+import com.intellij.execution.configurations.*;
+import com.intellij.execution.runners.ExecutionEnvironment;
+import com.intellij.execution.util.JavaParametersUtil;
+import com.intellij.execution.util.ProgramParametersUtil;
+import com.intellij.openapi.components.PathMacroManager;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.options.SettingsEditor;
+import com.intellij.openapi.options.SettingsEditorGroup;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.InvalidDataException;
+import com.intellij.openapi.util.WriteExternalException;
+import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters;
+import com.intellij.util.xmlb.XmlSerializer;
+import org.jdom.Element;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.File;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * @author nik
+ */
+public class JarApplicationConfiguration extends LocatableConfigurationBase implements CommonJavaRunConfigurationParameters, SearchScopeProvidingRunProfile {
+ private static final SkipDefaultValuesSerializationFilters SERIALIZATION_FILTERS = new SkipDefaultValuesSerializationFilters();
+ private JarApplicationConfigurationBean myBean = new JarApplicationConfigurationBean();
+ private Map<String, String> myEnvs = new LinkedHashMap<String, String>();
+ private JavaRunConfigurationModule myConfigurationModule;
+
+ public JarApplicationConfiguration(Project project, ConfigurationFactory factory, String name) {
+ super(project, factory, name);
+ myConfigurationModule = new JavaRunConfigurationModule(project, true);
+ }
+
+ @NotNull
+ @Override
+ public SettingsEditor<? extends RunConfiguration> getConfigurationEditor() {
+ SettingsEditorGroup<JarApplicationConfiguration> group = new SettingsEditorGroup<JarApplicationConfiguration>();
+ group.addEditor(ExecutionBundle.message("run.configuration.configuration.tab.title"), new JarApplicationConfigurable(getProject()));
+ JavaRunConfigurationExtensionManager.getInstance().appendEditors(this, group);
+ group.addEditor(ExecutionBundle.message("logs.tab.title"), new LogConfigurationPanel<JarApplicationConfiguration>());
+ return group;
+ }
+
+ @Override
+ public void readExternal(Element element) throws InvalidDataException {
+ PathMacroManager.getInstance(getProject()).expandPaths(element);
+ super.readExternal(element);
+ JavaRunConfigurationExtensionManager.getInstance().readExternal(this, element);
+ XmlSerializer.deserializeInto(myBean, element);
+ EnvironmentVariablesComponent.readExternal(element, getEnvs());
+ myConfigurationModule.readExternal(element);
+ }
+
+ public void setModule(Module module) {
+ myConfigurationModule.setModule(module);
+ }
+
+ public Module getModule() {
+ return myConfigurationModule.getModule();
+ }
+
+ @Override
+ public void writeExternal(Element element) throws WriteExternalException {
+ super.writeExternal(element);
+ JavaRunConfigurationExtensionManager.getInstance().writeExternal(this, element);
+ XmlSerializer.serializeInto(myBean, element, SERIALIZATION_FILTERS);
+ EnvironmentVariablesComponent.writeExternal(element, getEnvs());
+ PathMacroManager.getInstance(getProject()).collapsePathsRecursively(element);
+ if (myConfigurationModule.getModule() != null) {
+ myConfigurationModule.writeExternal(element);
+ }
+ }
+
+ @Override
+ public void checkConfiguration() throws RuntimeConfigurationException {
+ JavaParametersUtil.checkAlternativeJRE(this);
+ ProgramParametersUtil.checkWorkingDirectoryExist(this, getProject(), null);
+ File jarFile = new File(getJarPath());
+ if (!jarFile.exists()) {
+ throw new RuntimeConfigurationWarning("JAR file '" + jarFile.getAbsolutePath() + "' doesn't exist");
+ }
+ JavaRunConfigurationExtensionManager.checkConfigurationIsValid(this);
+ }
+
+ @NotNull
+ @Override
+ public Module[] getModules() {
+ Module module = myConfigurationModule.getModule();
+ return module != null ? new Module[] {module}: Module.EMPTY_ARRAY;
+ }
+
+ @Nullable
+ @Override
+ public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException {
+ return new JarApplicationCommandLineState(this, environment);
+ }
+
+ public String getJarPath() {
+ return myBean.JAR_PATH;
+ }
+
+ public void setJarPath(String jarPath) {
+ myBean.JAR_PATH = jarPath;
+ }
+
+ @Override
+ public void setVMParameters(String value) {
+ myBean.VM_PARAMETERS = value;
+ }
+
+ @Override
+ public String getVMParameters() {
+ return myBean.VM_PARAMETERS;
+ }
+
+ @Override
+ public boolean isAlternativeJrePathEnabled() {
+ return myBean.ALTERNATIVE_JRE_PATH_ENABLED;
+ }
+
+ @Override
+ public void setAlternativeJrePathEnabled(boolean enabled) {
+ myBean.ALTERNATIVE_JRE_PATH_ENABLED = enabled;
+ }
+
+ @Override
+ public String getAlternativeJrePath() {
+ return myBean.ALTERNATIVE_JRE_PATH;
+ }
+
+ @Override
+ public void setAlternativeJrePath(String path) {
+ myBean.ALTERNATIVE_JRE_PATH = path;
+ }
+
+ @Nullable
+ @Override
+ public String getRunClass() {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public String getPackage() {
+ return null;
+ }
+
+ @Override
+ public void setProgramParameters(@Nullable String value) {
+ myBean.PROGRAM_PARAMETERS = value;
+ }
+
+ @Nullable
+ @Override
+ public String getProgramParameters() {
+ return myBean.PROGRAM_PARAMETERS;
+ }
+
+ @Override
+ public void setWorkingDirectory(@Nullable String value) {
+ myBean.WORKING_DIRECTORY = value;
+ }
+
+ @Nullable
+ @Override
+ public String getWorkingDirectory() {
+ return myBean.WORKING_DIRECTORY;
+ }
+
+ @Override
+ public void setEnvs(@NotNull Map<String, String> envs) {
+ myEnvs.clear();
+ myEnvs.putAll(envs);
+ }
+
+ @NotNull
+ @Override
+ public Map<String, String> getEnvs() {
+ return myEnvs;
+ }
+
+ @Override
+ public void setPassParentEnvs(boolean passParentEnvs) {
+ myBean.PASS_PARENT_ENVS = passParentEnvs;
+ }
+
+ @Override
+ public boolean isPassParentEnvs() {
+ return myBean.PASS_PARENT_ENVS;
+ }
+
+ private static class JarApplicationConfigurationBean {
+ public String JAR_PATH = "";
+ public String VM_PARAMETERS = "";
+ public String PROGRAM_PARAMETERS = "";
+ public String WORKING_DIRECTORY = "";
+ public boolean ALTERNATIVE_JRE_PATH_ENABLED;
+ public String ALTERNATIVE_JRE_PATH = "";
+ public boolean PASS_PARENT_ENVS = true;
+ }
+}
diff --git a/java/execution/impl/src/com/intellij/execution/jar/JarApplicationConfigurationProducer.java b/java/execution/impl/src/com/intellij/execution/jar/JarApplicationConfigurationProducer.java
new file mode 100644
index 000000000000..b2b9f8fef81c
--- /dev/null
+++ b/java/execution/impl/src/com/intellij/execution/jar/JarApplicationConfigurationProducer.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.execution.jar;
+
+import com.intellij.execution.Location;
+import com.intellij.execution.actions.ConfigurationContext;
+import com.intellij.execution.actions.RunConfigurationProducer;
+import com.intellij.openapi.util.Ref;
+import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.util.io.FileUtilRt;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author nik
+ */
+public class JarApplicationConfigurationProducer extends RunConfigurationProducer<JarApplicationConfiguration> {
+ public JarApplicationConfigurationProducer() {
+ super(JarApplicationConfigurationType.getInstance());
+ }
+
+ @Override
+ protected boolean setupConfigurationFromContext(JarApplicationConfiguration configuration,
+ ConfigurationContext context,
+ Ref<PsiElement> sourceElement) {
+ VirtualFile file = getJarFileFromContext(context);
+ if (file != null) {
+ configuration.setName(file.getName());
+ configuration.setJarPath(file.getPath());
+ return true;
+ }
+ return false;
+ }
+
+ @Nullable
+ private static VirtualFile getJarFileFromContext(ConfigurationContext context) {
+ Location location = context.getLocation();
+ if (location == null) return null;
+
+ VirtualFile file = location.getVirtualFile();
+ return file != null && FileUtilRt.extensionEquals(file.getName(), "jar") ? file : null;
+ }
+
+ @Override
+ public boolean isConfigurationFromContext(JarApplicationConfiguration configuration, ConfigurationContext context) {
+ VirtualFile file = getJarFileFromContext(context);
+ return file != null && FileUtil.pathsEqual(file.getPath(), configuration.getJarPath());
+ }
+}
diff --git a/java/execution/impl/src/com/intellij/execution/jar/JarApplicationConfigurationType.java b/java/execution/impl/src/com/intellij/execution/jar/JarApplicationConfigurationType.java
new file mode 100644
index 000000000000..8c7fdebc8c52
--- /dev/null
+++ b/java/execution/impl/src/com/intellij/execution/jar/JarApplicationConfigurationType.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.execution.jar;
+
+import com.intellij.execution.ExecutionBundle;
+import com.intellij.execution.configuration.ConfigurationFactoryEx;
+import com.intellij.execution.configurations.ConfigurationType;
+import com.intellij.execution.configurations.ConfigurationTypeBase;
+import com.intellij.execution.configurations.ConfigurationTypeUtil;
+import com.intellij.execution.configurations.RunConfiguration;
+import com.intellij.icons.AllIcons;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.util.text.StringUtil;
+import org.jetbrains.annotations.NotNull;
+
+public class JarApplicationConfigurationType extends ConfigurationTypeBase implements ConfigurationType {
+ @NotNull
+ public static JarApplicationConfigurationType getInstance() {
+ return ConfigurationTypeUtil.findConfigurationType(JarApplicationConfigurationType.class);
+ }
+
+ public JarApplicationConfigurationType() {
+ super("JarApplication", ExecutionBundle.message("jar.application.configuration.name"),
+ ExecutionBundle.message("jar.application.configuration.description"), AllIcons.FileTypes.Archive);
+ addFactory(new ConfigurationFactoryEx(this) {
+ @Override
+ public void onNewConfigurationCreated(@NotNull RunConfiguration configuration) {
+ JarApplicationConfiguration jarApplicationConfiguration = (JarApplicationConfiguration)configuration;
+ if (StringUtil.isEmpty(jarApplicationConfiguration.getWorkingDirectory())) {
+ String baseDir = FileUtil.toSystemIndependentName(StringUtil.notNullize(configuration.getProject().getBasePath()));
+ jarApplicationConfiguration.setWorkingDirectory(baseDir);
+ }
+ }
+
+ public RunConfiguration createTemplateConfiguration(Project project) {
+ return new JarApplicationConfiguration(project, this, "");
+ }
+ });
+ }
+}
diff --git a/java/execution/impl/src/com/intellij/execution/jar/JarApplicationDebuggerRunner.java b/java/execution/impl/src/com/intellij/execution/jar/JarApplicationDebuggerRunner.java
new file mode 100644
index 000000000000..dc5bfbfb6129
--- /dev/null
+++ b/java/execution/impl/src/com/intellij/execution/jar/JarApplicationDebuggerRunner.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.execution.jar;
+
+import com.intellij.debugger.impl.GenericDebuggerRunner;
+import com.intellij.execution.configurations.RunProfile;
+import com.intellij.execution.executors.DefaultDebugExecutor;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author nik
+ */
+public class JarApplicationDebuggerRunner extends GenericDebuggerRunner {
+ @Override
+ public boolean canRun(@NotNull String executorId, @NotNull RunProfile profile) {
+ return DefaultDebugExecutor.EXECUTOR_ID.equals(executorId) && profile instanceof JarApplicationConfiguration;
+ }
+
+ @NotNull
+ @Override
+ public String getRunnerId() {
+ return "JarDebug";
+ }
+}
diff --git a/java/execution/impl/src/com/intellij/execution/junit/InheritorChooser.java b/java/execution/impl/src/com/intellij/execution/junit/InheritorChooser.java
index d318ad47bb70..fc0e65f9742b 100644
--- a/java/execution/impl/src/com/intellij/execution/junit/InheritorChooser.java
+++ b/java/execution/impl/src/com/intellij/execution/junit/InheritorChooser.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@ import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.Conditions;
import com.intellij.psi.*;
import com.intellij.psi.search.searches.ClassInheritorsSearch;
import com.intellij.psi.util.PsiClassUtil;
@@ -59,7 +60,7 @@ public class InheritorChooser {
final Runnable performRunnable,
final PsiMethod psiMethod,
final PsiClass containingClass) {
- return runMethodInAbstractClass(context, performRunnable, psiMethod, containingClass, Condition.TRUE);
+ return runMethodInAbstractClass(context, performRunnable, psiMethod, containingClass, Conditions.<PsiClass>alwaysTrue());
}
public boolean runMethodInAbstractClass(final ConfigurationContext context,
@@ -114,6 +115,7 @@ public class InheritorChooser {
}
}
}
+ final int numberOfInheritors = classes.size();
final PsiClassListCellRenderer renderer = new PsiClassListCellRenderer() {
@Override
protected boolean customizeNonPsiElementLeftRenderer(ColoredListCellRenderer renderer,
@@ -123,7 +125,7 @@ public class InheritorChooser {
boolean selected,
boolean hasFocus) {
if (value == null) {
- renderer.append("All");
+ renderer.append("All (" + numberOfInheritors + ")");
return true;
}
return super.customizeNonPsiElementLeftRenderer(renderer, list, value, index, selected, hasFocus);
diff --git a/java/execution/impl/src/com/intellij/execution/runners/ProcessProxyFactoryImpl.java b/java/execution/impl/src/com/intellij/execution/runners/ProcessProxyFactoryImpl.java
index 6af48770e78d..4b20e2189202 100644
--- a/java/execution/impl/src/com/intellij/execution/runners/ProcessProxyFactoryImpl.java
+++ b/java/execution/impl/src/com/intellij/execution/runners/ProcessProxyFactoryImpl.java
@@ -30,15 +30,16 @@ import java.io.File;
public class ProcessProxyFactoryImpl extends ProcessProxyFactory {
public ProcessProxy createCommandLineProxy(final JavaCommandLine javaCmdLine) throws ExecutionException {
ProcessProxyImpl proxy = null;
- if (ProcessProxyImpl.useLauncher()) {
+ final JavaParameters javaParameters = javaCmdLine.getJavaParameters();
+ String mainClass = javaParameters.getMainClass();
+ if (ProcessProxyImpl.useLauncher() && mainClass != null) {
try {
proxy = new ProcessProxyImpl();
- final JavaParameters javaParameters = javaCmdLine.getJavaParameters();
JavaSdkUtil.addRtJar(javaParameters.getClassPath());
final ParametersList vmParametersList = javaParameters.getVMParametersList();
vmParametersList.defineProperty(ProcessProxyImpl.PROPERTY_PORT_NUMBER, String.valueOf(proxy.getPortNumber()));
vmParametersList.defineProperty(ProcessProxyImpl.PROPERTY_BINPATH, PathManager.getBinPath());
- javaParameters.getProgramParametersList().prepend(javaParameters.getMainClass());
+ javaParameters.getProgramParametersList().prepend(mainClass);
javaParameters.setMainClass(ProcessProxyImpl.LAUNCH_MAIN_CLASS);
}
catch (ProcessProxyImpl.NoMoreSocketsException e) {
diff --git a/java/execution/impl/src/com/intellij/execution/util/JavaParametersUtil.java b/java/execution/impl/src/com/intellij/execution/util/JavaParametersUtil.java
index 18aead7fe7f1..4d948dae8a2d 100644
--- a/java/execution/impl/src/com/intellij/execution/util/JavaParametersUtil.java
+++ b/java/execution/impl/src/com/intellij/execution/util/JavaParametersUtil.java
@@ -27,7 +27,6 @@ import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.JavaSdk;
-import com.intellij.openapi.projectRoots.JavaSdkType;
import com.intellij.openapi.projectRoots.ProjectJdkTable;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.ex.PathUtilEx;
@@ -118,7 +117,7 @@ public class JavaParametersUtil {
return jreHome == null ? JavaParameters.getModuleJdk(module) : createAlternativeJdk(jreHome);
}
- private static Sdk createProjectJdk(final Project project, final String jreHome) throws CantRunException {
+ public static Sdk createProjectJdk(final Project project, final String jreHome) throws CantRunException {
return jreHome == null ? createProjectJdk(project) : createAlternativeJdk(jreHome);
}