1
2
3
4
5
6
7
8
9
10
11
12 package com.aimedia.ui;
13
14 import java.awt.event.*;
15
16 import javax.swing.AbstractAction;
17
18 import org.apache.log4j.Logger;
19
20 /***
21 * Generic UI Save action
22 * @author Chris Rose
23 */
24 public class SaveAction extends AbstractAction {
25 /***
26 * Logger for this class
27 */
28 private static final Logger logger = Logger.getLogger(SaveAction.class);
29
30 private ISaveable target;
31
32 /***
33 * Create a new SaveAction with the provided target
34 * @param target the <code>ISaveable</code> that will receive the action
35 */
36 public SaveAction(ISaveable target) {
37 super("Save");
38 putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_S));
39 if (null == target) {
40 throw new IllegalArgumentException("Non-null targets not allowed");
41 }
42 this.target = target;
43 }
44
45
46
47
48 public void actionPerformed(ActionEvent e) {
49 if (logger.isDebugEnabled()) {
50 logger.debug("actionPerformed() - doSave invoked on " + target.getClass().getName());
51 }
52
53 target.doSave();
54 }
55
56 }