1 | public class RedoAction extends AbstractColumbaAction implements↵ | | 1 | public class UndoAction extends AbstractColumbaAction implements↵
|
2 | PropertyChangeListener {↵ | | 2 | PropertyChangeListener {↵
|
3 | ↵ | | |
|
4 | private JComponent focusOwner = null;↵ | | 3 | private JComponent focusOwner = null;↵
|
|
5 | public RedoAction(IFrameMediator controller) {↵ | | 4 | public UndoAction(IFrameMediator controller) {↵
|
6 | super(controller, GlobalResourceLoader.getString(null, null,↵ | | 5 | super(controller, GlobalResourceLoader.getString(null, null,↵
|
7 | "menu_edit_redo"));↵ | | 6 | "menu_edit_undo"));↵
|
|
8 | // tooltip text↵ | | 7 | // tooltip text↵
|
9 | putValue(SHORT_DESCRIPTION, GlobalResourceLoader.getString(null, null,↵ | | 8 | putValue(SHORT_DESCRIPTION, GlobalResourceLoader.getString(null, null,↵
|
10 | "menu_edit_redo_tooltip").replaceAll("&", ""));↵ | | 9 | "menu_edit_undo_tooltip").replaceAll("&", ""));↵
|
|
11 | // small icon for menu↵ | | 10 | // small icon for menu↵
|
12 | putValue(SMALL_ICON, ImageLoader.getSmallIcon(IconKeys.EDIT_REDO));↵ | | 11 | putValue(SMALL_ICON, ImageLoader.getSmallIcon(IconKeys.EDIT_UNDO));↵
|
|
13 | // large icon for toolbar↵ | | 12 | // large icon for toolbar↵
|
14 | putValue(LARGE_ICON, ImageLoader.getIcon(IconKeys.EDIT_REDO));↵ | | 13 | putValue(LARGE_ICON, ImageLoader.getIcon(IconKeys.EDIT_UNDO));↵
|
|
15 | // disable toolbar text↵ | | |
|
16 | setShowToolBarText(false);↵ | | |
|
|
17 | // shortcut key↵ | | 14 | // shortcut key↵
|
18 | putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_Y,↵ | | 15 | putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_Z,↵
|
19 | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));↵ | | 16 | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));↵
|
|
| | | 17 | // disable toolbar text↵
|
| | | 18 | setShowToolBarText(false);↵
|
|
20 | setEnabled(true);↵ | | 19 | setEnabled(true);↵
|
|
21 | KeyboardFocusManager manager = KeyboardFocusManager↵ | | 20 | KeyboardFocusManager manager = KeyboardFocusManager↵
|
22 | .getCurrentKeyboardFocusManager();↵ | | 21 | .getCurrentKeyboardFocusManager();↵
|
|
23 | manager.addPropertyChangeListener("permanentFocusOwner", this);↵ | | 22 | manager.addPropertyChangeListener("permanentFocusOwner", this);↵
|
|
24 | }↵ | | 23 | }↵
|
|
25 | public void propertyChange(PropertyChangeEvent e) {↵ | | 24 | public void propertyChange(PropertyChangeEvent e) {↵
|
26 | Object o = e.getNewValue();↵ | | 25 | Object o = e.getNewValue();↵
|
27 | if (o instanceof JComponent)↵ | | 26 | if (o instanceof JComponent)↵
|
28 | focusOwner = (JComponent) o;↵ | | 27 | focusOwner = (JComponent) o;↵
|
29 | else↵ | | 28 | else↵
|
30 | focusOwner = null;↵ | | 29 | focusOwner = null;↵
|
|
31 | }↵ | | 30 | }↵
|
|
32 | public void actionPerformed(ActionEvent evt) {↵ | | 31 | public void actionPerformed(ActionEvent evt) {↵
|
33 | if (focusOwner == null)↵ | | 32 | if (focusOwner == null)↵
|
34 | return;↵ | | 33 | return;↵
|
|
35 | if (focusOwner instanceof JTextComponent) {↵ | | 34 | if (focusOwner instanceof JTextComponent) {↵
|
36 | Document doc = ((JTextComponent) focusOwner).getDocument();↵ | | 35 | Document doc = ((JTextComponent)focusOwner).getDocument();↵
|
| | | 36 | ↵
|
37 | if (doc instanceof UndoDocument) {↵ | | 37 | if ( doc instanceof UndoDocument) {↵
|
38 | ((UndoDocument) doc).redo() | | 38 | ((UndoDocument)doc).undo()
|