mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
RerunFailedTestsAction — prepare to fix IDEA-79203 Re-run keyboard shortcut (Ctrl-F5) doesn't work
This commit is contained in:
@@ -47,7 +47,7 @@ public class RunContentDescriptor implements Disposable {
|
||||
|
||||
private Content myContent;
|
||||
@NotNull
|
||||
private AnAction[] myRestartActions = AnAction.EMPTY_ARRAY;
|
||||
private final AnAction[] myRestartActions;
|
||||
|
||||
@Nullable
|
||||
private final Runnable myActivationCallback;
|
||||
@@ -58,6 +58,16 @@ public class RunContentDescriptor implements Disposable {
|
||||
String displayName,
|
||||
@Nullable Icon icon,
|
||||
@Nullable Runnable activationCallback) {
|
||||
this(executionConsole, processHandler, component, displayName, icon, activationCallback, null);
|
||||
}
|
||||
|
||||
public RunContentDescriptor(@Nullable ExecutionConsole executionConsole,
|
||||
@Nullable ProcessHandler processHandler,
|
||||
@NotNull JComponent component,
|
||||
String displayName,
|
||||
@Nullable Icon icon,
|
||||
@Nullable Runnable activationCallback,
|
||||
@Nullable AnAction[] restartActions) {
|
||||
myExecutionConsole = executionConsole;
|
||||
myProcessHandler = processHandler;
|
||||
myComponent = component;
|
||||
@@ -68,6 +78,8 @@ public class RunContentDescriptor implements Disposable {
|
||||
if (myExecutionConsole != null) {
|
||||
Disposer.register(this, myExecutionConsole);
|
||||
}
|
||||
|
||||
myRestartActions = restartActions == null ? AnAction.EMPTY_ARRAY : restartActions;
|
||||
}
|
||||
|
||||
public RunContentDescriptor(@Nullable ExecutionConsole executionConsole,
|
||||
@@ -75,23 +87,25 @@ public class RunContentDescriptor implements Disposable {
|
||||
@NotNull JComponent component,
|
||||
String displayName,
|
||||
@Nullable Icon icon) {
|
||||
this(executionConsole, processHandler, component, displayName, icon, null);
|
||||
this(executionConsole, processHandler, component, displayName, icon, null, null);
|
||||
}
|
||||
|
||||
public RunContentDescriptor(@Nullable ExecutionConsole executionConsole,
|
||||
@Nullable ProcessHandler processHandler,
|
||||
@NotNull JComponent component,
|
||||
String displayName) {
|
||||
this(executionConsole, processHandler, component, displayName, null);
|
||||
this(executionConsole, processHandler, component, displayName, null, null, null);
|
||||
}
|
||||
|
||||
public RunContentDescriptor(@NotNull RunProfile profile, @NotNull ExecutionResult executionResult, @NotNull RunnerLayoutUi ui) {
|
||||
this(executionResult.getExecutionConsole(), executionResult.getProcessHandler(), ui.getComponent(), profile.getName(),
|
||||
profile.getIcon());
|
||||
this(executionResult.getExecutionConsole(),
|
||||
executionResult.getProcessHandler(),
|
||||
ui.getComponent(),
|
||||
profile.getName(),
|
||||
profile.getIcon(),
|
||||
null,
|
||||
executionResult instanceof DefaultExecutionResult ? ((DefaultExecutionResult)executionResult).getRestartActions() : null);
|
||||
myRunnerLayoutUi = ui;
|
||||
if (executionResult instanceof DefaultExecutionResult) {
|
||||
myRestartActions = ((DefaultExecutionResult)executionResult).getRestartActions();
|
||||
}
|
||||
}
|
||||
|
||||
public Runnable getActivationCallback() {
|
||||
@@ -103,7 +117,7 @@ public class RunContentDescriptor implements Disposable {
|
||||
*/
|
||||
@NotNull
|
||||
public AnAction[] getRestartActions() {
|
||||
return myRestartActions.clone();
|
||||
return myRestartActions.length == 0 ? AnAction.EMPTY_ARRAY : myRestartActions.clone();
|
||||
}
|
||||
|
||||
public ExecutionConsole getExecutionConsole() {
|
||||
|
||||
+4
@@ -137,6 +137,10 @@ public class AbstractRerunFailedTestsAction extends AnAction implements AnAction
|
||||
return;
|
||||
}
|
||||
|
||||
execute(e, environment);
|
||||
}
|
||||
|
||||
void execute(@NotNull AnActionEvent e, @NotNull ExecutionEnvironment environment) {
|
||||
MyRunProfile profile = getRunProfile(environment);
|
||||
if (profile == null) {
|
||||
return;
|
||||
|
||||
+35
-13
@@ -16,40 +16,62 @@
|
||||
package com.intellij.execution.testframework.actions;
|
||||
|
||||
import com.intellij.execution.ExecutionManager;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.execution.ui.layout.ViewContext;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.LangDataKeys;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
class RerunFailedTestsAction extends AnAction {
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
e.getPresentation().setEnabled(getAction(e, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
getAction(e, true);
|
||||
}
|
||||
|
||||
private static boolean getAction(@NotNull AnActionEvent e, boolean execute) {
|
||||
Project project = e.getProject();
|
||||
if (project == null) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
RunContentDescriptor content = ExecutionManager.getInstance(project).getContentManager().getSelectedContent();
|
||||
if (content == null) {
|
||||
return;
|
||||
RunContentDescriptor contentDescriptor = ExecutionManager.getInstance(project).getContentManager().getSelectedContent();
|
||||
if (contentDescriptor == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
JComponent component = content.getComponent();
|
||||
JComponent component = contentDescriptor.getComponent();
|
||||
if (component == null) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
DataContext dataContext = DataManager.getInstance().getDataContext(component);
|
||||
ViewContext viewContext = ViewContext.CONTEXT_KEY.getData(dataContext);
|
||||
if (viewContext != null) {
|
||||
|
||||
ExecutionEnvironment environment = LangDataKeys.EXECUTION_ENVIRONMENT.getData(DataManager.getInstance().getDataContext(component));
|
||||
if (environment == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
AnAction[] actions = contentDescriptor.getRestartActions();
|
||||
if (actions.length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (AnAction action : actions) {
|
||||
if (action instanceof AbstractRerunFailedTestsAction) {
|
||||
if (execute) {
|
||||
((AbstractRerunFailedTestsAction)action).execute(e, environment);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,6 +39,7 @@ import com.intellij.ui.content.ContentManagerAdapter;
|
||||
import com.intellij.ui.content.ContentManagerEvent;
|
||||
import com.intellij.ui.content.tabs.PinToolwindowTabAction;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.xdebugger.XDebugSession;
|
||||
import com.intellij.xdebugger.XDebuggerBundle;
|
||||
import com.intellij.xdebugger.impl.XDebugSessionImpl;
|
||||
@@ -137,8 +138,18 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
|
||||
mySession = session;
|
||||
mySessionData = session.getSessionData();
|
||||
myConsole = session.getConsoleView();
|
||||
|
||||
AnAction[] restartActions;
|
||||
List<AnAction> restartActionsList = session.getRestartActions();
|
||||
if (ContainerUtil.isEmpty(restartActionsList)) {
|
||||
restartActions = AnAction.EMPTY_ARRAY;
|
||||
}
|
||||
else {
|
||||
restartActions = restartActionsList.toArray(new AnAction[restartActionsList.size()]);
|
||||
}
|
||||
|
||||
myRunContentDescriptor = new RunContentDescriptor(myConsole, session.getDebugProcess().getProcessHandler(),
|
||||
myUi.getComponent(), session.getSessionName(), icon, myRebuildWatchesRunnable);
|
||||
myUi.getComponent(), session.getSessionName(), icon, myRebuildWatchesRunnable, restartActions);
|
||||
Disposer.register(myRunContentDescriptor, this);
|
||||
Disposer.register(myProject, myRunContentDescriptor);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user