View Javadoc

    1   /*
    2    *  soapUI, copyright (C) 2004-2007 eviware.com
    3    *
    4    *  soapUI is free software; you can redistribute it and/or modify it under the
    5    *  terms of version 2.1 of the GNU Lesser General Public License as published by
    6    *  the Free Software Foundation.
    7    *
    8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
    9    *  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.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  }