Search in sources :

Example 1 with TextComponentEditorImpl

use of com.intellij.openapi.editor.textarea.TextComponentEditorImpl in project intellij-community by JetBrains.

the class TextComponentEditorAction method getEditorFromContext.

@Nullable
public static Editor getEditorFromContext(@NotNull DataContext dataContext) {
    final Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
    if (editor != null)
        return editor;
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);
    final Object data = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext);
    if (data instanceof JTextComponent) {
        return new TextComponentEditorImpl(project, (JTextComponent) data);
    }
    if (data instanceof JComponent) {
        final JTextField field = findActiveSpeedSearchTextField((JComponent) data);
        if (field != null) {
            return new TextComponentEditorImpl(project, field);
        }
    }
    return null;
}
Also used : Project(com.intellij.openapi.project.Project) TextComponentEditorImpl(com.intellij.openapi.editor.textarea.TextComponentEditorImpl) JTextComponent(javax.swing.text.JTextComponent) Editor(com.intellij.openapi.editor.Editor) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Editor (com.intellij.openapi.editor.Editor)1 TextComponentEditorImpl (com.intellij.openapi.editor.textarea.TextComponentEditorImpl)1 Project (com.intellij.openapi.project.Project)1 JTextComponent (javax.swing.text.JTextComponent)1 Nullable (org.jetbrains.annotations.Nullable)1