Example usage for com.intellij.openapi.command.undo UndoManager isUndoAvailable

List of usage examples for com.intellij.openapi.command.undo UndoManager isUndoAvailable

Introduction

In this page you can find the example usage for com.intellij.openapi.command.undo UndoManager isUndoAvailable.

Prototype

public abstract boolean isUndoAvailable(@Nullable FileEditor editor);

Source Link

Usage

From source file:com.intellij.ide.actions.UndoAction.java

License:Apache License

@Override
protected boolean isAvailable(FileEditor editor, UndoManager undoManager) {
    return undoManager.isUndoAvailable(editor);
}

From source file:com.maddyhome.idea.vim.helper.UndoRedoHelper.java

License:Open Source License

public static boolean undo(@NotNull final DataContext context) {
    final Project project = PlatformDataKeys.PROJECT.getData(context);
    final FileEditor fileEditor = PlatformDataKeys.FILE_EDITOR.getData(context);
    final com.intellij.openapi.command.undo.UndoManager undoManager = com.intellij.openapi.command.undo.UndoManager
            .getInstance(project);/*from w ww.j a  v  a2s.  c o m*/
    if (fileEditor != null && undoManager.isUndoAvailable(fileEditor)) {
        undoManager.undo(fileEditor);
        return true;
    }
    return false;
}