View Javadoc

1   /*
2    *  soapUI, copyright (C) 2006 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of the GNU Lesser General Public License as published by the Free Software Foundation; 
6    *  either version 2.1 of the License, or (at your option) any later version.
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.wsdl.actions.iface;
14  
15  import java.awt.event.ActionEvent;
16  
17  import javax.swing.AbstractAction;
18  import javax.swing.Action;
19  
20  import com.eviware.soapui.model.ModelItem;
21  import com.eviware.soapui.support.UISupport;
22  
23  public abstract class AbstractSwingAction<T extends ModelItem> extends AbstractAction
24  {
25  	private T modelItem;
26  	private final String name;
27  	
28  	public AbstractSwingAction( String name, String description )
29  	{
30  		super( name );
31  		this.name= name;
32  		this.modelItem = null;
33  		
34  		putValue( Action.SHORT_DESCRIPTION, description );
35  	}
36  	
37  	public AbstractSwingAction( String name, String description, T modelItem )
38  	{
39  		super( name );
40  		this.name= name;
41  		this.modelItem = modelItem;
42  		
43  		putValue( Action.SHORT_DESCRIPTION, description );
44  	}
45  
46  	public AbstractSwingAction( String name, String description, String iconUrl )
47  	{
48  		super( name );
49  		this.name= name;
50  		this.modelItem = null;
51  		
52  		putValue( Action.SHORT_DESCRIPTION, description );
53  		putValue( Action.SMALL_ICON, UISupport.createImageIcon( iconUrl ));
54  	}
55  	
56  	public AbstractSwingAction( String name, String description, String iconUrl, T modelItem )
57  	{
58  		super( name );
59  		this.name= name;
60  		this.modelItem = modelItem;
61  		
62  		putValue( Action.SHORT_DESCRIPTION, description );
63  		putValue( Action.SMALL_ICON, UISupport.createImageIcon( iconUrl ));
64  	}
65  	
66  	public void actionPerformed( ActionEvent arg0 )
67  	{
68  		actionPerformed( arg0, modelItem );
69  	}
70  	
71  	public String getName()
72  	{
73  		return name;
74  	}
75  
76  	public abstract void actionPerformed( ActionEvent arg0, T modelItem2 );
77  	
78  	public T getModelItem()
79  	{
80  		return modelItem;
81  	}
82  }