EDU-588 Add ability to turn off interactive console
authorLiana Bakradze <liana.bakradze@jetbrains.com>
Thu, 14 Apr 2016 14:24:57 +0000 (17:24 +0300)
committerLiana Bakradze <liana.bakradze@jetbrains.com>
Thu, 14 Apr 2016 14:24:57 +0000 (17:24 +0300)
python/educational-python/src/com/jetbrains/python/edu/debugger/PyEduDebugRunner.java

index 195117796bad7e9572ec659bfadc605e2a19557c..596eb4e2325b4096958c246fff84b00e5dfbccea 100644 (file)
@@ -152,6 +152,22 @@ public class PyEduDebugRunner extends PyDebugRunner {
     eduConsole.setCloseable(false);
     ui.addContent(eduConsole, 0, PlaceInGrid.right, false);
 
+    Presentation presentation = view.getSwitchConsoleActionPresentation();
+    ToggleAction action = new ToggleAction(presentation.getText(), presentation.getDescription(), presentation.getIcon()) {
+
+      @Override
+      public boolean isSelected(AnActionEvent e) {
+        return !view.isPrimaryConsoleEnabled();
+      }
+
+      @Override
+      public void setSelected(AnActionEvent e, boolean state) {
+        view.enableConsole(!state);
+      }
+    };
+
+    eduConsole.setActions(new DefaultActionGroup(action), ActionPlaces.DEBUGGER_TOOLBAR,
+                          view.getPreferredFocusableComponent());
     PyDebugProcess process = (PyDebugProcess)session.getDebugProcess();
     PyDebugRunner.initDebugConsoleView(project, process, view, processHandler, session);