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.util;
    14
    15  import java.util.HashMap;
    16  import java.util.Map;
    17
    18  import com.eviware.soapui.impl.WorkspaceImpl;
    19  import com.eviware.soapui.impl.WorkspaceImplPanelBuilder;
    20  import com.eviware.soapui.impl.wsdl.WsdlInterface;
    21  import com.eviware.soapui.impl.wsdl.WsdlOperation;
    22  import com.eviware.soapui.impl.wsdl.WsdlProject;
    23  import com.eviware.soapui.impl.wsdl.WsdlRequest;
    24  import com.eviware.soapui.impl.wsdl.WsdlTestSuite;
    25  import com.eviware.soapui.impl.wsdl.loadtest.WsdlLoadTest;
    26  import com.eviware.soapui.impl.wsdl.mock.WsdlMockOperation;
    27  import com.eviware.soapui.impl.wsdl.mock.WsdlMockResponse;
    28  import com.eviware.soapui.impl.wsdl.mock.WsdlMockService;
    29  import com.eviware.soapui.impl.wsdl.panels.iface.WsdlInterfacePanelBuilder;
    30  import com.eviware.soapui.impl.wsdl.panels.loadtest.WsdlLoadTestPanelBuilder;
    31  import com.eviware.soapui.impl.wsdl.panels.mock.WsdlMockServicePanelBuilder;
    32  import com.eviware.soapui.impl.wsdl.panels.mockoperation.WsdlMockOperationPanelBuilder;
    33  import com.eviware.soapui.impl.wsdl.panels.mockoperation.WsdlMockResponsePanelBuilder;
    34  import com.eviware.soapui.impl.wsdl.panels.operation.WsdlOperationPanelBuilder;
    35  import com.eviware.soapui.impl.wsdl.panels.project.WsdlProjectPanelBuilder;
    36  import com.eviware.soapui.impl.wsdl.panels.request.WsdlRequestPanelBuilder;
    37  import com.eviware.soapui.impl.wsdl.panels.testcase.WsdlTestCasePanelBuilder;
    38  import com.eviware.soapui.impl.wsdl.panels.teststeps.DelayTestStepPanelBuilder;
    39  import com.eviware.soapui.impl.wsdl.panels.teststeps.GotoStepPanelBuilder;
    40  import com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepPanelBuilder;
    41  import com.eviware.soapui.impl.wsdl.panels.teststeps.PropertiesStepPanelBuilder;
    42  import com.eviware.soapui.impl.wsdl.panels.teststeps.TransferResponseValuesTestStepPanelBuilder;
    43  import com.eviware.soapui.impl.wsdl.panels.teststeps.WsdlTestRequestPanelBuilder;
    44  import com.eviware.soapui.impl.wsdl.panels.testsuite.WsdlTestSuitePanelBuilder;
    45  import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;
    46  import com.eviware.soapui.impl.wsdl.teststeps.TransferResponseValuesTestStep;
    47  import com.eviware.soapui.impl.wsdl.teststeps.WsdlDelayTestStep;
    48  import com.eviware.soapui.impl.wsdl.teststeps.WsdlGotoTestStep;
    49  import com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep;
    50  import com.eviware.soapui.impl.wsdl.teststeps.WsdlPropertiesTestStep;
    51  import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep;
    52  import com.eviware.soapui.model.ModelItem;
    53  import com.eviware.soapui.model.PanelBuilder;
    54
    55  /***
    56   * Registry of PanelBuilders
    57   *
    58   * @author ole.matzura
    59   */
    60
    61  public class PanelBuilderRegistry
    62  {
    63  	private static Map<Class<? extends ModelItem>, PanelBuilder<? extends ModelItem> > builders =
    64  		new HashMap<Class<? extends ModelItem>,PanelBuilder<? extends ModelItem> >();
    65
    66  	@SuppressWarnings("unchecked")
    67  	public static <T extends ModelItem> PanelBuilder<T> getPanelBuilder( T modelItem )
    68  	{
    69  		return ( PanelBuilder<T> ) builders.get( modelItem.getClass() );
    70  	}
    71
    72  	public static <T extends ModelItem> void register( Class<T> modelItemClass,
    73  				PanelBuilder<T> panelBuilder )
    74  	{
    75  		builders.put( modelItemClass, panelBuilder );
    76  	}
    77
    78  	static
    79  	{
    80  		register( WorkspaceImpl.class, new WorkspaceImplPanelBuilder() );
    81  		register( WsdlProject.class, new WsdlProjectPanelBuilder() );
    82  		register( WsdlInterface.class, new WsdlInterfacePanelBuilder() );
    83  		register( WsdlOperation.class, new WsdlOperationPanelBuilder() );
    84  		register( WsdlRequest.class, new WsdlRequestPanelBuilder() );
    85  		register( WsdlTestSuite.class, new WsdlTestSuitePanelBuilder() );
    86  		register( WsdlTestCase.class, new WsdlTestCasePanelBuilder() );
    87  		register( WsdlLoadTest.class, new WsdlLoadTestPanelBuilder() );
    88  		register( WsdlMockService.class, new WsdlMockServicePanelBuilder() );
    89  		register( WsdlMockOperation.class, new WsdlMockOperationPanelBuilder() );
    90  		register( WsdlMockResponse.class, new WsdlMockResponsePanelBuilder() );
    91  		register( WsdlGotoTestStep.class, new GotoStepPanelBuilder() );
    92  		register( WsdlDelayTestStep.class, new DelayTestStepPanelBuilder() );
    93  		register( WsdlTestRequestStep.class, new WsdlTestRequestPanelBuilder() );
    94  		register( WsdlPropertiesTestStep.class, new PropertiesStepPanelBuilder() );
    95  		register( WsdlGroovyScriptTestStep.class, new GroovyScriptStepPanelBuilder() );
    96  		register( TransferResponseValuesTestStep.class, new TransferResponseValuesTestStepPanelBuilder() );
    97  	}
    98  }