本文整理汇总了Java中com.intellij.openapi.command.undo.UndoManager.isUndoAvailable方法的典型用法代码示例。如果您正苦于以下问题:Java UndoManager.isUndoAvailable方法的具体用法?Java UndoManager.isUndoAvailable怎么用?Java UndoManager.isUndoAvailable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.command.undo.UndoManager
的用法示例。
在下文中一共展示了UndoManager.isUndoAvailable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import com.intellij.openapi.command.undo.UndoManager; //导入方法依赖的package包/类
@Override
public void run() {
FORMATTING_CANCELLED_FLAG.set(true);
VirtualFile file = myFile.get();
Document document = myDocument.get();
if (file == null || document == null || myDocumentModificationStampBefore < 0) {
return;
}
FileEditor editor = FileEditorManager.getInstance(myProject).getSelectedEditor(file);
if (editor == null) {
return;
}
UndoManager manager = UndoManager.getInstance(myProject);
while (manager.isUndoAvailable(editor) && document.getModificationStamp() != myDocumentModificationStampBefore) {
manager.undo(editor);
}
}
示例2: finishCommand
import com.intellij.openapi.command.undo.UndoManager; //导入方法依赖的package包/类
@Override
public void finishCommand(final Project project, final Object command, final Throwable throwable) {
if (myCurrentCommand != command) return;
final boolean failed;
try {
if (throwable instanceof AbnormalCommandTerminationException) {
final AbnormalCommandTerminationException rollback = (AbnormalCommandTerminationException)throwable;
if (ApplicationManager.getApplication().isUnitTestMode()) {
throw new RuntimeException(rollback);
}
failed = true;
}
else if (throwable != null) {
failed = true;
if (throwable instanceof Error) {
throw (Error)throwable;
}
else if (throwable instanceof RuntimeException) throw (RuntimeException)throwable;
CommandLog.LOG.error(throwable);
}
else {
failed = false;
}
}
finally {
super.finishCommand(project, command, throwable);
}
if (failed) {
if (project != null) {
FileEditor editor = new FocusBasedCurrentEditorProvider().getCurrentEditor();
final UndoManager undoManager = UndoManager.getInstance(project);
if (undoManager.isUndoAvailable(editor)) {
undoManager.undo(editor);
}
}
Messages.showErrorDialog(project, "Cannot perform operation. Too complex, sorry.", "Failed to Perform Operation");
}
}
示例3: finishCommand
import com.intellij.openapi.command.undo.UndoManager; //导入方法依赖的package包/类
@Override
public void finishCommand(final Project project, final Object command, final Throwable throwable) {
ApplicationManager.getApplication().assertIsDispatchThread();
CommandLog.LOG.assertTrue(myCurrentCommand != null, "no current command in progress");
if (myCurrentCommand != command) return;
final boolean failed;
try {
if (throwable instanceof AbnormalCommandTerminationException) {
final AbnormalCommandTerminationException rollback = (AbnormalCommandTerminationException)throwable;
if (ApplicationManager.getApplication().isUnitTestMode()) {
throw new RuntimeException(rollback);
}
failed = true;
}
else if (throwable != null) {
failed = true;
if (throwable instanceof Error) {
throw (Error)throwable;
}
else if (throwable instanceof RuntimeException) throw (RuntimeException)throwable;
CommandLog.LOG.error(throwable);
}
else {
failed = false;
}
}
finally {
fireCommandFinished();
}
if (failed) {
if (project != null) {
FileEditor editor = new FocusBasedCurrentEditorProvider().getCurrentEditor();
final UndoManager undoManager = UndoManager.getInstance(project);
if (undoManager.isUndoAvailable(editor)) {
undoManager.undo(editor);
}
}
Messages.showErrorDialog(project, "Cannot perform operation. Too complex, sorry.", "Failed to Perform Operation");
}
}
示例4: isAvailable
import com.intellij.openapi.command.undo.UndoManager; //导入方法依赖的package包/类
@Override
protected boolean isAvailable(FileEditor editor, UndoManager undoManager) {
return undoManager.isUndoAvailable(editor);
}
示例5: finishCommand
import com.intellij.openapi.command.undo.UndoManager; //导入方法依赖的package包/类
@Override
public void finishCommand(final Project project, final Object command, final Throwable throwable) {
if (myCurrentCommand != command) return;
final boolean failed;
try {
if (throwable instanceof AbnormalCommandTerminationException) {
final AbnormalCommandTerminationException rollback = (AbnormalCommandTerminationException)throwable;
if (ApplicationManager.getApplication().isUnitTestMode()) {
throw new RuntimeException(rollback);
}
failed = true;
}
else if (throwable != null) {
failed = true;
ExceptionUtil.rethrowUnchecked(throwable);
CommandLog.LOG.error(throwable);
}
else {
failed = false;
}
}
finally {
try {
super.finishCommand(project, command, throwable);
}
catch (Throwable e) {
if (throwable != null) {
e.addSuppressed(throwable);
}
throw e;
}
}
if (failed) {
if (project != null) {
FileEditor editor = new FocusBasedCurrentEditorProvider().getCurrentEditor();
final UndoManager undoManager = UndoManager.getInstance(project);
if (undoManager.isUndoAvailable(editor)) {
undoManager.undo(editor);
}
}
Messages.showErrorDialog(project, "Cannot perform operation. Too complex, sorry.", "Failed to Perform Operation");
}
}