Move Debug console view related stuff to an appropriate class
authorElizaveta Shashkova <Elizaveta.Shashkova@jetbrains.com>
Wed, 16 Nov 2016 11:24:40 +0000 (14:24 +0300)
committerElizaveta Shashkova <Elizaveta.Shashkova@jetbrains.com>
Wed, 16 Nov 2016 11:28:45 +0000 (14:28 +0300)
python/src/com/jetbrains/python/console/PythonConsoleView.java
python/src/com/jetbrains/python/console/PythonDebugLanguageConsoleView.java

index a3df1ceac153245ba22fa17ea9a0fc897572aef0..31f3663f68e15e1bef5165d81ee2d0c483e734aa 100644 (file)
@@ -89,7 +89,6 @@ public class PythonConsoleView extends LanguageConsoleImpl implements Observable
   private final PyHighlighter myPyHighlighter;
   private final EditorColorsScheme myScheme;
   private boolean myHyperlink;
-  private boolean myFirstRun = true;
 
   private XStandaloneVariablesView mySplitView;
   private ActionCallback myInitialized = new ActionCallback();
@@ -144,28 +143,16 @@ public class PythonConsoleView extends LanguageConsoleImpl implements Observable
     myExecuteActionHandler = consoleExecuteActionHandler;
   }
 
+  public PydevConsoleExecuteActionHandler getExecuteActionHandler() {
+    return myExecuteActionHandler;
+  }
+
   public void setConsoleEnabled(boolean flag) {
     if (myExecuteActionHandler != null) {
       myExecuteActionHandler.setEnabled(flag);
     }
   }
 
-  public boolean isConsoleEnabledFirstTime() {
-    return myFirstRun && myExecuteActionHandler != null;
-  }
-
-  public void setFirstRun(boolean firstRun) {
-    myFirstRun = firstRun;
-  }
-
-  public void showStartMessageForFirstExecution(String startCommand) {
-    if (myFirstRun && myExecuteActionHandler != null) {
-      setPrompt("");
-      executeStatement(startCommand + "\n", ProcessOutputTypes.SYSTEM);
-    }
-  }
-
-
   public void inputRequested() {
     if (myExecuteActionHandler != null) {
       final ConsoleCommunication consoleCommunication = myExecuteActionHandler.getConsoleCommunication();
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);