custom renderer for SMRootTestProxy

This commit is contained in:
Sergey Simonchik
2013-06-05 16:07:00 +04:00
parent 04f0bf177d
commit d9a97693b7
2 changed files with 30 additions and 5 deletions
@@ -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);
}
@@ -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;
}
}