Search in sources :

Example 6 with CloseAction

use of com.intellij.execution.ui.actions.CloseAction in project intellij-community by JetBrains.

the class RunContentBuilder method createActionToolbar.

@NotNull
private ActionGroup createActionToolbar(@NotNull final RunContentDescriptor contentDescriptor) {
    final DefaultActionGroup actionGroup = new DefaultActionGroup();
    actionGroup.add(ActionManager.getInstance().getAction(IdeActions.ACTION_RERUN));
    final AnAction[] actions = contentDescriptor.getRestartActions();
    actionGroup.addAll(actions);
    if (actions.length > 0) {
        actionGroup.addSeparator();
    }
    actionGroup.add(ActionManager.getInstance().getAction(IdeActions.ACTION_STOP_PROGRAM));
    actionGroup.addAll(myExecutionResult.getActions());
    for (AnAction anAction : myRunnerActions) {
        if (anAction != null) {
            actionGroup.add(anAction);
        } else {
            actionGroup.addSeparator();
        }
    }
    actionGroup.addSeparator();
    actionGroup.add(myUi.getOptions().getLayoutActions());
    actionGroup.addSeparator();
    actionGroup.add(PinToolwindowTabAction.getPinAction());
    actionGroup.add(new CloseAction(myEnvironment.getExecutor(), contentDescriptor, myProject));
    final String helpId = contentDescriptor.getHelpId();
    actionGroup.add(new ContextHelpAction(helpId != null ? helpId : myEnvironment.getExecutor().getHelpId()));
    return actionGroup;
}
Also used : CloseAction(com.intellij.execution.ui.actions.CloseAction) ContextHelpAction(com.intellij.ide.actions.ContextHelpAction) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with CloseAction

use of com.intellij.execution.ui.actions.CloseAction in project intellij-community by JetBrains.

the class DefaultDebugUIEnvironment method initActions.

@Override
public void initActions(RunContentDescriptor content, DefaultActionGroup actionGroup) {
    Executor executor = myExecutionEnvironment.getExecutor();
    actionGroup.add(ActionManager.getInstance().getAction(IdeActions.ACTION_RERUN), Constraints.FIRST);
    actionGroup.add(new CloseAction(executor, content, myExecutionEnvironment.getProject()));
    actionGroup.add(new ContextHelpAction(executor.getHelpId()));
}
Also used : Executor(com.intellij.execution.Executor) CloseAction(com.intellij.execution.ui.actions.CloseAction) ContextHelpAction(com.intellij.ide.actions.ContextHelpAction)

Example 8 with CloseAction

use of com.intellij.execution.ui.actions.CloseAction in project intellij-community by JetBrains.

the class GroovyConsole method createConsole.

@Nullable
public static GroovyConsole createConsole(@NotNull final Project project, @NotNull final VirtualFile contentFile, @NotNull Module module) {
    final ProcessHandler processHandler = createProcessHandler(module);
    if (processHandler == null)
        return null;
    final GroovyConsoleStateService consoleStateService = GroovyConsoleStateService.getInstance(project);
    consoleStateService.setFileModule(contentFile, module);
    final String title = consoleStateService.getSelectedModuleTitle(contentFile);
    final ConsoleViewImpl consoleView = new ConsoleViewImpl(project, true);
    final RunContentDescriptor descriptor = new RunContentDescriptor(consoleView, processHandler, new JPanel(new BorderLayout()), title);
    final GroovyConsole console = new GroovyConsole(project, descriptor, consoleView, processHandler);
    // must call getComponent before createConsoleActions()
    final JComponent consoleViewComponent = consoleView.getComponent();
    final DefaultActionGroup actionGroup = new DefaultActionGroup();
    actionGroup.add(new BuildAndRestartConsoleAction(module, project, defaultExecutor, descriptor, restarter(project, contentFile)));
    actionGroup.addSeparator();
    actionGroup.addAll(consoleView.createConsoleActions());
    actionGroup.add(new CloseAction(defaultExecutor, descriptor, project) {

        @Override
        public void actionPerformed(AnActionEvent e) {
            // use force
            processHandler.destroyProcess();
            super.actionPerformed(e);
        }
    });
    final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actionGroup, false);
    toolbar.setTargetComponent(consoleViewComponent);
    final JComponent ui = descriptor.getComponent();
    ui.add(consoleViewComponent, BorderLayout.CENTER);
    ui.add(toolbar.getComponent(), BorderLayout.WEST);
    project.getMessageBus().connect().subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener() {

        @Override
        public void fileClosed(@NotNull FileEditorManager source, @NotNull VirtualFile file) {
            if (file.equals(contentFile)) {
                // if file was closed then kill process and hide console content
                console.stop();
            }
        }
    });
    processHandler.addProcessListener(new ProcessAdapter() {

        @Override
        public void processTerminated(ProcessEvent event) {
            if (contentFile.getUserData(GROOVY_CONSOLE) == console) {
                // process terminated either by closing file or by close action
                contentFile.putUserData(GROOVY_CONSOLE, null);
            }
        }
    });
    contentFile.putUserData(GROOVY_CONSOLE, console);
    consoleView.attachToProcess(processHandler);
    processHandler.startNotify();
    ExecutionManager.getInstance(project).getContentManager().showRunContent(defaultExecutor, descriptor);
    return console;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) ConsoleViewImpl(com.intellij.execution.impl.ConsoleViewImpl) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) CloseAction(com.intellij.execution.ui.actions.CloseAction) FileEditorManagerListener(com.intellij.openapi.fileEditor.FileEditorManagerListener) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

CloseAction (com.intellij.execution.ui.actions.CloseAction)8 Executor (com.intellij.execution.Executor)5 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)4 ContextHelpAction (com.intellij.ide.actions.ContextHelpAction)4 DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)3 ConsoleView (com.intellij.execution.ui.ConsoleView)3 TextConsoleBuilder (com.intellij.execution.filters.TextConsoleBuilder)2 ConsoleViewImpl (com.intellij.execution.impl.ConsoleViewImpl)2 NotNull (org.jetbrains.annotations.NotNull)2 DefaultDebugExecutor (com.intellij.execution.executors.DefaultDebugExecutor)1 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)1 FileEditorManagerListener (com.intellij.openapi.fileEditor.FileEditorManagerListener)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 Content (com.intellij.ui.content.Content)1 XDebugTabLayouter (com.intellij.xdebugger.ui.XDebugTabLayouter)1 Nullable (org.jetbrains.annotations.Nullable)1