%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
com.aimedia.ui.SaveAction |
|
|
1 | /* |
|
2 | ******************************************************************************* |
|
3 | * Copyright (c) 2005 Chris Rose and AIMedia |
|
4 | * All rights reserved. SaveAction and the accompanying materials |
|
5 | * are made available under the terms of the Common Public License v1.0 |
|
6 | * which accompanies this distribution, and is available at |
|
7 | * http://www.eclipse.org/legal/cpl-v10.html |
|
8 | * |
|
9 | * Contributors: |
|
10 | * Chris Rose |
|
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 | 0 | 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 | 0 | super("Save"); |
38 | 0 | putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_S)); |
39 | 0 | if (null == target) { |
40 | 0 | throw new IllegalArgumentException("Non-null targets not allowed"); |
41 | } |
|
42 | 0 | this.target = target; |
43 | 0 | } |
44 | ||
45 | /* (non-Javadoc) |
|
46 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) |
|
47 | */ |
|
48 | public void actionPerformed(ActionEvent e) { |
|
49 | 0 | if (logger.isDebugEnabled()) { |
50 | 0 | logger.debug("actionPerformed() - doSave invoked on " + target.getClass().getName()); |
51 | } |
|
52 | ||
53 | 0 | target.doSave(); |
54 | 0 | } |
55 | ||
56 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |