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 java.beans.PropertyChangeListener;
16  import java.beans.PropertyChangeSupport;
17  import java.util.Collections;
18  import java.util.List;
19  
20  import javax.swing.ImageIcon;
21  
22  import com.eviware.soapui.SoapUI;
23  import com.eviware.soapui.model.ModelItem;
24  import com.eviware.soapui.model.settings.Settings;
25  
26  /***
27   * Empty ModelItem used by intermediary TreeNodes
28   * 
29   * @author ole.matzura
30   */
31  
32  public class EmptyModelItem implements ModelItem
33  {
34  	private String name;
35  	private ImageIcon icon;
36  	protected PropertyChangeSupport propertyChangeSupport;
37  	
38  	public EmptyModelItem(String name, ImageIcon icon)
39  	{
40  		this.name = name;
41  		this.icon = icon;
42  	}
43  
44  	public void setName( String name )
45  	{
46  		String oldName = this.name;
47  		this.name = name;
48  		
49  		if( propertyChangeSupport != null )
50  		{
51  			propertyChangeSupport.firePropertyChange( ModelItem.NAME_PROPERTY, oldName, name );
52  		}
53  	}
54  
55  	public String getName()
56  	{
57  		return name;
58  	}
59  
60  	public ImageIcon getIcon()
61  	{
62  		return icon;
63  	}
64  
65  	public String getDescription()
66  	{
67  		return name;
68  	}
69  
70  	public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
71  	{
72  		if( propertyChangeSupport == null )
73  			propertyChangeSupport = new PropertyChangeSupport( this );
74  		
75  		propertyChangeSupport.addPropertyChangeListener( propertyName, listener );
76  	}
77  
78  	public void addPropertyChangeListener(PropertyChangeListener listener)
79  	{
80  		if( propertyChangeSupport == null )
81  			propertyChangeSupport = new PropertyChangeSupport( this );
82  		
83  		propertyChangeSupport.addPropertyChangeListener( listener );
84  	}
85  
86  	public void removePropertyChangeListener(PropertyChangeListener listener)
87  	{
88  		if( propertyChangeSupport != null )
89  			propertyChangeSupport.removePropertyChangeListener( listener );
90  	}
91  
92  	public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
93  	{
94  		if( propertyChangeSupport != null )
95  			propertyChangeSupport.removePropertyChangeListener( propertyName, listener );
96  	}
97  
98  	public Settings getSettings()
99  	{
100 		return SoapUI.getSettings();
101 	}
102 
103 	public void release()
104 	{
105 	}
106 
107 	public String getId()
108 	{
109 		return String.valueOf( hashCode() );
110 	}
111    
112    @SuppressWarnings("unchecked")
113    public List<? extends ModelItem> getChildren()
114    {
115       return Collections.EMPTY_LIST;
116    }
117 
118 	public ModelItem getParent()
119 	{
120 		return null;
121 	}
122 }