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