private ChainActionEvent createPendingSelectAndPasteAction(AnActionEvent e) { Runnable selectAndPaste = new Runnable() { @Override public void run() { Runnable runnable = new Runnable() { @Override public void run() { CommandContext cmdCtx = CopyCutWithoutSelectAction.getInstance().getCmdContext(); TextRange tr = Selection.getTextRangeBy(_editor, cmdCtx); if (tr != null) { _editor.getSelectionModel().setSelection(tr.getStartOffset(), tr.getEndOffset()); EditorCopyPasteHelperImpl.getInstance().pasteFromClipboard(_editor); } } }; AppUtil.runWriteAction(runnable, _editor); } }; return new ChainActionEvent(e, selectAndPaste, _editor, _project); }
@Override public void afterJump() { final Runnable runnable = new Runnable() { @Override public void run() { EditorUtils.copyRange(_selectorClass, _te); pasteClipboardToOffset(); } private void pasteClipboardToOffset() { focusSourceCaret(); TextRange[] tr = EditorCopyPasteHelperImpl.getInstance().pasteFromClipboard(_se); if (_config._needSelectTextAfterJump) EditorUtils.selectTextRange(_se, tr); } }; AppUtil.runWriteAction(runnable, _se); }
@Override public void afterJump() { TextRange tr = getTextRangeToReplace(); if (tr != null) { _se.getSelectionModel().setSelection(tr.getStartOffset(), tr.getEndOffset()); } final Runnable runnable = new Runnable() { @Override public void run() { if (_addNewLineBeforePaste) { _se.getDocument().insertString(_se.getCaretModel().getOffset(), "\n"); _se.getCaretModel().moveToOffset(_se.getCaretModel().getOffset() + 1); } EditorCopyPasteHelperImpl.getInstance().pasteFromClipboard(_se); } }; AppUtil.runWriteAction(runnable, _se); }
@Override public void afterJump() { final Runnable runnable = new Runnable() { @Override public void run() { EditorUtils.copyRange(_selectorClass, _te); focusSourceCaret(); EditorUtils.selectRangeOf(_selectorClass, _se); EditorUtils.deleteRange(_selectorClass, _se); TextRange[] tr = EditorCopyPasteHelperImpl.getInstance().pasteFromClipboard(_se); if (_config._needSelectTextAfterJump) { EditorUtils.selectTextRange(_se, tr); } } }; AppUtil.runWriteAction(runnable, _se); }
@Override public void afterJump() { final Runnable runnable = new Runnable() { @Override public void run() { TextRange tr = EditorUtils.getRangeOf(_selectorClass, _te); if (tr != null) { _te.getSelectionModel().setSelection(tr.getStartOffset(), tr.getEndOffset()); EditorUtils.deleteRange(tr, _te); } CaretModel targetCaret = _te.getCaretModel(); if (_addNewLineBeforePaste) { _te.getDocument().insertString(targetCaret.getOffset(), "\n"); targetCaret.moveToOffset(targetCaret.getOffset() + 1); } TextRange[] textRanges = EditorCopyPasteHelperImpl.getInstance().pasteFromClipboard(_te); if (_config._needSelectTextAfterJump) { int caret = textRanges[0].getStartOffset() + _caretOffsetFromSelectRangeStartBeforeJump; targetCaret.moveToOffset(caret); EditorUtils.selectRangeOf(_selectorClass, _te); } } }; AppUtil.runWriteAction(runnable, _se); }
@Override public void afterJump() { final Runnable runnable = new Runnable() { @Override public void run() { TextRange sourceRange = EditorUtils.getRangeOf(_selectorClass, _te); if (inSameEditor()) { boolean noNeedToMove = sourceRange.contains(_soff); if (noNeedToMove) { _se.getCaretModel().moveToOffset(_soff); return; } } int textSourceStartOffset = sourceRange.getStartOffset(); EditorUtils.copyRange(_selectorClass, _te); if ( !inSameEditor() || textSourceStartOffset > _soff) { deleteTextSource(_te); pasteClipboardToOffset(); } else { pasteClipboardToOffset(); focusTargetCaret(); deleteTextSource(_te); focusSourceCaret(); int cur_offset = _se.getCaretModel().getOffset(); if (_config._needSelectTextAfterJump) { EditorUtils.selectTextRange(_se, cur_offset - _length, cur_offset); } } } private void deleteTextSource(Editor editor) { EditorUtils.selectRangeOf(_selectorClass, editor); EditorModificationUtil.deleteSelectedText(editor); } private void pasteClipboardToOffset() { focusSourceCaret(); TextRange[] tr = EditorCopyPasteHelperImpl.getInstance().pasteFromClipboard(_se); if (_config._needSelectTextAfterJump) { EditorUtils.selectTextRange(_se, tr); } _length = tr[0].getEndOffset() - tr[0].getStartOffset(); } }; AppUtil.runWriteAction(runnable, _se); }