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;
14  
15  
16  import javax.swing.JPopupMenu;
17  
18  import com.eviware.soapui.model.ModelItem;
19  import com.eviware.soapui.support.action.swing.ActionList;
20  import com.eviware.soapui.support.action.swing.ActionListBuilder;
21  import com.eviware.soapui.support.action.swing.ActionSupport;
22  
23  /***
24   * Base implementation of SoapUITreeNode interface
25   * 
26   * @author Ole.Matzura
27   */
28  
29  public abstract class AbstractTreeNode<T extends ModelItem> implements SoapUITreeNode
30  {
31  	private T modelItem;
32  
33  	public AbstractTreeNode( T modelItem )
34  	{
35  		this.modelItem = modelItem;
36  	}
37  	
38  	public boolean valueChanged(Object newValue)
39  	{
40  		return false;
41  	}
42  
43  	public boolean isLeaf()
44  	{
45  		return getChildCount() == 0;
46  	}
47  
48  	public JPopupMenu getPopup()
49  	{
50  		return ActionSupport.buildPopup( getActions() );
51  	}
52  	
53  	public ActionList getActions()
54  	{
55  		return ActionListBuilder.buildActions( modelItem );
56  	}
57  	
58  	public T getModelItem()
59  	{
60  		return modelItem;
61  	}
62  
63  	public String toString()
64  	{
65  		return modelItem.getName();
66  	}
67  	
68  	public void reorder( boolean notify )
69  	{
70  	}
71  }