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.ui.desktop;
    14
    15  import java.util.HashMap;
    16  import java.util.Map;
    17
    18  import com.eviware.soapui.model.workspace.Workspace;
    19
    20  /***
    21   * Registry of available desktops
    22   *
    23   * @author ole.matzura
    24   */
    25
    26  public class DesktopRegistry
    27  {
    28  	private static DesktopRegistry instance;
    29  	private Map<String,DesktopFactory> factories = new HashMap<String, DesktopFactory>();
    30
    31  	public static DesktopRegistry getInstance()
    32  	{
    33  		if( instance == null )
    34  			instance = new DesktopRegistry();
    35
    36  		return instance;
    37  	}
    38
    39  	public void addDesktop( String name, DesktopFactory factory )
    40  	{
    41  		factories.put( name, factory );
    42  	}
    43
    44  	public String [] getNames()
    45  	{
    46  		return factories.keySet().toArray( new String[factories.size()] );
    47  	}
    48
    49  	public SoapUIDesktop createDesktop( String desktopType, Workspace workspace )
    50  	{
    51  		if( factories.containsKey( desktopType ))
    52  			return factories.get( desktopType ).createDesktop( workspace );
    53
    54  		return null;
    55  	}
    56  }