Example #1
0
    @Override
    public void run() {
      try {
        PySelection selection = new PySelection(edit);

        ScriptConsole console = ScriptConsole.getActiveScriptConsole();

        if (console == null) {
          // if no console is available, create it (if possible).
          PydevConsoleFactory factory = new PydevConsoleFactory();
          String cmd = null;

          // Check if the current selection should be sent to the editor.
          if (InteractiveConsolePrefs.getSendCommandOnCreationFromEditor()) {
            cmd = getCommandToSend(edit, selection);
            if (cmd != null) {
              cmd = "\n" + cmd;
            }
          }
          factory.createConsole(cmd);

        } else {
          if (console instanceof ScriptConsole) {
            // ok, console available
            sendCommandToConsole(selection, console, this.edit);
          }
        }
      } catch (Exception e) {
        Log.log(e);
      }
    }