View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2008 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.impl;
14  
15  import java.awt.Component;
16  
17  import com.eviware.soapui.model.ModelItem;
18  import com.eviware.soapui.model.PanelBuilder;
19  import com.eviware.soapui.model.tree.nodes.support.EmptyModelItem;
20  import com.eviware.soapui.support.components.JPropertiesTable;
21  import com.eviware.soapui.ui.desktop.DesktopPanel;
22  
23  /***
24   * Empty PanelBuilder implementation for extension.
25   * 
26   * @author Ole.Matzura
27   */
28  
29  public class EmptyPanelBuilder<T extends ModelItem> implements PanelBuilder<T>
30  {
31  	private static final EmptyPanelBuilder<?> instance = new EmptyPanelBuilder<EmptyModelItem>();
32  	
33  	public static EmptyPanelBuilder<?> get()
34  	{
35  		return instance;
36  	}
37  	
38  	public Component buildOverviewPanel(T modelItem)
39     {
40  		String caption = "Properties";
41  		if( modelItem.getClass().getSimpleName().startsWith( "Wsdl" ))
42  		{
43  			caption = modelItem.getClass().getSimpleName().substring( 4 );
44  			
45  			if( caption.endsWith( "TestStep" ))
46  				caption = caption.substring( 0, caption.length()-8 );
47  			
48  			caption += " Properties";
49  		}
50  			
51     	return buildDefaultProperties( modelItem, caption );
52     }
53  
54  	protected JPropertiesTable<T> buildDefaultProperties( T modelItem, String caption )
55  	{
56  		JPropertiesTable<T> table = new JPropertiesTable<T>( caption, modelItem );
57  
58     	table.addProperty( "Name", "name", true );
59     	table.addProperty( "Description", "description", true );
60     	
61     	table.setPropertyObject( modelItem );
62     	
63     	return table;
64  	}
65  
66     public boolean hasOverviewPanel()
67     {
68        return true;
69     }
70  
71     public boolean hasDesktopPanel()
72     {
73        return false;
74     }
75  
76     public DesktopPanel buildDesktopPanel( T modelItem )
77     {
78        return null;
79     }
80  }