From d9a97693b778e3b9c674439795fc8fa958ea9923 Mon Sep 17 00:00:00 2001 From: Sergey Simonchik Date: Wed, 5 Jun 2013 16:07:00 +0400 Subject: [PATCH] custom renderer for SMRootTestProxy --- .../runner/ui/SMRootTestProxyFormatter.java | 11 +++++++++ .../sm/runner/ui/TestTreeRenderer.java | 24 +++++++++++++++---- 2 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMRootTestProxyFormatter.java diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMRootTestProxyFormatter.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMRootTestProxyFormatter.java new file mode 100644 index 000000000000..cb9b80f06bd8 --- /dev/null +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMRootTestProxyFormatter.java @@ -0,0 +1,11 @@ +package com.intellij.execution.testframework.sm.runner.ui; + +import com.intellij.execution.testframework.sm.runner.SMTestProxy; +import org.jetbrains.annotations.NotNull; + +/** + * @author Sergey Simonchik + */ +public interface SMRootTestProxyFormatter { + void format(@NotNull SMTestProxy.SMRootTestProxy testProxy, @NotNull TestTreeRenderer renderer); +} diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/TestTreeRenderer.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/TestTreeRenderer.java index 979fe0921e0f..29d183fb7c89 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/TestTreeRenderer.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/TestTreeRenderer.java @@ -21,6 +21,7 @@ import com.intellij.execution.testframework.sm.runner.SMTestProxy; import com.intellij.ui.ColoredTreeCellRenderer; import com.intellij.ui.SimpleTextAttributes; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; @@ -29,9 +30,11 @@ import javax.swing.tree.DefaultMutableTreeNode; * @author: Roman Chernyatchik */ public class TestTreeRenderer extends ColoredTreeCellRenderer { - private final TestConsoleProperties myConsoleProperties; @NonNls private static final String SPACE_STRING = " "; + private final TestConsoleProperties myConsoleProperties; + private SMRootTestProxyFormatter myAdditionalRootFormatter; + public TestTreeRenderer(final TestConsoleProperties consoleProperties) { myConsoleProperties = consoleProperties; } @@ -50,11 +53,14 @@ public class TestTreeRenderer extends ColoredTreeCellRenderer { final SMTestProxy testProxy = desc.getElement(); if (testProxy instanceof SMTestProxy.SMRootTestProxy) { - //Root node - if (testProxy.isLeaf()) { - TestsPresentationUtil.formatRootNodeWithoutChildren((SMTestProxy.SMRootTestProxy)testProxy, this); + SMTestProxy.SMRootTestProxy rootTestProxy = (SMTestProxy.SMRootTestProxy) testProxy; + if (rootTestProxy.isLeaf()) { + TestsPresentationUtil.formatRootNodeWithoutChildren(rootTestProxy, this); } else { - TestsPresentationUtil.formatRootNodeWithChildren((SMTestProxy.SMRootTestProxy)testProxy, this); + TestsPresentationUtil.formatRootNodeWithChildren(rootTestProxy, this); + } + if (myAdditionalRootFormatter != null) { + myAdditionalRootFormatter.format(rootTestProxy, this); } } else { TestsPresentationUtil.formatTestProxy(testProxy, this); @@ -72,4 +78,12 @@ public class TestTreeRenderer extends ColoredTreeCellRenderer { public TestConsoleProperties getConsoleProperties() { return myConsoleProperties; } + + public void setAdditionalRootFormatter(@NotNull SMRootTestProxyFormatter formatter) { + myAdditionalRootFormatter = formatter; + } + + public void removeAdditionalRootFormatter() { + myAdditionalRootFormatter = null; + } }