mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Paste from X11 should only be enabled when pasting onto editor's editing area.
This commit is contained in:
@@ -5,13 +5,18 @@ import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorModificationUtil;
|
||||
import com.intellij.openapi.editor.event.EditorMouseEventArea;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.actionSystem.DataConstants;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.InputEvent;
|
||||
|
||||
/**
|
||||
* Author: msk
|
||||
@@ -22,8 +27,19 @@ public class PasteFromX11Action extends EditorAction {
|
||||
}
|
||||
|
||||
public void update(AnActionEvent e) {
|
||||
super.update(e);
|
||||
e.getPresentation().setEnabled(SystemInfo.isUnix);
|
||||
Presentation presentation = e.getPresentation();
|
||||
DataContext dataContext = e.getDataContext();
|
||||
Editor editor = (Editor) dataContext.getData(DataConstants.EDITOR);
|
||||
if (editor == null) {
|
||||
presentation.setEnabled(false);
|
||||
} else {
|
||||
boolean rightPlace = true;
|
||||
final InputEvent inputEvent = e.getInputEvent();
|
||||
if (inputEvent instanceof MouseEvent) {
|
||||
rightPlace = editor.getMouseEventArea((MouseEvent)inputEvent) == EditorMouseEventArea.EDITING_AREA;
|
||||
}
|
||||
presentation.setEnabled(SystemInfo.isUnix && rightPlace);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Handler extends EditorWriteActionHandler {
|
||||
|
||||
Reference in New Issue
Block a user