testng: test view optimization
[fedora-idea.git] / plugins / testng / src / com / theoryinpractice / testng / model / TestTreeBuilder.java
blob531b249228b1160e6e021f8ed2390606afc40af4
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.theoryinpractice.testng.model;
18 import com.intellij.execution.testframework.ui.AbstractTestTreeBuilder;
19 import com.intellij.ide.util.treeView.AbstractTreeStructure;
20 import com.intellij.ide.util.treeView.IndexComparator;
21 import com.intellij.ide.util.treeView.NodeDescriptor;
23 import javax.swing.*;
24 import javax.swing.tree.DefaultMutableTreeNode;
25 import javax.swing.tree.DefaultTreeModel;
27 /**
28 * @author Hani Suleiman Date: Jul 28, 2005 Time: 10:49:36 PM
30 public class TestTreeBuilder extends AbstractTestTreeBuilder
32 public TestTreeBuilder(JTree tree, AbstractTreeStructure structure) {
33 super(tree, new DefaultTreeModel(new DefaultMutableTreeNode(structure.getRootElement())), structure, IndexComparator.INSTANCE);
34 initRootNode();
37 @Override
38 protected boolean isSmartExpand() {
39 return false;
42 @Override
43 protected boolean isAlwaysShowPlus(NodeDescriptor descriptor) {
44 return false;
47 @Override
48 protected boolean isAutoExpandNode(NodeDescriptor descriptor) {
49 return descriptor.getElement() == getTreeStructure().getRootElement();
52 public void addItem(TestProxy parent, TestProxy proxy) {
53 parent.addResult(proxy);
54 DefaultMutableTreeNode parentNode = getNodeForElement(parent);
55 if (parentNode != null)
56 updateSubtree(parentNode);
59 public TestProxy getRoot() {
60 return (TestProxy) getTreeStructure().getRootElement();