当前位置: 首页>>代码示例>>Java>>正文


Java UndoManager.getInstance方法代码示例

本文整理汇总了Java中com.intellij.openapi.command.undo.UndoManager.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java UndoManager.getInstance方法的具体用法?Java UndoManager.getInstance怎么用?Java UndoManager.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.command.undo.UndoManager的用法示例。


在下文中一共展示了UndoManager.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:FormattingProgressTask.java

示例2: markUnshelvedFilesNonUndoable

import com.intellij.openapi.command.undo.UndoManager; //导入方法依赖的package包/类
@CalledInAwt
private static void markUnshelvedFilesNonUndoable(@NotNull final Project project,
                                                  @NotNull List<ShelvedChange> changes) {
  final UndoManagerImpl undoManager = (UndoManagerImpl)UndoManager.getInstance(project);
  if (undoManager != null && !changes.isEmpty()) {
    ContainerUtil.process(changes, new Processor<ShelvedChange>() {
      @Override
      public boolean process(ShelvedChange change) {
        final VirtualFile vfUnderProject = VfsUtil.findFileByIoFile(new File(project.getBasePath(), change.getAfterPath()), false);
        if (vfUnderProject != null) {
          final DocumentReference documentReference = DocumentReferenceManager.getInstance().create(vfUnderProject);
          undoManager.nonundoableActionPerformed(documentReference, false);
          undoManager.invalidateActionsFor(documentReference);
        }
        return true;
      }
    });
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GitShelveUtils.java

示例3: runExecuteAction

import com.intellij.openapi.command.undo.UndoManager; //导入方法依赖的package包/类
public void runExecuteAction(LanguageConsoleImpl languageConsole) {

    // Process input and add to history
    final Document document = languageConsole.getCurrentEditor().getDocument();
    final String text = document.getText();
    final TextRange range = new TextRange(0, document.getTextLength());

    languageConsole.getCurrentEditor().getSelectionModel().setSelection(range.getStartOffset(), range.getEndOffset());
    if (myAddCurrentToHistory) {
      languageConsole.addCurrentToHistory(range, false, myPreserveMarkup);
    }

    languageConsole.setInputText("");

    final UndoManager manager = languageConsole.getProject() == null ? UndoManager.getGlobalInstance() : UndoManager.getInstance(
      languageConsole.getProject());

    ((UndoManagerImpl)manager).invalidateActionsFor(DocumentReferenceManager.getInstance().create(document));

    myConsoleHistoryModel.addToHistory(text);
    // Send to interpreter / server

    processLine(text);
  }
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:ConsoleExecuteActionHandler.java

示例4: RedoAction

import com.intellij.openapi.command.undo.UndoManager; //导入方法依赖的package包/类
public RedoAction(DomElement domElement) {
    super("Redo", AllIcons.Actions.Redo);

    if (domElement.isValid()) {
        Project project = domElement.getModule().getProject();
        undoManager = UndoManager.getInstance(project);
        //get parent to be sure that underlying xml element exists, e.g. for empty properties there is no underlying xml tag
        XmlElement xmlElement = domElement instanceof Scenario ? domElement.getXmlElement() : domElement.getParent().getXmlElement();

        fileToRedo = xmlElement.getContainingFile().getVirtualFile();
        editorManager = FileEditorManager.getInstance(project);
        FileEditor selectedEditor = editorManager.getSelectedEditor(fileToRedo);
        boolean redoAvailable = undoManager.isRedoAvailable(selectedEditor);
        if (redoAvailable) {
            putValue(Action.NAME, undoManager.getRedoActionNameAndDescription(selectedEditor).second);
        }
        setEnabled(redoAvailable);
        return;
    }
    setEnabled(false);

}
 
开发者ID:PerfCake,项目名称:PerfCakeIDEA-deprecated,代码行数:23,代码来源:RedoAction.java

示例5: UndoAction

import com.intellij.openapi.command.undo.UndoManager; //导入方法依赖的package包/类
public UndoAction(DomElement domElement) {
    super("Undo", AllIcons.Actions.Undo);


    if (domElement.isValid()) {
        Project project = domElement.getModule().getProject();
        undoManager = UndoManager.getInstance(project);
        //get parent to be sure that underlying xml element exists, e.g. for empty properties there is no underlying xml tag
        XmlElement xmlElement = domElement instanceof Scenario ? domElement.getXmlElement() : domElement.getParent().getXmlElement();

        fileToUndo = xmlElement.getContainingFile().getVirtualFile();
        editorManager = FileEditorManager.getInstance(project);
        FileEditor selectedEditor = editorManager.getSelectedEditor(fileToUndo);
        boolean undoAvailable = undoManager.isUndoAvailable(selectedEditor);
        if (undoAvailable) {
            putValue(Action.NAME, undoManager.getUndoActionNameAndDescription(selectedEditor).second);
        }
        setEnabled(undoAvailable);
        return;
    }
    setEnabled(false);

}
 
开发者ID:PerfCake,项目名称:PerfCakeIDEA-deprecated,代码行数:24,代码来源:UndoAction.java

示例6: HexUndoIntelliJHandler

import com.intellij.openapi.command.undo.UndoManager; //导入方法依赖的package包/类
/**
 * Creates a new instance.
 *
 * @param codeArea hexadecimal component
 */
public HexUndoIntelliJHandler(CodeArea codeArea, Project project, DeltaHexFileEditor fileEditor) {
    this.codeArea = codeArea;
    this.fileEditor = fileEditor;
    this.project = project;
    undoManager = UndoManager.getInstance(project);
    init();
}
 
开发者ID:hajdam,项目名称:deltahex-intellij-plugin,代码行数:13,代码来源:HexUndoIntelliJHandler.java

示例7: 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");
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:CommandProcessorImpl.java

示例8: documentChanged

import com.intellij.openapi.command.undo.UndoManager; //导入方法依赖的package包/类
@Override
public void documentChanged(DocumentEvent e) {
  UndoManager undoManager = UndoManager.getInstance(myProject);
  boolean undoOrRedo = undoManager.isUndoInProgress() || undoManager.isRedoInProgress();
  if (undoOrRedo) {
    // allow undo/redo up until 'creation stamp' back in time
    // and check it after action is completed
    if (e.getDocument() == myOrigDocument) {
      //noinspection SSBasedInspection
      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
          if (myOrigCreationStamp > myOrigDocument.getModificationStamp()) {
            closeEditor();
          }
        }
      });
    }
  }
  else if (e.getDocument() == myNewDocument) {
    commitToOriginal(e);
    if (!isValid()) {
      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          closeEditor();
        }
      }, myProject.getDisposed());
    }
  }
  else if (e.getDocument() == myOrigDocument) {
    if (myCommittingToOriginal || myAltFullRange != null && myAltFullRange.isValid()) return;
    ApplicationManager.getApplication().invokeLater(new Runnable() {
      @Override
      public void run() {
        closeEditor();
      }
    }, myProject.getDisposed());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:41,代码来源:QuickEditHandler.java

示例9: 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");
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:41,代码来源:CommandProcessorImpl.java

示例10: documentChanged

import com.intellij.openapi.command.undo.UndoManager; //导入方法依赖的package包/类
@Override
public void documentChanged(DocumentEvent e) {
  UndoManager undoManager = UndoManager.getInstance(myProject);
  boolean undoOrRedo = undoManager.isUndoInProgress() || undoManager.isRedoInProgress();
  if (undoOrRedo) {
    // allow undo/redo up until 'creation stamp' back in time
    // and check it after action is completed
    if (e.getDocument() == myOrigDocument) {
      //noinspection SSBasedInspection
      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
          if (myOrigCreationStamp > myOrigDocument.getModificationStamp()) {
            closeEditor();
          }
        }
      });
    }
  }
  else if (e.getDocument() == myNewDocument) {
    commitToOriginal();
  }
  else if (e.getDocument() == myOrigDocument) {
    if (myCommittingToOriginal || myAltFullRange != null && myAltFullRange.isValid()) return;
    closeEditor();
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:28,代码来源:QuickEditHandler.java

示例11: register

import com.intellij.openapi.command.undo.UndoManager; //导入方法依赖的package包/类
public static void register(@javax.annotation.Nullable Project project, @Nonnull Editor editor, @Nonnull JComponent component) {
  UndoManager undoManager = project != null ? UndoManager.getInstance(project) : UndoManager.getGlobalInstance();
  TextEditor textEditor = TextEditorProvider.getInstance().getTextEditor(editor);
  if (undoManager != null) {
    EmptyAction.setupAction(new ProxyUndoRedoAction(undoManager, textEditor, true), IdeActions.ACTION_UNDO, component);
    EmptyAction.setupAction(new ProxyUndoRedoAction(undoManager, textEditor, false), IdeActions.ACTION_REDO, component);
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:9,代码来源:ProxyUndoRedoAction.java

示例12: MergeModelBase

import com.intellij.openapi.command.undo.UndoManager; //导入方法依赖的package包/类
public MergeModelBase(@javax.annotation.Nullable Project project, @Nonnull Document document) {
  myProject = project;
  myDocument = document;
  myUndoManager = myProject != null ? UndoManager.getInstance(myProject) : UndoManager.getGlobalInstance();

  myDocument.addDocumentListener(new MyDocumentListener(), this);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:8,代码来源:MergeModelBase.java

示例13: putNonundoableOperation

import com.intellij.openapi.command.undo.UndoManager; //导入方法依赖的package包/类
public static void putNonundoableOperation(@Nullable Project project, @Nonnull Document document) {
  UndoManager undoManager = project != null ? UndoManager.getInstance(project) : UndoManager.getGlobalInstance();
  if (undoManager != null) {
    DocumentReference ref = DocumentReferenceManager.getInstance().create(document);
    undoManager.nonundoableActionPerformed(ref, false);
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:8,代码来源:DiffUtil.java

示例14: undo

import com.intellij.openapi.command.undo.UndoManager; //导入方法依赖的package包/类
protected void undo() {
  UndoManager undoManager = UndoManager.getInstance(myProject);
  TextEditor textEditor = TextEditorProvider.getInstance().getTextEditor(getEditor());
  undoManager.undo(textEditor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:CodeInsightTestCase.java

示例15: getUndoManager

import com.intellij.openapi.command.undo.UndoManager; //导入方法依赖的package包/类
private static UndoManagerImpl getUndoManager(Project project) {
  return (UndoManagerImpl)(project != null ? UndoManager.getInstance(project) : UndoManager.getGlobalInstance());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:CommandProcessorImpl.java


注:本文中的com.intellij.openapi.command.undo.UndoManager.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。