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  public class DesktopRegistry
21  {
22  	private static DesktopRegistry instance;
23  	private Map<String,DesktopFactory> factories = new HashMap<String, DesktopFactory>();
24  	
25  	public static DesktopRegistry getInstance()
26  	{
27  		if( instance == null )
28  			instance = new DesktopRegistry();
29  		
30  		return instance;
31  	}
32  	
33  	public void addDesktop( String name, DesktopFactory factory )
34  	{
35  		factories.put( name, factory );
36  	}
37  	
38  	public String [] getNames()
39  	{
40  		return factories.keySet().toArray( new String[factories.size()] );
41  	}
42  
43  	public SoapUIDesktop createDesktop( String desktopType, Workspace workspace )
44  	{
45  		if( factories.containsKey( desktopType ))
46  			return factories.get( desktopType ).createDesktop( workspace );
47  		
48  		return null;
49  	}
50  }