mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
[service-view] update test run configuration node label on test finish
GitOrigin-RevId: b9d5890f6b2f92f3ab454c7349027329283afb6e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
94cdfffe14
commit
be38abefd4
@@ -5,23 +5,28 @@ import com.intellij.execution.RunnerAndConfigurationSettings;
|
||||
import com.intellij.execution.dashboard.RunDashboardCustomizer;
|
||||
import com.intellij.execution.dashboard.RunDashboardRunConfigurationNode;
|
||||
import com.intellij.execution.testframework.TestsUIUtil;
|
||||
import com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView;
|
||||
import com.intellij.execution.testframework.sm.runner.ui.SMTestRunnerResultsForm;
|
||||
import com.intellij.execution.testframework.sm.runner.ui.TestTreeRenderer;
|
||||
import com.intellij.execution.testframework.sm.runner.ui.TestsPresentationUtil;
|
||||
import com.intellij.execution.testframework.sm.runner.ui.*;
|
||||
import com.intellij.execution.ui.ExecutionConsole;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.ide.projectView.PresentationData;
|
||||
import com.intellij.ide.util.treeView.AbstractTreeNode;
|
||||
import com.intellij.openapi.progress.util.ColorProgressBar;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.reference.SoftReference;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.ui.content.Content;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class SMTRunnerRunDashboardCustomizer extends RunDashboardCustomizer {
|
||||
private static final SimpleTextAttributes IGNORE_ATTRIBUTES =
|
||||
new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, ColorProgressBar.YELLOW);
|
||||
private static final SimpleTextAttributes ERROR_ATTRIBUTES =
|
||||
new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, ColorProgressBar.RED_TEXT);
|
||||
private static final Key<NodeUpdaterEventsListener> EVENTS_LISTENER_KEY = Key.create("TestResultsEventsListener");
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(@NotNull RunnerAndConfigurationSettings settings, @Nullable RunContentDescriptor descriptor) {
|
||||
@@ -37,6 +42,22 @@ public class SMTRunnerRunDashboardCustomizer extends RunDashboardCustomizer {
|
||||
if (!(executionConsole instanceof SMTRunnerConsoleView)) return false;
|
||||
|
||||
SMTestRunnerResultsForm resultsViewer = ((SMTRunnerConsoleView)executionConsole).getResultsViewer();
|
||||
Content content = node.getContent();
|
||||
if (content != null && node instanceof AbstractTreeNode<?>) {
|
||||
NodeUpdaterEventsListener eventsListener = content.getUserData(EVENTS_LISTENER_KEY);
|
||||
if (eventsListener == null) {
|
||||
eventsListener = new NodeUpdaterEventsListener();
|
||||
resultsViewer.addEventsListener(eventsListener);
|
||||
content.putUserData(EVENTS_LISTENER_KEY, eventsListener);
|
||||
NodeUpdaterEventsListener listener = eventsListener;
|
||||
Disposer.register(resultsViewer, () -> {
|
||||
if (content.getUserData(EVENTS_LISTENER_KEY) == listener) {
|
||||
content.putUserData(EVENTS_LISTENER_KEY, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
eventsListener.setNode((AbstractTreeNode<?>)node);
|
||||
}
|
||||
|
||||
SMTestProxy.SMRootTestProxy rootNode = resultsViewer.getTestsRootNode();
|
||||
TestTreeRenderer renderer = new TestTreeRenderer(resultsViewer.getProperties());
|
||||
@@ -90,4 +111,29 @@ public class SMTRunnerRunDashboardCustomizer extends RunDashboardCustomizer {
|
||||
|
||||
presentation.addText(" of " + total + "]", SimpleTextAttributes.GRAYED_ATTRIBUTES);
|
||||
}
|
||||
|
||||
private static class NodeUpdaterEventsListener extends TestResultsViewer.SMEventsAdapter {
|
||||
private WeakReference<AbstractTreeNode<?>> myNodeReference;
|
||||
|
||||
@Override
|
||||
public void onTestingFinished(@NotNull TestResultsViewer sender) {
|
||||
update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTestNodeAdded(@NotNull TestResultsViewer sender, @NotNull SMTestProxy test) {
|
||||
update();
|
||||
}
|
||||
|
||||
void setNode(AbstractTreeNode<?> node) {
|
||||
myNodeReference = new WeakReference<>(node);
|
||||
}
|
||||
|
||||
private void update() {
|
||||
AbstractTreeNode<?> node = SoftReference.dereference(myNodeReference);
|
||||
if (node != null) {
|
||||
node.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user