diff --git a/python/ide/src/com/jetbrains/python/PyIdeCommonOptionsForm.form b/python/ide/src/com/jetbrains/python/PyIdeCommonOptionsForm.form index a8225d6a3447..b732b517538b 100644 --- a/python/ide/src/com/jetbrains/python/PyIdeCommonOptionsForm.form +++ b/python/ide/src/com/jetbrains/python/PyIdeCommonOptionsForm.form @@ -7,7 +7,7 @@ - + @@ -15,7 +15,7 @@ - + @@ -121,15 +121,6 @@ - - - - - - - - - diff --git a/python/ide/src/com/jetbrains/python/PyIdeCommonOptionsForm.java b/python/ide/src/com/jetbrains/python/PyIdeCommonOptionsForm.java index 3cfd58277f71..79c35527e673 100644 --- a/python/ide/src/com/jetbrains/python/PyIdeCommonOptionsForm.java +++ b/python/ide/src/com/jetbrains/python/PyIdeCommonOptionsForm.java @@ -71,7 +71,6 @@ public class PyIdeCommonOptionsForm implements AbstractPyCommonOptionsForm { private JPanel myHideablePanel; private JBCheckBox myAddContentRootsCheckbox; private JBCheckBox myAddSourceRootsCheckbox; - private JBCheckBox myShowCommandLineCheckbox; private JComponent labelAnchor; private final Project myProject; @@ -296,16 +295,6 @@ public class PyIdeCommonOptionsForm implements AbstractPyCommonOptionsForm { myAddSourceRootsCheckbox.setSelected(add); } - @Override - public boolean showCommandLineAfterwards() { - return myShowCommandLineCheckbox.isSelected(); - } - - @Override - public void setShowCommandLineAfterwards(boolean showCommandLineAfterwards) { - myShowCommandLineCheckbox.setSelected(showCommandLineAfterwards); - } - private void createUIComponents() { myInterpreterComboBox = new ComboBox(100); } diff --git a/python/openapi/src/com/jetbrains/python/run/AbstractPythonRunConfigurationParams.java b/python/openapi/src/com/jetbrains/python/run/AbstractPythonRunConfigurationParams.java index 025d361e655b..1ed994e7ca10 100644 --- a/python/openapi/src/com/jetbrains/python/run/AbstractPythonRunConfigurationParams.java +++ b/python/openapi/src/com/jetbrains/python/run/AbstractPythonRunConfigurationParams.java @@ -64,7 +64,4 @@ public interface AbstractPythonRunConfigurationParams { boolean addSourceRoots(); void addContentRoots(boolean add); void addSourceRoots(boolean add); - - boolean showCommandLineAfterwards(); - void setShowCommandLineAfterwards(boolean showCommandLineAfterwards); } diff --git a/python/openapi/src/com/jetbrains/python/run/PythonRunConfigurationParams.java b/python/openapi/src/com/jetbrains/python/run/PythonRunConfigurationParams.java index 80ca3ce1a4ef..adb1c31e6134 100644 --- a/python/openapi/src/com/jetbrains/python/run/PythonRunConfigurationParams.java +++ b/python/openapi/src/com/jetbrains/python/run/PythonRunConfigurationParams.java @@ -28,5 +28,8 @@ public interface PythonRunConfigurationParams { String getScriptParameters(); void setScriptParameters(String scriptParameters); + + boolean showCommandLineAfterwards(); + void setShowCommandLineAfterwards(boolean showCommandLineAfterwards); } diff --git a/python/src/com/jetbrains/python/run/AbstractPythonRunConfiguration.java b/python/src/com/jetbrains/python/run/AbstractPythonRunConfiguration.java index d1b847b5d756..0927d2e37a3d 100644 --- a/python/src/com/jetbrains/python/run/AbstractPythonRunConfiguration.java +++ b/python/src/com/jetbrains/python/run/AbstractPythonRunConfiguration.java @@ -64,7 +64,6 @@ public abstract class AbstractPythonRunConfiguration actions = Lists.newArrayList(createActions(console, processHandler)); - return new DefaultExecutionResult(runner.getConsoleView(), runner.getProcessHandler()); - } - else { - final ProcessHandler processHandler = startProcess(patchers); - final ConsoleView console = createAndAttachConsole(myConfig.getProject(), processHandler, executor); - - List actions = Lists.newArrayList(createActions(console, processHandler)); - - return new DefaultExecutionResult(console, processHandler, actions.toArray(new AnAction[actions.size()])); - } + return new DefaultExecutionResult(console, processHandler, actions.toArray(new AnAction[actions.size()])); } @NotNull diff --git a/python/src/com/jetbrains/python/run/PythonRunConfiguration.java b/python/src/com/jetbrains/python/run/PythonRunConfiguration.java index 118c27beb548..5efc8d465bc1 100644 --- a/python/src/com/jetbrains/python/run/PythonRunConfiguration.java +++ b/python/src/com/jetbrains/python/run/PythonRunConfiguration.java @@ -47,8 +47,10 @@ public class PythonRunConfiguration extends AbstractPythonRunConfiguration public static final String SCRIPT_NAME = "SCRIPT_NAME"; public static final String PARAMETERS = "PARAMETERS"; public static final String MULTIPROCESS = "MULTIPROCESS"; + public static final String SHOW_COMMAND_LINE = "SHOW_COMMAND_LINE"; private String myScriptName; private String myScriptParameters; + private boolean myShowCommandLineAfterwards = false; protected PythonRunConfiguration(Project project, ConfigurationFactory configurationFactory) { super(project, configurationFactory); @@ -98,17 +100,27 @@ public class PythonRunConfiguration extends AbstractPythonRunConfiguration myScriptParameters = scriptParameters; } + public boolean showCommandLineAfterwards() { + return myShowCommandLineAfterwards; + } + + public void setShowCommandLineAfterwards(boolean showCommandLineAfterwards) { + myShowCommandLineAfterwards = showCommandLineAfterwards; + } + public void readExternal(Element element) throws InvalidDataException { PathMacroManager.getInstance(getProject()).expandPaths(element); super.readExternal(element); myScriptName = JDOMExternalizerUtil.readField(element, SCRIPT_NAME); myScriptParameters = JDOMExternalizerUtil.readField(element, PARAMETERS); + myShowCommandLineAfterwards = Boolean.parseBoolean(JDOMExternalizerUtil.readField(element, SHOW_COMMAND_LINE, "false")); } public void writeExternal(Element element) throws WriteExternalException { super.writeExternal(element); JDOMExternalizerUtil.writeField(element, SCRIPT_NAME, myScriptName); JDOMExternalizerUtil.writeField(element, PARAMETERS, myScriptParameters); + JDOMExternalizerUtil.writeField(element, SHOW_COMMAND_LINE, Boolean.toString(myShowCommandLineAfterwards)); PathMacroManager.getInstance(getProject()).collapsePathsRecursively(element); } @@ -120,6 +132,7 @@ public class PythonRunConfiguration extends AbstractPythonRunConfiguration AbstractPythonRunConfiguration.copyParams(source.getBaseParams(), target.getBaseParams()); target.setScriptName(source.getScriptName()); target.setScriptParameters(source.getScriptParameters()); + target.setShowCommandLineAfterwards(source.showCommandLineAfterwards()); } @Override diff --git a/python/src/com/jetbrains/python/run/PythonRunConfigurationForm.form b/python/src/com/jetbrains/python/run/PythonRunConfigurationForm.form index 1ba245143902..33e45b9c04ee 100644 --- a/python/src/com/jetbrains/python/run/PythonRunConfigurationForm.form +++ b/python/src/com/jetbrains/python/run/PythonRunConfigurationForm.form @@ -1,6 +1,6 @@
- + @@ -44,7 +44,7 @@ - + @@ -63,6 +63,15 @@ + + + + + + + + + diff --git a/python/src/com/jetbrains/python/run/PythonRunConfigurationForm.java b/python/src/com/jetbrains/python/run/PythonRunConfigurationForm.java index da041f961f80..cad905fd9618 100644 --- a/python/src/com/jetbrains/python/run/PythonRunConfigurationForm.java +++ b/python/src/com/jetbrains/python/run/PythonRunConfigurationForm.java @@ -25,6 +25,7 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.PanelWithAnchor; import com.intellij.ui.RawCommandLineEditor; +import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBLabel; import com.jetbrains.python.debugger.PyDebuggerOptionsProvider; import org.jetbrains.annotations.NotNull; @@ -44,6 +45,7 @@ public class PythonRunConfigurationForm implements PythonRunConfigurationParams, private final AbstractPyCommonOptionsForm myCommonOptionsForm; private JComponent anchor; private final Project myProject; + private JBCheckBox myShowCommandLineCheckbox; public PythonRunConfigurationForm(PythonRunConfiguration configuration) { myCommonOptionsForm = PyCommonOptionsFormFactory.getInstance().createForm(configuration.getCommonOptionsFormData()); @@ -104,6 +106,16 @@ public class PythonRunConfigurationForm implements PythonRunConfigurationParams, myScriptParametersTextField.setText(scriptParameters); } + @Override + public boolean showCommandLineAfterwards() { + return myShowCommandLineCheckbox.isSelected(); + } + + @Override + public void setShowCommandLineAfterwards(boolean showCommandLineAfterwards) { + myShowCommandLineCheckbox.setSelected(showCommandLineAfterwards); + } + @Override public JComponent getAnchor() { return anchor; diff --git a/python/src/com/jetbrains/python/run/PythonScriptCommandLineState.java b/python/src/com/jetbrains/python/run/PythonScriptCommandLineState.java index 81d2daaee3d0..65466a049dc4 100644 --- a/python/src/com/jetbrains/python/run/PythonScriptCommandLineState.java +++ b/python/src/com/jetbrains/python/run/PythonScriptCommandLineState.java @@ -15,11 +15,18 @@ */ package com.jetbrains.python.run; +import com.intellij.execution.DefaultExecutionResult; +import com.intellij.execution.ExecutionException; +import com.intellij.execution.ExecutionResult; +import com.intellij.execution.Executor; import com.intellij.execution.configurations.GeneralCommandLine; import com.intellij.execution.configurations.ParametersList; import com.intellij.execution.configurations.ParamsGroup; import com.intellij.execution.runners.ExecutionEnvironment; import com.intellij.openapi.util.text.StringUtil; +import com.jetbrains.python.console.PyConsoleType; +import com.jetbrains.python.console.PydevConsoleRunner; +import org.jetbrains.annotations.NotNull; /** * @author yole @@ -32,6 +39,23 @@ public class PythonScriptCommandLineState extends PythonCommandLineState { myConfig = runConfiguration; } + @NotNull + @Override + public ExecutionResult execute(Executor executor, CommandLinePatcher... patchers) throws ExecutionException { + if (myConfig.showCommandLineAfterwards()) { + PydevConsoleRunner runner = + new PydevConsoleRunner(myConfig.getProject(), myConfig.getSdk(), PyConsoleType.PYTHON, myConfig.getWorkingDirectory(), + myConfig.getEnvs()); + + runner.run(); + + return new DefaultExecutionResult(runner.getConsoleView(), runner.getProcessHandler()); + } + else { + return super.execute(executor, patchers); + } + } + @Override protected void buildCommandLineParameters(GeneralCommandLine commandLine) { ParametersList parametersList = commandLine.getParametersList(); @@ -52,5 +76,4 @@ public class PythonScriptCommandLineState extends PythonCommandLineState { commandLine.setWorkDirectory(myConfig.getWorkingDirectory()); } } - }