48 |
import javax.swing.event.SwingPropertyChangeSupport; |
import javax.swing.event.SwingPropertyChangeSupport; |
49 |
|
|
50 |
/** |
/** |
51 |
* AbstractAction |
* A base class for implementing the {@link Action} interface. |
52 |
|
* |
53 |
* @author Andrew Selkirk |
* @author Andrew Selkirk |
54 |
* @version 1.0 |
* @version 1.0 |
55 |
*/ |
*/ |
59 |
private static final long serialVersionUID = -6803159439231523484L; |
private static final long serialVersionUID = -6803159439231523484L; |
60 |
|
|
61 |
/** |
/** |
62 |
* enabled |
* A flag that indicates whether or not the action is enabled. |
63 |
*/ |
*/ |
64 |
protected boolean enabled = true; |
protected boolean enabled = true; |
65 |
|
|
66 |
/** |
/** |
67 |
* changeSupport |
* Provides support for property change event notification. |
68 |
*/ |
*/ |
69 |
protected SwingPropertyChangeSupport changeSupport = |
protected SwingPropertyChangeSupport changeSupport = |
70 |
new SwingPropertyChangeSupport(this); |
new SwingPropertyChangeSupport(this); |
75 |
private transient HashMap store = new HashMap(); |
private transient HashMap store = new HashMap(); |
76 |
|
|
77 |
/** |
/** |
78 |
* Constructor AbstractAction |
* Creates a new action with an empty string for the name. All other |
79 |
|
* properties are initialised to <code>null</code> |
80 |
*/ |
*/ |
81 |
public AbstractAction() |
public AbstractAction() |
82 |
{ |
{ |
84 |
} |
} |
85 |
|
|
86 |
/** |
/** |
87 |
* Constructor AbstractAction |
* Creates a new action with the specified name. All other properties are |
88 |
|
* initialised to <code>null</code>. |
89 |
* |
* |
90 |
* @param name TODO |
* @param name the name (<code>null</code> permitted). |
91 |
*/ |
*/ |
92 |
public AbstractAction(String name) |
public AbstractAction(String name) |
93 |
{ |
{ |
95 |
} |
} |
96 |
|
|
97 |
/** |
/** |
98 |
* Constructor AbstractAction |
* Creates a new action with the specified name and icon. All other |
99 |
|
* properties are initialised to <code>null</code>. |
100 |
* |
* |
101 |
* @param name TODO |
* @param name the name (<code>null</code> permitted). |
102 |
* @param icon TODO |
* @param icon the icon (<code>null</code> permitted). |
103 |
*/ |
*/ |
104 |
public AbstractAction(String name, Icon icon) |
public AbstractAction(String name, Icon icon) |
105 |
{ |
{ |
148 |
} |
} |
149 |
|
|
150 |
/** |
/** |
151 |
* Returns a value for a given key from the built-in store. |
* Returns the value associated with the specified key. |
152 |
* |
* |
153 |
* @param key the key to get the value for |
* @param key the key (not <code>null</code>). |
154 |
* |
* |
155 |
* @return Object |
* @return The value associated with the specified key, or |
156 |
|
* <code>null</code> if the key is not found. |
157 |
*/ |
*/ |
158 |
public Object getValue(String key) |
public Object getValue(String key) |
159 |
{ |
{ |
161 |
} |
} |
162 |
|
|
163 |
/** |
/** |
164 |
* Puts a key/value pair into the built-in store. |
* Sets the value associated with the specified key and sends a |
165 |
* |
* {@link java.beans.PropertyChangeEvent} to all registered listeners. |
166 |
* @param key the key |
* The standard keys are: {@link #NAME}, {@link #SHORT_DESCRIPTION}, |
167 |
* @param value the value |
* {@link #LONG_DESCRIPTION}, {@link #SMALL_ICON}, |
168 |
|
* {@link #ACTION_COMMAND_KEY}, {@link #ACCELERATOR_KEY} and |
169 |
|
* {@link #MNEMONIC_KEY}. Any existing value associated with the key will be |
170 |
|
* overwritten. |
171 |
|
* |
172 |
|
* @param key the key (not <code>null</code>). |
173 |
|
* @param value the value (<code>null</code> permitted). |
174 |
*/ |
*/ |
175 |
public void putValue(String key, Object value) |
public void putValue(String key, Object value) |
176 |
{ |
{ |
183 |
} |
} |
184 |
|
|
185 |
/** |
/** |
186 |
* isEnabled |
* Returns the flag that indicates whether or not the action is enabled. |
187 |
* |
* |
188 |
* @return boolean |
* @return The flag. |
189 |
*/ |
*/ |
190 |
public boolean isEnabled() |
public boolean isEnabled() |
191 |
{ |
{ |
193 |
} |
} |
194 |
|
|
195 |
/** |
/** |
196 |
* setEnabled |
* Sets the flag that indicates whether or not the action is enabled and, if |
197 |
|
* the value of the flag changed from the previous setting, sends a |
198 |
|
* {@link java.beans.PropertyChangeEvent} to all registered listeners. |
199 |
* |
* |
200 |
* @param enabled TODO |
* @param enabled the new flag value. |
201 |
*/ |
*/ |
202 |
public void setEnabled(boolean enabled) |
public void setEnabled(boolean enabled) |
203 |
{ |
{ |