Java 类com.intellij.openapi.editor.actionSystem.DocCommandGroupId 实例源码

项目:intellij-ce-playground    文件:CodeInsightAction.java   
public void actionPerformedImpl(@NotNull final Project project, final Editor editor) {
  if (editor == null) return;
  //final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
  final PsiFile psiFile = PsiUtilBase.getPsiFileInEditor(editor, project);
  if (psiFile == null) return;
  CommandProcessor.getInstance().executeCommand(project, new Runnable() {
    @Override
    public void run() {
      final CodeInsightActionHandler handler = getHandler();
      final Runnable action = new Runnable() {
        @Override
        public void run() {
          if (!ApplicationManager.getApplication().isUnitTestMode() && !editor.getContentComponent().isShowing()) return;
          handler.invoke(project, editor, psiFile);
        }
      };
      if (handler.startInWriteAction()) {
        ApplicationManager.getApplication().runWriteAction(action);
      }
      else {
        action.run();
      }
    }
  }, getCommandName(), DocCommandGroupId.noneGroupId(editor.getDocument()));
}
项目:intellij-ce-playground    文件:DocumentImpl.java   
@Override
public void setText(@NotNull final CharSequence text) {
  Runnable runnable = new Runnable() {
    @Override
    public void run() {
      replaceString(0, getTextLength(), text, LocalTimeCounter.currentTime(), true);
    }
  };
  if (CommandProcessor.getInstance().isUndoTransparentActionInProgress()) {
    runnable.run();
  }
  else {
    CommandProcessor.getInstance().executeCommand(null, runnable, "", DocCommandGroupId.noneGroupId(this));
  }

  clearLineModificationFlags();
}
项目:intellij-ce-playground    文件:MultiCaretCodeInsightAction.java   
public void actionPerformedImpl(final Project project, final Editor hostEditor) {
  CommandProcessor.getInstance().executeCommand(project, new Runnable() {
    @Override
    public void run() {
      ApplicationManager.getApplication().runWriteAction(new Runnable() {
        @Override
        public void run() {
          MultiCaretCodeInsightActionHandler handler = getHandler();
          try {
            iterateOverCarets(project, hostEditor, handler);
          }
          finally {
            handler.postInvoke();
          }
        }
      });
    }
  }, getCommandName(), DocCommandGroupId.noneGroupId(hostEditor.getDocument()));

  hostEditor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
}
项目:intellij-ce-playground    文件:XmlSyncTagTest.java   
protected void type(String toType) {
  for (int i = 0; i < toType.length(); i++) {
    final char c = toType.charAt(i);
    CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
      @Override
      public void run() {
        ApplicationManager.getApplication().runWriteAction(new Runnable() {
          @Override
          public void run() {
            myFixture.type(c);
          }
        });
      }
    }, "Typing", DocCommandGroupId.noneGroupId(myFixture.getEditor().getDocument()), myFixture.getEditor().getDocument());
  }
}
项目:intellij-ce-playground    文件:XmlSyncTagTest.java   
protected void doTestCompletion(final FileType fileType,
                                final String text,
                                final String toType,
                                final String result) {
  myFixture.configureByText(fileType, text);
  CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
    @Override
    public void run() {
      ApplicationManager.getApplication().runWriteAction(new Runnable() {
        @Override
        public void run() {
          myFixture.completeBasic();
          if (toType != null) myFixture.type(toType);
        }
      });
    }
  }, "Typing", DocCommandGroupId.noneGroupId(myFixture.getEditor().getDocument()), myFixture.getEditor().getDocument());
  myFixture.checkResult(result);
}
项目:eddy    文件:LightDocument.java   
@Override
public void setText(@NotNull final CharSequence text) {
  Runnable runnable = new Runnable() {
    @Override
    public void run() {
      replaceString(0, getTextLength(), text, LocalTimeCounter.currentTime(), true);
    }
  };
  if (CommandProcessor.getInstance().isUndoTransparentActionInProgress()) {
    runnable.run();
  }
  else {
    CommandProcessor.getInstance().executeCommand(null, runnable, "", DocCommandGroupId.noneGroupId(this));
  }

  clearLineModificationFlags();
}
项目:tools-idea    文件:CodeInsightAction.java   
public void actionPerformedImpl(@NotNull final Project project, final Editor editor) {
  if (editor == null) return;
  //final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
  final PsiFile psiFile = PsiUtilBase.getPsiFileInEditor(editor, project);
  if (psiFile == null) return;
  CommandProcessor.getInstance().executeCommand(project, new Runnable() {
    @Override
    public void run() {
      final CodeInsightActionHandler handler = getHandler();
      final Runnable action = new Runnable() {
        @Override
        public void run() {
          if (!ApplicationManager.getApplication().isUnitTestMode() && !editor.getContentComponent().isShowing()) return;
          handler.invoke(project, editor, psiFile);
        }
      };
      if (handler.startInWriteAction()) {
        ApplicationManager.getApplication().runWriteAction(action);
      }
      else {
        action.run();
      }
    }
  }, getCommandName(), DocCommandGroupId.noneGroupId(editor.getDocument()));
}
项目:tools-idea    文件:DocumentImpl.java   
@Override
public void setText(@NotNull final CharSequence text) {
  Runnable runnable = new Runnable() {
    @Override
    public void run() {
      replaceString(0, getTextLength(), text, LocalTimeCounter.currentTime(), true);
    }
  };
  if (CommandProcessor.getInstance().isUndoTransparentActionInProgress()) {
    runnable.run();
  }
  else {
    CommandProcessor.getInstance().executeCommand(null, runnable, "", DocCommandGroupId.noneGroupId(this));
  }

  clearLineModificationFlags();
}
项目:lombok-intellij-plugin    文件:BaseRefactorAction.java   
public void actionPerformed(AnActionEvent e) {
  final Project project = e.getProject();
  final BaseRefactorHandler handler = initHandler(project, e.getDataContext());

  boolean processChooser = handler.processChooser();

  if (processChooser) {
    final Editor editor = getEditor(e);

    CommandProcessor.getInstance().executeCommand(project, new Runnable() {
      @Override
      public void run() {
        ApplicationManager.getApplication().runWriteAction(handler);
      }
    }, getClass().getName() + "-Commandname", DocCommandGroupId.noneGroupId(editor.getDocument()));
  }
}
项目:consulo    文件:CodeInsightAction.java   
@RequiredDispatchThread
public void actionPerformedImpl(@Nonnull final Project project, final Editor editor) {
  if (editor == null) return;
  //final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
  final PsiFile psiFile = PsiUtilBase.getPsiFileInEditor(editor, project);
  if (psiFile == null) return;
  CommandProcessor.getInstance().executeCommand(project, new Runnable() {
    @Override
    public void run() {
      final CodeInsightActionHandler handler = getHandler();
      final Runnable action = new Runnable() {
        @Override
        public void run() {
          if (!ApplicationManager.getApplication().isUnitTestMode() && !editor.getContentComponent().isShowing()) return;
          handler.invoke(project, editor, psiFile);
        }
      };
      if (handler.startInWriteAction()) {
        ApplicationManager.getApplication().runWriteAction(action);
      }
      else {
        action.run();
      }
    }
  }, getCommandName(), DocCommandGroupId.noneGroupId(editor.getDocument()));
}
项目:intellij-ce-playground    文件:EditorMarkupModelImpl.java   
@Override
public void mouseClicked(@NotNull final MouseEvent e) {
  CommandProcessor.getInstance().executeCommand(myEditor.getProject(), new Runnable() {
    @Override
    public void run() {
      doMouseClicked(e);
    }
  },
                                                EditorBundle.message("move.caret.command.name"),
                                                DocCommandGroupId.noneGroupId(getDocument()), UndoConfirmationPolicy.DEFAULT,
                                                getDocument()
  );
}
项目:intellij-ce-playground    文件:DaemonListeners.java   
@Nullable
private Document extractDocumentFromCommand(CommandEvent event) {
  Document affectedDocument = event.getDocument();
  if (affectedDocument != null) return affectedDocument;
  Object id = event.getCommandGroupId();

  if (id instanceof Document) {
    affectedDocument = (Document)id;
  }
  else if (id instanceof DocCommandGroupId) {
    affectedDocument = ((DocCommandGroupId)id).getDocument();
  }
  return affectedDocument;
}
项目:tools-idea    文件:EditorMarkupModelImpl.java   
@Override
public void mouseClicked(final MouseEvent e) {
  CommandProcessor.getInstance().executeCommand(myEditor.getProject(), new Runnable() {
    @Override
    public void run() {
      doMouseClicked(e);
    }
  },
                                                EditorBundle.message("move.caret.command.name"),
                                                DocCommandGroupId.noneGroupId(getDocument()), UndoConfirmationPolicy.DEFAULT,
                                                getDocument()
  );
}
项目:tools-idea    文件:DaemonListeners.java   
@Nullable
private Document extractDocumentFromCommand(CommandEvent event) {
  Document affectedDocument = event.getDocument();
  if (affectedDocument != null) return affectedDocument;
  Object id = event.getCommandGroupId();

  if (id instanceof Document) {
    affectedDocument = (Document)id;
  }
  else if (id instanceof DocCommandGroupId) {
    affectedDocument = ((DocCommandGroupId)id).getDocument();
  }
  return affectedDocument;
}
项目:consulo    文件:EditorMarkupModelImpl.java   
@Override
@RequiredDispatchThread
public void mouseClicked(final MouseEvent e) {
  CommandProcessor.getInstance().executeCommand(myEditor.getProject(), new Runnable() {
    @Override
    @RequiredDispatchThread
    public void run() {
      doMouseClicked(e);
    }
  }, EditorBundle.message("move.caret.command.name"), DocCommandGroupId.noneGroupId(getDocument()), UndoConfirmationPolicy.DEFAULT, getDocument());
}
项目:consulo    文件:DocumentImpl.java   
@Override
public void setText(@Nonnull final CharSequence text) {
  Runnable runnable = () -> replaceString(0, getTextLength(), text, LocalTimeCounter.currentTime(), true);
  if (CommandProcessor.getInstance().isUndoTransparentActionInProgress()) {
    runnable.run();
  }
  else {
    CommandProcessor.getInstance().executeCommand(null, runnable, "", DocCommandGroupId.noneGroupId(this));
  }

  clearLineModificationFlags();
}
项目:consulo    文件:DaemonListeners.java   
@Nullable
private Document extractDocumentFromCommand(CommandEvent event) {
  Document affectedDocument = event.getDocument();
  if (affectedDocument != null) return affectedDocument;
  Object id = event.getCommandGroupId();

  if (id instanceof Document) {
    affectedDocument = (Document)id;
  }
  else if (id instanceof DocCommandGroupId) {
    affectedDocument = ((DocCommandGroupId)id).getDocument();
  }
  return affectedDocument;
}
项目:consulo    文件:MultiCaretCodeInsightAction.java   
public void actionPerformedImpl(final Project project, final Editor hostEditor) {
  CommandProcessor.getInstance().executeCommand(project, () -> ApplicationManager.getApplication().runWriteAction(() -> {
    MultiCaretCodeInsightActionHandler handler = getHandler();
    try {
      iterateOverCarets(project, hostEditor, handler);
    }
    finally {
      handler.postInvoke();
    }
  }), getCommandName(), DocCommandGroupId.noneGroupId(hostEditor.getDocument()));

  hostEditor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
}
项目:intellij-ce-playground    文件:CodeInsightTestFixtureImpl.java   
@Override
public void type(final char c) {
  assertInitialized();
  UIUtil.invokeAndWaitIfNeeded(new Runnable() {
    @Override
    public void run() {
      final EditorActionManager actionManager = EditorActionManager.getInstance();
      if (c == '\b') {
        performEditorAction(IdeActions.ACTION_EDITOR_BACKSPACE);
        return;
      }
      if (c == '\n') {
        if (_performEditorAction(IdeActions.ACTION_CHOOSE_LOOKUP_ITEM)) {
          return;
        }
        if (_performEditorAction(IdeActions.ACTION_EDITOR_NEXT_TEMPLATE_VARIABLE)) {
          return;
        }

        performEditorAction(IdeActions.ACTION_EDITOR_ENTER);
        return;
      }
      if (c == '\t') {
        if (_performEditorAction(IdeActions.ACTION_CHOOSE_LOOKUP_ITEM_REPLACE)) {
          return;
        }
        if (_performEditorAction(IdeActions.ACTION_EXPAND_LIVE_TEMPLATE_BY_TAB)) {
          return;
        }
        if (_performEditorAction(IdeActions.ACTION_EDITOR_NEXT_TEMPLATE_VARIABLE)) {
          return;
        }
        if (_performEditorAction(IdeActions.ACTION_EDITOR_TAB)) {
          return;
        }
      }
      if (c == Lookup.COMPLETE_STATEMENT_SELECT_CHAR) {
        if (_performEditorAction(IdeActions.ACTION_CHOOSE_LOOKUP_ITEM_COMPLETE_STATEMENT)) {
          return;
        }
      }

      CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
        @Override
        public void run() {
          CommandProcessor.getInstance().setCurrentCommandGroupId(myEditor.getDocument());
          ActionManagerEx.getInstanceEx().fireBeforeEditorTyping(c, getEditorDataContext());
          actionManager.getTypedAction().actionPerformed(getEditor(), c, getEditorDataContext());
        }
      }, null, DocCommandGroupId.noneGroupId(myEditor.getDocument()));
    }
  });
}
项目:intellij-ce-playground    文件:BaseEnterHandler.java   
@Override
public DocCommandGroupId getCommandGroupId(Editor editor) {
  return DocCommandGroupId.withGroupId(editor.getDocument(), GROUP_ID);
}
项目:nopol    文件:ApplyPatchAction.java   
@Override
public void actionPerformed(ActionEvent e) {
    final Project project = this.parent.getProject();
    PsiElement buggyElement = this.parent.getBuggyElement();
    final Patch selectedPatch = this.parent.getSelectedPatch();

    PsiClass classToBeFix = JavaPsiFacade.getInstance(project).findClass(selectedPatch.getRootClassName(), new EverythingGlobalScope(project));
    OpenFileDescriptor descriptor = new OpenFileDescriptor(project, classToBeFix.getContainingFile().getVirtualFile(), buggyElement.getTextOffset());
    Editor editor = FileEditorManager.getInstance(project).openTextEditor(descriptor, true);
    Document modifiedDocument = editor.getDocument();

    final String patch;

    if (selectedPatch.getType() == StatementType.CONDITIONAL) {
        buggyElement = ((PsiIfStatement) buggyElement).getCondition();
        patch = selectedPatch.asString();
    } else {
        String newline = FileDocumentManager.getInstance().getFile(modifiedDocument).getDetectedLineSeparator();
        StringBuilder sb = new StringBuilder();
        sb.append("if( ");
        sb.append(selectedPatch.asString());
        sb.append(" ) {" + newline);
        sb.append(buggyElement.getText() + newline);
        sb.append("}");
        patch = sb.toString();
    }

    final PsiElement finalBuggyElement = buggyElement;

    CommandProcessor.getInstance().executeCommand(project, () -> WriteCommandAction.runWriteCommandAction(project, () -> {
        //Apply the patch
        modifiedDocument.replaceString(finalBuggyElement.getTextOffset(), finalBuggyElement.getTextOffset() + finalBuggyElement.getTextLength(), patch);
        //Move caret to modification
        editor.getCaretModel().moveToOffset(finalBuggyElement.getTextOffset());
        //Select patch
        editor.getSelectionModel().setSelection(finalBuggyElement.getTextOffset(), finalBuggyElement.getTextOffset() +
                (selectedPatch.getType() == StatementType.CONDITIONAL ? finalBuggyElement.getTextLength() : patch.length()));
        PsiDocumentManager.getInstance(project).commitDocument(modifiedDocument);
        CodeStyleManager.getInstance(project).reformat(PsiDocumentManager.getInstance(project).getPsiFile(modifiedDocument), false);
    }), "Apply Patch", DocCommandGroupId.noneGroupId(modifiedDocument));

    PsiDocumentManager.getInstance(project).commitDocument(modifiedDocument);

    parent.close(0);
}
项目:tools-idea    文件:CodeInsightTestFixtureImpl.java   
@Override
public void type(final char c) {
  assertInitialized();
  UIUtil.invokeAndWaitIfNeeded(new Runnable() {
    @Override
    public void run() {
      final EditorActionManager actionManager = EditorActionManager.getInstance();
      if (c == '\b') {
        performEditorAction(IdeActions.ACTION_EDITOR_BACKSPACE);
        return;
      }
      if (c == '\n') {
        if (_performEditorAction(IdeActions.ACTION_CHOOSE_LOOKUP_ITEM)) {
          return;
        }

        performEditorAction(IdeActions.ACTION_EDITOR_ENTER);
        return;
      }
      if (c == '\t') {
        if (_performEditorAction(IdeActions.ACTION_CHOOSE_LOOKUP_ITEM_REPLACE)) {
          return;
        }
        if (_performEditorAction(IdeActions.ACTION_EXPAND_LIVE_TEMPLATE_BY_TAB)) {
          return;
        }
        if (_performEditorAction(IdeActions.ACTION_EDITOR_NEXT_TEMPLATE_VARIABLE)) {
          return;
        }
        if (_performEditorAction(IdeActions.ACTION_EDITOR_TAB)) {
          return;
        }
      }
      if (c == Lookup.COMPLETE_STATEMENT_SELECT_CHAR) {
        if (_performEditorAction(IdeActions.ACTION_CHOOSE_LOOKUP_ITEM_COMPLETE_STATEMENT)) {
          return;
        }
      }

      CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
        @Override
        public void run() {
          CommandProcessor.getInstance().setCurrentCommandGroupId(myEditor.getDocument());
          ActionManagerEx.getInstanceEx().fireBeforeEditorTyping(c, getEditorDataContext());
          actionManager.getTypedAction().actionPerformed(getEditor(), c, getEditorDataContext());
        }
      }, null, DocCommandGroupId.noneGroupId(myEditor.getDocument()));
    }
  });
}
项目:tools-idea    文件:BaseEnterHandler.java   
@Override
public DocCommandGroupId getCommandGroupId(Editor editor) {
  return DocCommandGroupId.withGroupId(editor.getDocument(), GROUP_ID);
}
项目:consulo    文件:CodeInsightTestFixtureImpl.java   
@Override
public void type(final char c) {
  assertInitialized();
  UIUtil.invokeAndWaitIfNeeded(new Runnable() {
    @Override
    public void run() {
      final EditorActionManager actionManager = EditorActionManager.getInstance();
      if (c == '\b') {
        performEditorAction(IdeActions.ACTION_EDITOR_BACKSPACE);
        return;
      }
      if (c == '\n') {
        if (_performEditorAction(IdeActions.ACTION_CHOOSE_LOOKUP_ITEM)) {
          return;
        }

        performEditorAction(IdeActions.ACTION_EDITOR_ENTER);
        return;
      }
      if (c == '\t') {
        if (_performEditorAction(IdeActions.ACTION_CHOOSE_LOOKUP_ITEM_REPLACE)) {
          return;
        }
        if (_performEditorAction(IdeActions.ACTION_EXPAND_LIVE_TEMPLATE_BY_TAB)) {
          return;
        }
        if (_performEditorAction(IdeActions.ACTION_EDITOR_NEXT_TEMPLATE_VARIABLE)) {
          return;
        }
        if (_performEditorAction(IdeActions.ACTION_EDITOR_TAB)) {
          return;
        }
      }
      if (c == Lookup.COMPLETE_STATEMENT_SELECT_CHAR) {
        if (_performEditorAction(IdeActions.ACTION_CHOOSE_LOOKUP_ITEM_COMPLETE_STATEMENT)) {
          return;
        }
      }

      CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
        @Override
        public void run() {
          CommandProcessor.getInstance().setCurrentCommandGroupId(myEditor.getDocument());
          ActionManagerEx.getInstanceEx().fireBeforeEditorTyping(c, getEditorDataContext());
          actionManager.getTypedAction().actionPerformed(getEditor(), c, getEditorDataContext());
        }
      }, null, DocCommandGroupId.noneGroupId(myEditor.getDocument()));
    }
  });
}
项目:consulo    文件:BaseEnterHandler.java   
@Override
public DocCommandGroupId getCommandGroupId(Editor editor) {
  return DocCommandGroupId.withGroupId(editor.getDocument(), GROUP_ID);
}