1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 package org.xmlcv.gui.action;
28
29 import java.awt.event.ActionEvent;
30 import java.awt.event.InputEvent;
31 import java.awt.event.KeyEvent;
32
33 import javax.swing.AbstractAction;
34 import javax.swing.ImageIcon;
35 import javax.swing.KeyStroke;
36
37 import org.xmlcv.gui.Frame;
38 import org.xmlcv.util.Config;
39 import org.xmlcv.util.I18n;
40
41 /***
42 * Listener for « New CV » action
43 *
44 * This class follow the pattern Singleton from GOF. So that only one object is
45 * shared between all the Button/MenuItem.<br>
46 * The <code>actionPerformed()</code> method is the core of the class.<br>
47 * The <code>parent</code> is present to allow further modal dialog creation.
48 *
49 * @version $Revision: 114 $
50 * @author <a href="mailto:drazzib@drazzib.com">Damien Raude-Morvan </a>
51 */
52 public class ActionNewCV extends AbstractAction {
53
54 /*** Parent Frame (for future modal dialog) */
55 private Frame _parentFrame;
56
57 /*** Singleton */
58 static private ActionNewCV _singleInstance = null;
59
60 /***
61 * Create a new Action that could be used in JMenuItem, JButton to asign
62 * text, icon, accesskey. <br>
63 * Don't access directly :)
64 *
65 * @param parent
66 * main window of XMLCV
67 */
68 private ActionNewCV(Frame parent) {
69 this._parentFrame = parent;
70
71 putValue(NAME, I18n.getString("ActionNewCV.NewCV"));
72 putValue(SHORT_DESCRIPTION, I18n.getString("ActionNewCV.NewCVDesc"));
73 putValue(SMALL_ICON, new ImageIcon(getClass().getResource(
74 Config.ICON_FILENEW)));
75 putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_N));
76 putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_N,
77 InputEvent.CTRL_MASK));
78 }
79
80 /***
81 * Get a new instance of the singleton (create it if doesn't exist)
82 *
83 * @param parent
84 * main window of XMLCV
85 * @return singleton instance of Action
86 */
87 public static ActionNewCV instance(Frame parent) {
88 if (null == _singleInstance)
89 _singleInstance = new ActionNewCV(parent);
90 return _singleInstance;
91 }
92
93
94
95
96
97
98 public void actionPerformed(ActionEvent e) {
99 System.out.println(this.getClass().toString());
100
101 this._parentFrame.newCV();
102 }
103
104 }