1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.model.tree.nodes;
14
15 import com.eviware.soapui.model.testsuite.TestCase;
16 import com.eviware.soapui.model.testsuite.TestStep;
17 import com.eviware.soapui.model.testsuite.TestSuite;
18 import com.eviware.soapui.model.testsuite.TestSuiteListener;
19 import com.eviware.soapui.model.tree.AbstractTreeNode;
20 import com.eviware.soapui.model.tree.SoapUITreeNode;
21
22 /***
23 * SoapUITreeNode for TestSuite implementations
24 *
25 * @author Ole.Matzura
26 */
27
28 public class TestSuiteTreeNode extends AbstractTreeNode
29 {
30 private InternalTestSuiteListener internalTestSuiteListener;
31
32 public TestSuiteTreeNode(TestSuite testSuite )
33 {
34 super( testSuite, testSuite.getProject() );
35
36 internalTestSuiteListener = new InternalTestSuiteListener();
37 testSuite.addTestSuiteListener( internalTestSuiteListener );
38 }
39
40 public void release()
41 {
42 ((TestSuite)getModelItem()).removeTestSuiteListener( internalTestSuiteListener );
43 }
44
45 public int getChildCount()
46 {
47 return getTestSuite().getTestCaseCount();
48 }
49
50 public TestSuite getTestSuite()
51 {
52 return (TestSuite) getModelItem();
53 }
54
55 public int getIndexOfChild(Object child)
56 {
57 TestSuite testSuite = getTestSuite();
58 for( int c = 0; c < testSuite.getTestCaseCount(); c++ )
59 {
60 if( testSuite.getTestCaseAt( c ).getTreeNode() == child ) return c;
61 }
62
63 return -1;
64 }
65
66 public SoapUITreeNode getChildNode(int index)
67 {
68 return getTestSuite().getTestCaseAt( index ).getTreeNode();
69 }
70
71 private class InternalTestSuiteListener extends InternalTreeNodeListener implements TestSuiteListener
72 {
73 public InternalTestSuiteListener()
74 {
75 super( getTreeModel() );
76 }
77
78 public void testCaseAdded(TestCase testCase)
79 {
80 notifyNodeInserted( testCase );
81 }
82
83 public void testCaseRemoved(TestCase testCase)
84 {
85 notifyNodeRemoved( testCase );
86 }
87
88 public void testStepAdded(TestStep testStep, int index)
89 {
90 notifyNodeInserted( testStep );
91 }
92
93 public void testStepRemoved(TestStep testStep, int ix)
94 {
95 notifyNodeRemoved( testStep );
96 }
97 }
98 }