1 | public class CopyAction extends AbstractColumbaAction implements↵ | | 1 | public class PasteAction extends AbstractColumbaAction implements↵
|
2 | PropertyChangeListener {↵ | | 2 | PropertyChangeListener {↵
|
|
3 | private JComponent focusOwner = null;↵ | | 3 | private JComponent focusOwner = null;↵
|
|
4 | public CopyAction(IFrameMediator controller) {↵ | | 4 | public PasteAction(IFrameMediator controller) {↵
|
5 | super(controller, GlobalResourceLoader.getString(null, null,↵ | | 5 | super(controller, GlobalResourceLoader.getString(null, null,↵
|
6 | "menu_edit_copy"));↵ | | 6 | "menu_edit_paste"));↵
|
|
7 | // tooltip text↵ | | 7 | // tooltip text↵
|
8 | putValue(SHORT_DESCRIPTION, GlobalResourceLoader.getString(null, null,↵ | | 8 | putValue(SHORT_DESCRIPTION, GlobalResourceLoader.getString(null, null,↵
|
9 | "menu_edit_copy_tooltip").replaceAll("&", ""));↵ | | 9 | "menu_edit_paste_tooltip").replaceAll("&", ""));↵
|
|
10 | // small icon for menu↵ | | 10 | // small icon for menu↵
|
11 | putValue(SMALL_ICON, ImageLoader.getSmallIcon(IconKeys.EDIT_COPY));↵ | | 11 | putValue(SMALL_ICON, ImageLoader.getSmallIcon(IconKeys.EDIT_PASTE));↵
|
|
12 | // large icon for toolbar↵ | | 12 | // large icon for toolbar↵
|
13 | putValue(LARGE_ICON, ImageLoader.getIcon(IconKeys.EDIT_COPY));↵ | | 13 | putValue(LARGE_ICON, ImageLoader.getIcon(IconKeys.EDIT_PASTE));↵
|
|
14 | // short cut key↵ | | 14 | // shortcut key↵
|
15 | putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_C,↵ | | 15 | putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_V,↵
|
16 | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));↵ | | 16 | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));↵
|
|
17 | // disable toolbar text↵ | | 17 | // disable toolbar text↵
|
18 | setShowToolBarText(false);↵ | | 18 | setShowToolBarText(false);↵
|
|
19 | setEnabled(true);↵ | | 19 | setEnabled(true);↵
|
|
20 | putValue(Action.ACTION_COMMAND_KEY, (String) TransferHandler↵ | | 20 | putValue(Action.ACTION_COMMAND_KEY, (String) TransferHandler↵
|
21 | .getCopyAction().getValue(Action.NAME));↵ | | 21 | .getPasteAction().getValue(Action.NAME));↵
|
|
22 | KeyboardFocusManager manager = KeyboardFocusManager↵ | | 22 | KeyboardFocusManager manager = KeyboardFocusManager↵
|
23 | .getCurrentKeyboardFocusManager();↵ | | 23 | .getCurrentKeyboardFocusManager();↵
|
24 | manager.addPropertyChangeListener("permanentFocusOwner", this);↵ | | 24 | manager.addPropertyChangeListener("permanentFocusOwner", this);↵
|
|
25 | }↵ | | 25 | }↵
|
|
26 | public void propertyChange(PropertyChangeEvent e) {↵ | | 26 | public void propertyChange(PropertyChangeEvent e) {↵
|
27 | Object o = e.getNewValue();↵ | | 27 | Object o = e.getNewValue();↵
|
28 | if (o instanceof JComponent) {↵ | | 28 | if (o instanceof JComponent)↵
|
29 | focusOwner = (JComponent) o;↵ | | 29 | focusOwner = (JComponent) o;↵
|
30 | ↵ | | 30 | ↵
|
31 | setEnabled(isEnabled());↵ | | |
|
32 | }↵ | | |
|
33 | else↵ | | 31 | else↵
|
34 | focusOwner = null;↵ | | 32 | focusOwner = null;↵
|
|
35 | }↵ | | 33 | }↵
|
|
36 | /**↵ | | 34 | /**↵
|
37 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)↵ | | 35 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)↵
|
38 | */↵ | | 36 | */↵
|
39 | public void actionPerformed(ActionEvent e) {↵ | | 37 | public void actionPerformed(ActionEvent e) {↵
|
|
40 | if (focusOwner == null)↵ | | 38 | if (focusOwner == null)↵
|
41 | return;↵ | | 39 | return;↵
|
|
42 | String action = (String) e.getActionCommand();↵ | | 40 | String action = (String) e.getActionCommand();↵
|
43 | Action a = focusOwner.getActionMap().get(action);↵ | | 41 | Action a = focusOwner.getActionMap().get(action);↵
|
44 | if (a != null)↵ | | 42 | if (a != null)↵
|
45 | a.actionPerformed(new ActionEvent(focusOwner,↵ | | 43 | a.actionPerformed(new ActionEvent(focusOwner,↵
|
46 | ActionEvent.ACTION_PERFORMED, null));↵ | | 44 | ActionEvent.ACTION_PERFORMED, null));↵
|
|
47 | }↵ | | 45 | }↵
|
|
48 | /**↵ | | 46 | /**↵
|
49 | * @see org.columba.core.gui.action.AbstractColumbaAction#isSingleton()↵ | | 47 | * @see org.columba.core.gui.action.AbstractColumbaAction#isSingleton()↵
|
50 | */↵ | | 48 | */↵
|
51 | public boolean isSingleton() {↵ | | 49 | public boolean isSingleton() {↵
|
52 | return true | | 50 | return true
|