Move Debug console view related stuff to an appropriate class
[idea/community.git] / python / src / com / jetbrains / python / console / PythonDebugLanguageConsoleView.java
index 177ce1fc9bdcaca4d9b5d65aff7a5ee23614978d..d2d5257c3e5ce73a6bfe97eabd8b88b6418ec8ba 100644 (file)
@@ -18,6 +18,7 @@ package com.jetbrains.python.console;
 import com.intellij.execution.console.DuplexConsoleView;
 import com.intellij.execution.filters.TextConsoleBuilderFactory;
 import com.intellij.execution.impl.ConsoleViewImpl;
+import com.intellij.execution.process.ProcessOutputTypes;
 import com.intellij.execution.ui.ConsoleView;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
@@ -34,6 +35,7 @@ import org.jetbrains.annotations.Nullable;
 public class PythonDebugLanguageConsoleView extends DuplexConsoleView<ConsoleView, PythonConsoleView> implements PyCodeExecutor {
 
   public static final String DEBUG_CONSOLE_START_COMMAND = "import sys; print('Python %s on %s' % (sys.version, sys.platform))";
+  private boolean myDebugConsoleInitialized = false;
 
   public PythonDebugLanguageConsoleView(final Project project, Sdk sdk, ConsoleView consoleView) {
     super(consoleView, new PythonConsoleView(project, "Python Console", sdk));
@@ -67,16 +69,21 @@ public class PythonDebugLanguageConsoleView extends DuplexConsoleView<ConsoleVie
     return null;
   }
 
+  public void showStartMessageForFirstExecution(String startCommand, PythonConsoleView console) {
+    console.setPrompt("");
+    console.executeStatement(startCommand + "\n", ProcessOutputTypes.SYSTEM);
+  }
+
   @Override
   public void enableConsole(boolean primary) {
     super.enableConsole(primary);
 
     if (!primary && !isPrimaryConsoleEnabled()) {
       PythonConsoleView console = getPydevConsoleView();
-      if (console.isConsoleEnabledFirstTime()) {
+      if (!myDebugConsoleInitialized && console.getExecuteActionHandler() != null) {
         console.addConsoleFolding(true);
-        console.showStartMessageForFirstExecution(DEBUG_CONSOLE_START_COMMAND);
-        console.setFirstRun(false);
+        showStartMessageForFirstExecution(DEBUG_CONSOLE_START_COMMAND, console);
+        myDebugConsoleInitialized = true;
       }
 
       IdeFocusManager.findInstance().requestFocus(console.getConsoleEditor().getContentComponent(), true);