mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
continue WEB-1171 javascript live console: add history actions
This commit is contained in:
@@ -86,6 +86,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* @author Gregory.Shrago
|
||||
* In case of REPL consider to use {@link com.intellij.execution.runners.LanguageConsoleBuilder}
|
||||
*/
|
||||
public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider {
|
||||
private static final Logger LOG = Logger.getInstance("#" + LanguageConsoleImpl.class.getName());
|
||||
|
||||
+4
-20
@@ -47,7 +47,7 @@ import java.util.List;
|
||||
* This class provides basic functionality for running consoles.
|
||||
* It launches external process and handles line input with history
|
||||
*/
|
||||
public abstract class AbstractConsoleRunnerWithHistory<T extends LanguageConsoleView> extends ConsoleRunnerWithHistory<T> {
|
||||
public abstract class AbstractConsoleRunnerWithHistory<T extends LanguageConsoleView> {
|
||||
private final String myConsoleTitle;
|
||||
|
||||
private ProcessHandler myProcessHandler;
|
||||
@@ -55,11 +55,12 @@ public abstract class AbstractConsoleRunnerWithHistory<T extends LanguageConsole
|
||||
|
||||
private T myConsoleView;
|
||||
|
||||
private final Project myProject;
|
||||
|
||||
private ConsoleExecuteActionHandler myConsoleExecuteActionHandler;
|
||||
|
||||
public AbstractConsoleRunnerWithHistory(@NotNull Project project, @NotNull String consoleTitle, @Nullable String workingDir) {
|
||||
super(project);
|
||||
|
||||
myProject = project;
|
||||
myConsoleTitle = consoleTitle;
|
||||
myWorkingDir = workingDir;
|
||||
}
|
||||
@@ -252,23 +253,6 @@ public abstract class AbstractConsoleRunnerWithHistory<T extends LanguageConsole
|
||||
protected abstract ConsoleExecuteActionHandler createConsoleExecuteActionHandler();
|
||||
|
||||
|
||||
private static class ProcessBackedConsoleExecuteAction extends ConsoleExecuteAction {
|
||||
private final ProcessHandler myProcessHandler;
|
||||
|
||||
public ProcessBackedConsoleExecuteAction(LanguageConsoleImpl languageConsole,
|
||||
ProcessHandler processHandler,
|
||||
ConsoleExecuteActionHandler consoleExecuteActionHandler) {
|
||||
super(languageConsole, consoleExecuteActionHandler);
|
||||
|
||||
myProcessHandler = processHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEnabled() {
|
||||
return !myProcessHandler.isProcessTerminated();
|
||||
}
|
||||
}
|
||||
|
||||
public T getConsoleView() {
|
||||
return myConsoleView;
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.intellij.execution.runners;
|
||||
|
||||
import com.intellij.execution.console.LanguageConsoleView;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class ConsoleRunnerWithHistory<T extends LanguageConsoleView> {
|
||||
protected final Project myProject;
|
||||
|
||||
public ConsoleRunnerWithHistory(@NotNull Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.intellij.execution.runners;
|
||||
|
||||
import com.intellij.execution.console.ConsoleHistoryController;
|
||||
import com.intellij.execution.console.LanguageConsoleImpl;
|
||||
import com.intellij.execution.console.LanguageConsoleView;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class LanguageConsoleBuilder {
|
||||
private LanguageConsoleImpl myConsole;
|
||||
private ProcessHandler myProcessHandler;
|
||||
|
||||
public LanguageConsoleBuilder console(@NotNull LanguageConsoleView console) {
|
||||
myConsole = console.getConsole();
|
||||
return this;
|
||||
}
|
||||
|
||||
public LanguageConsoleBuilder processHandler(ProcessHandler processHandler) {
|
||||
myProcessHandler = processHandler;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LanguageConsoleBuilder initActions(@NotNull BaseConsoleExecuteActionHandler executeActionHandler, @NotNull String historyType) {
|
||||
ConsoleExecuteAction action = myProcessHandler == null
|
||||
? new ConsoleExecuteAction(myConsole, executeActionHandler)
|
||||
: new ProcessBackedConsoleExecuteAction(myConsole, myProcessHandler, executeActionHandler);
|
||||
action.registerCustomShortcutSet(action.getShortcutSet(), myConsole.getConsoleEditor().getComponent());
|
||||
|
||||
new ConsoleHistoryController(historyType, "", myConsole, executeActionHandler.getConsoleHistoryModel()).install();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.intellij.execution.runners;
|
||||
|
||||
import com.intellij.execution.console.LanguageConsoleImpl;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
|
||||
class ProcessBackedConsoleExecuteAction extends ConsoleExecuteAction {
|
||||
private final ProcessHandler myProcessHandler;
|
||||
|
||||
public ProcessBackedConsoleExecuteAction(LanguageConsoleImpl languageConsole,
|
||||
ProcessHandler processHandler,
|
||||
BaseConsoleExecuteActionHandler consoleExecuteActionHandler) {
|
||||
super(languageConsole, consoleExecuteActionHandler);
|
||||
|
||||
myProcessHandler = processHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEnabled() {
|
||||
return !myProcessHandler.isProcessTerminated();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user