1
2
3
4
5
6
7
8
9
10
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 }