void (final JComponent source, Transferable data, int action) { if (data == null) return; if (action == MOVE && !getEditor(source).isViewer() && getEditor(source).getDocument().isWritable()) { CommandProcessor.getInstance().executeCommand(((EditorImpl)getEditor(source)).myProject, new Runnable() { public void run() { ApplicationManager.getApplication().runWriteAction(new Runnable() { public void run() { Document doc = getEditor(source).getDocument(); doc.startGuardedBlockChecking(); try { doc.deleteString(myDraggedRange.getStartOffset(), myDraggedRange.getEndOffset()); } catch (ReadOnlyFragmentModificationException e) { EditorActionManager.getInstance().getReadonlyFragmentModificationHandler().handle(e); } finally { doc.stopGuardedBlockChecking(); } } }); } }, "Move selection", DND_COMMAND_KEY); } myDraggedRange = null; }