1 | public class CutAction 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 CutAction(IFrameMediator controller) {↵ | | 4 | public PasteAction(IFrameMediator controller) {↵
|
5 | super(controller, GlobalResourceLoader.getString(null, null,↵ | | 5 | super(controller, GlobalResourceLoader.getString(null, null,↵
|
6 | "menu_edit_cut"));↵ | | 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_cut_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_CUT));↵ | | 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_CUT));↵ | | 13 | putValue(LARGE_ICON, ImageLoader.getIcon(IconKeys.EDIT_PASTE));↵
|
|
14 | // disable toolbar text↵ | | 14 | // ↵
|
15 | setShowToolBarText(false);↵ | | |
|
|
16 | // short cut key↵ | | 15 | shortcut key↵
|
17 | putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_X,↵ | | 16 | putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_V,↵
|
18 | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));↵ | | 17 | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));↵
|
|
| | | 18 | // disable toolbar text↵
|
| | | 19 | setShowToolBarText(false);↵
|
|
19 | setEnabled(true);↵ | | 20 | setEnabled(true);↵
|
|
20 | putValue(Action.ACTION_COMMAND_KEY, (String) TransferHandler↵ | | 21 | putValue(Action.ACTION_COMMAND_KEY, (String) TransferHandler↵
|
21 | .getCutAction().getValue(Action.NAME));↵ | | 22 | .getPasteAction().getValue(Action.NAME));↵
|
|
22 | KeyboardFocusManager manager = KeyboardFocusManager↵ | | 23 | KeyboardFocusManager manager = KeyboardFocusManager↵
|
23 | .getCurrentKeyboardFocusManager();↵ | | 24 | .getCurrentKeyboardFocusManager();↵
|
24 | ↵ | | 25 | ↵
|
25 | manager.addPropertyChangeListener("permanentFocusOwner", this);↵ | | 26 | manager.addPropertyChangeListener("permanentFocusOwner", this);↵
|
26 | }↵ | | 27 | }↵
|
|
27 | public void propertyChange(PropertyChangeEvent e) {↵ | | 28 | public void propertyChange(PropertyChangeEvent e) {↵
|
28 | Object o = e.getNewValue();↵ | | 29 | Object o = e.getNewValue();↵
|
29 | if (o instanceof JComponent)↵ | | 30 | if (o instanceof JComponent)↵
|
30 | focusOwner = (JComponent) o;↵ | | 31 | focusOwner = (JComponent) o;↵
|
31 | else↵ | | 32 | else↵
|
32 | focusOwner = null;↵ | | 33 | focusOwner = null;↵
|
|
33 | }↵ | | 34 | }↵
|
|
34 | /**↵ | | 35 | /**↵
|
35 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)↵ | | 36 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)↵
|
36 | */↵ | | 37 | */↵
|
37 | public void actionPerformed(ActionEvent e) {↵ | | 38 | public void actionPerformed(ActionEvent e) {↵
|
|
38 | if (focusOwner == null)↵ | | 39 | if (focusOwner == null)↵
|
39 | return;↵ | | 40 | return;↵
|
|
40 | String action = (String) e.getActionCommand();↵ | | 41 | String action = (String) e.getActionCommand();↵
|
41 | Action a = focusOwner.getActionMap().get(action);↵ | | 42 | Action a = focusOwner.getActionMap().get(action);↵
|
42 | if (a != null)↵ | | 43 | if (a != null)↵
|
43 | a.actionPerformed(new ActionEvent(focusOwner,↵ | | 44 | a.actionPerformed(new ActionEvent(focusOwner,↵
|
44 | ActionEvent.ACTION_PERFORMED, null));↵ | | 45 | ActionEvent.ACTION_PERFORMED, null));↵
|
|
45 | }↵ | | 46 | }↵
|
|
46 | /**↵ | | 47 | /**↵
|
47 | * @see org.columba.core.gui.action.AbstractColumbaAction#isSingleton()↵ | | 48 | * @see org.columba.core.gui.action.AbstractColumbaAction#isSingleton()↵
|
48 | */↵ | | 49 | */↵
|
49 | public boolean isSingleton() {↵ | | 50 | public boolean isSingleton() {↵
|
50 | return true;↵ | | 51 | return true;↵
|
51 | | | 52 |
|