com.intellij.openapi.editor.actionSystem.DocCommandGroupId Java Examples
The following examples show how to use
com.intellij.openapi.editor.actionSystem.DocCommandGroupId.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseRefactorAction.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 6 votes |
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())); } }
Example #2
Source File: CodeInsightAction.java From consulo with Apache License 2.0 | 6 votes |
@RequiredUIAccess 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; final CodeInsightActionHandler handler = getHandler(); PsiElement elementToMakeWritable = handler.getElementToMakeWritable(psiFile); if (elementToMakeWritable != null && !(EditorModificationUtil.checkModificationAllowed(editor) && FileModificationService.getInstance().preparePsiElementsForWrite(elementToMakeWritable))) { return; } CommandProcessor.getInstance().executeCommand(project, () -> { final Runnable action = () -> { if (!ApplicationManager.getApplication().isHeadlessEnvironment() && !editor.getContentComponent().isShowing()) return; handler.invoke(project, editor, psiFile); }; if (handler.startInWriteAction()) { ApplicationManager.getApplication().runWriteAction(action); } else { action.run(); } }, getCommandName(), DocCommandGroupId.noneGroupId(editor.getDocument()), editor.getDocument()); }
Example #3
Source File: DesktopEditorErrorPanel.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess public void mouseClicked(final MouseEvent e) { CommandProcessor.getInstance().executeCommand(myEditor.getProject(), new Runnable() { @Override @RequiredUIAccess public void run() { doMouseClicked(e); } }, EditorBundle.message("move.caret.command.name"), DocCommandGroupId.noneGroupId(myEditor.getDocument()), UndoConfirmationPolicy.DEFAULT, myEditor.getDocument()); }
Example #4
Source File: DocumentImpl.java From consulo with Apache License 2.0 | 5 votes |
@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(); }
Example #5
Source File: MultiCaretCodeInsightAction.java From consulo with Apache License 2.0 | 5 votes |
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); }
Example #6
Source File: ApplyPatchAction.java From nopol with GNU General Public License v2.0 | 4 votes |
@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() == RepairType.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() == RepairType.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); }
Example #7
Source File: CodeInsightTestFixtureImpl.java From consulo with Apache License 2.0 | 4 votes |
@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())); } }); }
Example #8
Source File: BaseEnterHandler.java From consulo with Apache License 2.0 | 4 votes |
@Override public DocCommandGroupId getCommandGroupId(Editor editor) { return DocCommandGroupId.withGroupId(editor.getDocument(), GROUP_ID); }