in src/java/org/jetbrains/plugins/clojure/repl/ClojureConsoleRunner.java [118:193]
public void initAndRun(Module module, final String... statements2execute) throws ExecutionException {
// Create Server process
final Process process = createProcess(myProvider);
// !!! do not change order!!!
myConsoleView = createConsoleView(module);
myHistory = new ConsoleHistoryController("clojure", null, myConsoleView);
myConsoleView.setHistoryController(myHistory);
myProcessHandler = new ClojureConsoleProcessHandler(process, myProvider.getCommandLineString(), getConsoleView());
myConsoleExecuteActionHandler = new ClojureConsoleExecuteActionHandler(getProcessHandler(), getProject(), false);
getConsoleView().setExecuteHandler(myConsoleExecuteActionHandler);
// Init a console view
ProcessTerminatedListener.attach(myProcessHandler);
myProcessHandler.addProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(ProcessEvent event) {
myRunAction.getTemplatePresentation().setEnabled(false);
myConsoleView.setPrompt("");
myConsoleView.getConsoleEditor().setRendererMode(true);
ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
myConsoleView.getConsoleEditor().getComponent().updateUI();
}
});
}
});
// Attach a console view to the process
myConsoleView.attachToProcess(myProcessHandler);
// Runner creating
final Executor defaultExecutor = ExecutorRegistry.getInstance().getExecutorById(DefaultRunExecutor.EXECUTOR_ID);
final DefaultActionGroup toolbarActions = new DefaultActionGroup();
final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, toolbarActions, false);
final JPanel panel = new JPanel(new BorderLayout());
panel.add(actionToolbar.getComponent(), BorderLayout.WEST);
panel.add(myConsoleView.getComponent(), BorderLayout.CENTER);
final RunContentDescriptor myDescriptor =
new RunContentDescriptor(myConsoleView, myProcessHandler, panel, myConsoleTitle);
// tool bar actions
final AnAction[] actions = fillToolBarActions(toolbarActions, defaultExecutor, myDescriptor);
registerActionShortcuts(actions, getConsoleView().getConsoleEditor().getComponent());
registerActionShortcuts(actions, panel);
panel.updateUI();
// enter action
createAndRegisterEnterAction(panel);
// Show in run tool window
ExecutionManager.getInstance(myProject).getContentManager().showRunContent(defaultExecutor, myDescriptor);
// Request focus
final ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(defaultExecutor.getId());
window.activate(new Runnable() {
public void run() {
IdeFocusManager.getInstance(myProject).requestFocus(getConsoleView().getCurrentEditor().getContentComponent(), true);
}
});
// Run
myProcessHandler.startNotify();
final ClojureConsole console = getConsoleView();
for (String statement : statements2execute) {
final String st = statement + "\n";
ClojureConsoleHighlightingUtil.processOutput(console, st, ProcessOutputTypes.SYSTEM);
final ClojureConsoleExecuteActionHandler actionHandler = getConsoleExecuteActionHandler();
actionHandler.processLine(st);
}
}