Search in sources :

Example 21 with EditorEx

use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.

the class EditorTextField method setDocument.

public void setDocument(Document document) {
    if (myDocument != null) {
        uninstallDocumentListener(true);
    }
    myDocument = document;
    installDocumentListener();
    if (myEditor != null) {
        //MainWatchPanel watches the oldEditor's focus in order to remove debugger combobox when focus is lost
        //we should first transfer focus to new oldEditor and only then remove current oldEditor
        //MainWatchPanel check that oldEditor.getParent == newEditor.getParent and does not remove oldEditor in such cases
        boolean isFocused = isFocusOwner();
        EditorEx newEditor = createEditor();
        releaseEditor(myEditor);
        myEditor = newEditor;
        add(myEditor.getComponent(), BorderLayout.CENTER);
        validate();
        if (isFocused) {
            IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
                IdeFocusManager.getGlobalInstance().requestFocus(newEditor.getContentComponent(), true);
            });
        }
    }
}
Also used : EditorEx(com.intellij.openapi.editor.ex.EditorEx)

Example 22 with EditorEx

use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.

the class EditorTextField method releaseEditorLater.

void releaseEditorLater() {
    // releasing an editor implies removing it from a component hierarchy
    // invokeLater is required because releaseEditor() may be called from
    // removeNotify(), so we need to let swing complete its removeNotify() chain
    // and only then execute another removal from the hierarchy. Otherwise
    // swing goes nuts because of nested removals and indices get corrupted
    EditorEx editor = myEditor;
    ApplicationManager.getApplication().invokeLater(() -> releaseEditor(editor));
    myEditor = null;
}
Also used : EditorEx(com.intellij.openapi.editor.ex.EditorEx)

Example 23 with EditorEx

use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.

the class ComboboxEditorTextField method createEditor.

@Override
protected EditorEx createEditor() {
    final EditorEx result = super.createEditor();
    result.addFocusListener(new FocusChangeListener() {

        @Override
        public void focusGained(Editor editor) {
            repaintComboBox();
        }

        @Override
        public void focusLost(Editor editor) {
            repaintComboBox();
        }
    });
    return result;
}
Also used : EditorEx(com.intellij.openapi.editor.ex.EditorEx) Editor(com.intellij.openapi.editor.Editor) FixedComboBoxEditor(com.intellij.openapi.ui.FixedComboBoxEditor) FocusChangeListener(com.intellij.openapi.editor.ex.FocusChangeListener)

Example 24 with EditorEx

use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.

the class ApplyPatchChange method createOperation.

@Nullable
private MyGutterOperation createOperation(@NotNull OperationType type) {
    if (isResolved())
        return null;
    EditorEx editor = myViewer.getPatchEditor();
    Document document = editor.getDocument();
    int line = getPatchRange().start;
    int offset = line == DiffUtil.getLineCount(document) ? document.getTextLength() : document.getLineStartOffset(line);
    RangeHighlighter highlighter = editor.getMarkupModel().addRangeHighlighter(offset, offset, HighlighterLayer.ADDITIONAL_SYNTAX, null, HighlighterTargetArea.LINES_IN_RANGE);
    return new MyGutterOperation(highlighter, type);
}
Also used : RangeHighlighter(com.intellij.openapi.editor.markup.RangeHighlighter) EditorEx(com.intellij.openapi.editor.ex.EditorEx) Document(com.intellij.openapi.editor.Document) Nullable(org.jetbrains.annotations.Nullable)

Example 25 with EditorEx

use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.

the class ApplyPatchChange method createPatchHighlighters.

private void createPatchHighlighters() {
    EditorEx patchEditor = myViewer.getPatchEditor();
    myHighlighters.addAll(DiffDrawUtil.createUnifiedChunkHighlighters(patchEditor, myPatchDeletionRange, myPatchInsertionRange, myPatchInnerDifferences));
}
Also used : EditorEx(com.intellij.openapi.editor.ex.EditorEx)

Aggregations

EditorEx (com.intellij.openapi.editor.ex.EditorEx)164 EditorHighlighter (com.intellij.openapi.editor.highlighter.EditorHighlighter)36 Editor (com.intellij.openapi.editor.Editor)35 HighlighterIterator (com.intellij.openapi.editor.highlighter.HighlighterIterator)33 Document (com.intellij.openapi.editor.Document)29 NotNull (org.jetbrains.annotations.NotNull)26 IElementType (com.intellij.psi.tree.IElementType)14 Nullable (org.jetbrains.annotations.Nullable)13 Project (com.intellij.openapi.project.Project)12 PsiFile (com.intellij.psi.PsiFile)12 EditorFactory (com.intellij.openapi.editor.EditorFactory)11 VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 TextRange (com.intellij.openapi.util.TextRange)10 FileType (com.intellij.openapi.fileTypes.FileType)8 LogicalPosition (com.intellij.openapi.editor.LogicalPosition)7 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)7 BraceMatcher (com.intellij.codeInsight.highlighting.BraceMatcher)6 Language (com.intellij.lang.Language)6 CaretModel (com.intellij.openapi.editor.CaretModel)6 EditorGutterComponentEx (com.intellij.openapi.editor.ex.EditorGutterComponentEx)6