List of usage examples for com.intellij.openapi.actionSystem IdeActions ACTION_UNDO
String ACTION_UNDO
To view the source code for com.intellij.openapi.actionSystem IdeActions ACTION_UNDO.
Click Source Link
From source file:com.intellij.ui.TextComponentUndoProvider.java
License:Apache License
public TextComponentUndoProvider(final JTextComponent textComponent) { myTextComponent = textComponent;//from www.j a va 2s . c om myUndoableEditListener = new UndoableEditListener() { public void undoableEditHappened(UndoableEditEvent e) { myUndoManager.addEdit(e.getEdit()); } }; myTextComponent.getDocument().addUndoableEditListener(myUndoableEditListener); com.intellij.openapi.keymap.Keymap activeKeymap = KeymapManager.getInstance().getActiveKeymap(); Shortcut[] undoShortcuts = activeKeymap.getShortcuts(IdeActions.ACTION_UNDO); Shortcut[] redoShortcuts = activeKeymap.getShortcuts(IdeActions.ACTION_REDO); AnAction undoAction = new AnAction() { @Override public void update(AnActionEvent e) { super.update(e); e.getPresentation().setEnabled(canUndo()); } @Override public void actionPerformed(AnActionEvent e) { undo(); } }; AnAction redoAction = new AnAction() { @Override public void update(AnActionEvent e) { super.update(e); e.getPresentation().setEnabled(canRedo()); } @Override public void actionPerformed(AnActionEvent e) { redo(); } }; undoAction.registerCustomShortcutSet(new CustomShortcutSet(undoShortcuts), myTextComponent); redoAction.registerCustomShortcutSet(new CustomShortcutSet(redoShortcuts), myTextComponent); }