mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
make an additional requirement for editor paste handler more obvious for plugin developers (to avoid exceptions similar to EA-98045)
This commit is contained in:
+4
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,6 +22,9 @@ import com.intellij.util.Producer;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
|
||||
/**
|
||||
* {@link EditorActionHandler Handlers} for {@link com.intellij.openapi.actionSystem.IdeActions#ACTION_EDITOR_PASTE EditorPaste} action
|
||||
* should implement this interface (it's required for text drag-n-drop functionality in editor).
|
||||
*
|
||||
* @author pegov
|
||||
*/
|
||||
public interface EditorTextInsertHandler {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,9 +17,13 @@ package com.intellij.openapi.editor.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Caret;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorCopyPasteHelper;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorTextInsertHandler;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.util.Producer;
|
||||
@@ -31,12 +35,22 @@ import java.awt.datatransfer.Transferable;
|
||||
* @since May 13, 2002
|
||||
*/
|
||||
public class PasteAction extends TextComponentEditorAction {
|
||||
private static final Logger LOG = Logger.getInstance(PasteAction.class);
|
||||
|
||||
public static final DataKey<Producer<Transferable>> TRANSFERABLE_PROVIDER = DataKey.create("PasteTransferableProvider");
|
||||
|
||||
public PasteAction() {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Editor editor, Presentation presentation, DataContext dataContext) {
|
||||
if (!(getHandler() instanceof EditorTextInsertHandler)) {
|
||||
LOG.error("Handler for " + IdeActions.ACTION_EDITOR_PASTE +
|
||||
" action should implement com.intellij.openapi.editor.actionSystem.EditorTextInsertHandler");
|
||||
}
|
||||
}
|
||||
|
||||
private static class Handler extends BasePasteHandler {
|
||||
@Override
|
||||
public void executeWriteAction(Editor editor, Caret caret, DataContext dataContext) {
|
||||
|
||||
Reference in New Issue
Block a user