01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * 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: /**
24: * Utility class for creating Swing Actions for ModelItems
25: *
26: * @author ole.matzura
27: */
28:
29: public abstract class AbstractSwingAction<T extends ModelItem> extends
30: AbstractAction {
31: private T modelItem;
32: private final String name;
33:
34: public AbstractSwingAction(String name, String description) {
35: super (name);
36: this .name = name;
37: this .modelItem = null;
38:
39: putValue(Action.SHORT_DESCRIPTION, description);
40: }
41:
42: public AbstractSwingAction(String name, String description,
43: T modelItem) {
44: super (name);
45: this .name = name;
46: this .modelItem = modelItem;
47:
48: putValue(Action.SHORT_DESCRIPTION, description);
49: }
50:
51: public AbstractSwingAction(String name, String description,
52: String iconUrl) {
53: super (name);
54: this .name = name;
55: this .modelItem = null;
56:
57: putValue(Action.SHORT_DESCRIPTION, description);
58: putValue(Action.SMALL_ICON, UISupport.createImageIcon(iconUrl));
59: }
60:
61: public AbstractSwingAction(String name, String description,
62: String iconUrl, T modelItem) {
63: super (name);
64: this .name = name;
65: this .modelItem = modelItem;
66:
67: putValue(Action.SHORT_DESCRIPTION, description);
68: putValue(Action.SMALL_ICON, UISupport.createImageIcon(iconUrl));
69: }
70:
71: public void actionPerformed(ActionEvent arg0) {
72: actionPerformed(arg0, modelItem);
73: }
74:
75: public String getName() {
76: return name;
77: }
78:
79: public abstract void actionPerformed(ActionEvent arg0, T modelItem2);
80:
81: public T getModelItem() {
82: return modelItem;
83: }
84: }
|