01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: * See the GNU Lesser General Public License for more details at gnu.org.
11: */
12:
13: package com.eviware.soapui.model.tree.nodes.support;
14:
15: import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;
16: import com.eviware.soapui.model.settings.Settings;
17: import com.eviware.soapui.model.support.TestSuiteListenerAdapter;
18: import com.eviware.soapui.model.testsuite.TestCase;
19: import com.eviware.soapui.model.testsuite.TestStep;
20: import com.eviware.soapui.model.testsuite.TestSuiteListener;
21: import com.eviware.soapui.support.UISupport;
22:
23: /**
24: * ModelItem for TestSteps node
25: *
26: * @author ole.matzura
27: */
28:
29: public class WsdlTestStepsModelItem extends EmptyModelItem {
30: private TestCase testCase;
31: private TestSuiteListener listener = new InternalTestSuiteListener();
32:
33: public WsdlTestStepsModelItem(TestCase testCase) {
34: super (createLabel(testCase), UISupport
35: .createImageIcon("/teststeps.gif"));
36: this .testCase = testCase;
37:
38: testCase.getTestSuite().addTestSuiteListener(listener);
39: }
40:
41: private static String createLabel(TestCase testCase) {
42: return "Test Steps (" + testCase.getTestStepCount() + ")";
43: }
44:
45: public Settings getSettings() {
46: return testCase.getSettings();
47: }
48:
49: public WsdlTestCase getTestCase() {
50: return (WsdlTestCase) testCase;
51: }
52:
53: @Override
54: public void release() {
55: super .release();
56: testCase.getTestSuite().removeTestSuiteListener(listener);
57: }
58:
59: public void updateLabel() {
60: setName(createLabel(testCase));
61: }
62:
63: public class InternalTestSuiteListener extends
64: TestSuiteListenerAdapter implements TestSuiteListener {
65: @Override
66: public void testStepAdded(TestStep testStep, int index) {
67: updateLabel();
68: }
69:
70: @Override
71: public void testStepRemoved(TestStep testStep, int index) {
72: updateLabel();
73: }
74: }
75:
76: }
|