1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.model.tree.nodes.support;
14
15 import com.eviware.soapui.model.settings.Settings;
16 import com.eviware.soapui.model.support.TestSuiteListenerAdapter;
17 import com.eviware.soapui.model.testsuite.LoadTest;
18 import com.eviware.soapui.model.testsuite.TestCase;
19 import com.eviware.soapui.model.testsuite.TestSuiteListener;
20 import com.eviware.soapui.support.UISupport;
21
22 /***
23 * ModelItem for LoadTests node
24 *
25 * @author ole.matzura
26 */
27
28 public class WsdlLoadTestsModelItem extends EmptyModelItem
29 {
30 private TestCase testCase;
31 private TestSuiteListener listener = new InternalTestSuiteListener();
32
33 public WsdlLoadTestsModelItem( TestCase testCase )
34 {
35 super( createLabel( testCase ), UISupport.createImageIcon("/loadtests.gif") );
36 this.testCase = testCase;
37
38 testCase.getTestSuite().addTestSuiteListener( listener );
39 }
40
41 private static String createLabel( TestCase testCase )
42 {
43 return "Load Tests (" + testCase.getLoadTestCount() + ")";
44 }
45
46 public Settings getSettings()
47 {
48 return testCase.getSettings();
49 }
50
51 @Override
52 public void release()
53 {
54 super.release();
55 testCase.getTestSuite().removeTestSuiteListener( listener );
56 }
57
58 public void updateLabel()
59 {
60 setName( createLabel( testCase ) );
61 }
62
63 public class InternalTestSuiteListener extends TestSuiteListenerAdapter implements TestSuiteListener
64 {
65 @Override
66 public void loadTestAdded( LoadTest loadTest )
67 {
68 updateLabel();
69 }
70
71 @Override
72 public void loadTestRemoved( LoadTest loadTest )
73 {
74 updateLabel();
75 }
76 }
77 }