mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
UX-389 New icon for "pause output" action - moved pause output to the context menu
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
package com.intellij.execution.configurations;
|
||||
|
||||
import com.intellij.execution.*;
|
||||
import com.intellij.execution.executors.DefaultRunExecutor;
|
||||
import com.intellij.execution.filters.Filter;
|
||||
import com.intellij.execution.filters.TextConsoleBuilder;
|
||||
import com.intellij.execution.filters.TextConsoleBuilderFactory;
|
||||
@@ -10,13 +9,7 @@ import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.execution.ui.ConsoleView;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -96,10 +89,7 @@ public abstract class CommandLineState implements RunProfileState {
|
||||
|
||||
@NotNull
|
||||
protected AnAction[] createActions(final ConsoleView console, final ProcessHandler processHandler, Executor executor) {
|
||||
if (console == null || !console.canPause() || (executor != null && !DefaultRunExecutor.EXECUTOR_ID.equals(executor.getId()))) {
|
||||
return AnAction.EMPTY_ARRAY;
|
||||
}
|
||||
return new AnAction[]{new PauseOutputAction(console, processHandler)};
|
||||
return AnAction.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
public TextConsoleBuilder getConsoleBuilder() {
|
||||
@@ -109,49 +99,4 @@ public abstract class CommandLineState implements RunProfileState {
|
||||
public void setConsoleBuilder(final TextConsoleBuilder consoleBuilder) {
|
||||
myConsoleBuilder = consoleBuilder;
|
||||
}
|
||||
|
||||
protected static class PauseOutputAction extends ToggleAction implements DumbAware{
|
||||
private final ConsoleView myConsole;
|
||||
private final ProcessHandler myProcessHandler;
|
||||
|
||||
public PauseOutputAction(final ConsoleView console, final ProcessHandler processHandler) {
|
||||
super(ExecutionBundle.message("run.configuration.pause.output.action.name"), null, AllIcons.Actions.Pause);
|
||||
myConsole = console;
|
||||
myProcessHandler = processHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelected(@NotNull final AnActionEvent event) {
|
||||
return myConsole.isOutputPaused();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(@NotNull final AnActionEvent event, final boolean flag) {
|
||||
myConsole.setOutputPaused(flag);
|
||||
ApplicationManager.getApplication().invokeLater(() -> update(event));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull final AnActionEvent event) {
|
||||
super.update(event);
|
||||
final Presentation presentation = event.getPresentation();
|
||||
final boolean isRunning = myProcessHandler != null && !myProcessHandler.isProcessTerminated();
|
||||
if (isRunning) {
|
||||
presentation.setEnabled(true);
|
||||
}
|
||||
else {
|
||||
if (!myConsole.canPause()) {
|
||||
presentation.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
if (!myConsole.hasDeferredOutput()) {
|
||||
presentation.setEnabled(false);
|
||||
}
|
||||
else {
|
||||
presentation.setEnabled(true);
|
||||
myConsole.performWhenNoDeferredOutput(() -> update(event));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution.actions;
|
||||
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.ui.ConsoleView;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.LangDataKeys;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PauseOutputAction extends ToggleAction implements DumbAware {
|
||||
public PauseOutputAction() {
|
||||
super(ExecutionBundle.message("run.configuration.pause.output.action.name"), null, AllIcons.Actions.Pause);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static ConsoleView getConsoleView(AnActionEvent event) {
|
||||
return event.getData(LangDataKeys.CONSOLE_VIEW);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelected(@NotNull AnActionEvent event) {
|
||||
ConsoleView consoleView = getConsoleView(event);
|
||||
return consoleView != null && consoleView.isOutputPaused();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(@NotNull AnActionEvent event, boolean flag) {
|
||||
ConsoleView consoleView = getConsoleView(event);
|
||||
if (consoleView != null) {
|
||||
consoleView.setOutputPaused(flag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent event) {
|
||||
super.update(event);
|
||||
final Presentation presentation = event.getPresentation();
|
||||
RunContentDescriptor descriptor = StopAction.getRecentlyStartedContentDescriptor(event.getDataContext());
|
||||
ProcessHandler handler = descriptor != null ? descriptor.getProcessHandler() : null;
|
||||
if (handler != null && !handler.isProcessTerminated()) {
|
||||
presentation.setEnabled(true);
|
||||
}
|
||||
else {
|
||||
ConsoleView consoleView = getConsoleView(event);
|
||||
if (consoleView == null || !consoleView.canPause()) {
|
||||
presentation.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
if (!consoleView.hasDeferredOutput()) {
|
||||
presentation.setEnabled(false);
|
||||
}
|
||||
else {
|
||||
presentation.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -640,6 +640,7 @@
|
||||
<reference ref="CompareClipboardWithSelection"/>
|
||||
<reference ref="$SearchWeb"/>
|
||||
<action id="CopyUrl" class="com.intellij.ide.actions.CopyUrlAction"/>
|
||||
<action id="PauseOutput" class="com.intellij.execution.actions.PauseOutputAction"/>
|
||||
</group>
|
||||
|
||||
<group id="EditorTabPopupMenu">
|
||||
|
||||
Reference in New Issue
Block a user