Search in sources :

Example 56 with TextEditor

use of com.intellij.openapi.fileEditor.TextEditor in project intellij-community by JetBrains.

the class DaemonRespondToChangesTest method testCodeFoldingInSplittedWindowAppliesToAllEditors.

public void testCodeFoldingInSplittedWindowAppliesToAllEditors() throws Exception {
    final Set<Editor> applied = new THashSet<>();
    final Set<Editor> collected = new THashSet<>();
    registerFakePass(applied, collected);
    configureByText(PlainTextFileType.INSTANCE, "");
    Editor editor1 = getEditor();
    final Editor editor2 = EditorFactory.getInstance().createEditor(editor1.getDocument(), getProject());
    Disposer.register(getProject(), () -> EditorFactory.getInstance().releaseEditor(editor2));
    TextEditor textEditor1 = new PsiAwareTextEditorProvider().getTextEditor(editor1);
    TextEditor textEditor2 = new PsiAwareTextEditorProvider().getTextEditor(editor2);
    List<HighlightInfo> errors = myDaemonCodeAnalyzer.runPasses(myFile, editor1.getDocument(), Arrays.asList(textEditor1, textEditor2), new int[0], false, null);
    assertEmpty(errors);
    assertEquals(collected, ContainerUtil.newHashSet(editor1, editor2));
    assertEquals(applied, ContainerUtil.newHashSet(editor1, editor2));
}
Also used : PsiAwareTextEditorProvider(com.intellij.openapi.fileEditor.impl.text.PsiAwareTextEditorProvider) TextEditor(com.intellij.openapi.fileEditor.TextEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) THashSet(gnu.trove.THashSet)

Example 57 with TextEditor

use of com.intellij.openapi.fileEditor.TextEditor in project intellij-community by JetBrains.

the class JvmSmartStepIntoHandler method handleTargets.

protected final boolean handleTargets(SourcePosition position, DebuggerSession session, TextEditor fileEditor, List<SmartStepTarget> targets) {
    if (!targets.isEmpty()) {
        SmartStepTarget firstTarget = targets.get(0);
        if (targets.size() == 1) {
            doStepInto(session, Registry.is("debugger.single.smart.step.force"), firstTarget);
        } else {
            Editor editor = fileEditor.getEditor();
            PsiMethodListPopupStep popupStep = new PsiMethodListPopupStep(editor, targets, chosenTarget -> doStepInto(session, true, chosenTarget));
            ListPopupImpl popup = new ListPopupImpl(popupStep);
            DebuggerUIUtil.registerExtraHandleShortcuts(popup, XDebuggerActions.STEP_INTO, XDebuggerActions.SMART_STEP_INTO);
            popup.setAdText(DebuggerUIUtil.getSelectionShortcutsAdText(XDebuggerActions.STEP_INTO, XDebuggerActions.SMART_STEP_INTO));
            UIUtil.maybeInstall(popup.getList().getInputMap(JComponent.WHEN_FOCUSED), "selectNextRow", KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
            popup.addListSelectionListener(new ListSelectionListener() {

                public void valueChanged(ListSelectionEvent e) {
                    popupStep.getScopeHighlighter().dropHighlight();
                    if (!e.getValueIsAdjusting()) {
                        final SmartStepTarget selectedTarget = (SmartStepTarget) ((JBList) e.getSource()).getSelectedValue();
                        if (selectedTarget != null) {
                            highlightTarget(popupStep, selectedTarget);
                        }
                    }
                }
            });
            highlightTarget(popupStep, firstTarget);
            DebuggerUIUtil.showPopupForEditorLine(popup, editor, position.getLine());
        }
        return true;
    }
    return false;
}
Also used : ListPopupImpl(com.intellij.ui.popup.list.ListPopupImpl) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JBList(com.intellij.ui.components.JBList) Editor(com.intellij.openapi.editor.Editor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) ListSelectionListener(javax.swing.event.ListSelectionListener)

Example 58 with TextEditor

use of com.intellij.openapi.fileEditor.TextEditor in project intellij-community by JetBrains.

the class GroovyConsoleRootType method fileOpened.

@Override
public void fileOpened(@NotNull final VirtualFile file, @NotNull FileEditorManager source) {
    final Project project = source.getProject();
    final GroovyConsoleStateService projectConsole = GroovyConsoleStateService.getInstance(project);
    for (FileEditor fileEditor : source.getAllEditors(file)) {
        if (!(fileEditor instanceof TextEditor))
            continue;
        final Editor editor = ((TextEditor) fileEditor).getEditor();
        final JPanel panel = new EditorHeaderComponent();
        final DefaultActionGroup actionGroup = new DefaultActionGroup(EXECUTE_ACTION, new GrSelectModuleAction(projectConsole, file));
        final ActionToolbar menu = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actionGroup, true);
        panel.add(menu.getComponent());
        editor.setHeaderComponent(panel);
        EXECUTE_ACTION.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, editor.getComponent());
    }
}
Also used : GrSelectModuleAction(org.jetbrains.plugins.groovy.console.actions.GrSelectModuleAction) Project(com.intellij.openapi.project.Project) FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) EditorHeaderComponent(com.intellij.openapi.editor.impl.EditorHeaderComponent) Editor(com.intellij.openapi.editor.Editor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor)

Example 59 with TextEditor

use of com.intellij.openapi.fileEditor.TextEditor in project intellij-community by JetBrains.

the class MvcProjectViewPane method scrollFromSource.

public void scrollFromSource() {
    FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject);
    Editor selectedTextEditor = fileEditorManager.getSelectedTextEditor();
    if (selectedTextEditor != null) {
        selectElementAtCaret(selectedTextEditor, false);
        return;
    }
    final FileEditor[] editors = fileEditorManager.getSelectedEditors();
    for (FileEditor fileEditor : editors) {
        if (fileEditor instanceof TextEditor) {
            Editor editor = ((TextEditor) fileEditor).getEditor();
            selectElementAtCaret(editor, false);
            return;
        }
    }
    final VirtualFile[] selectedFiles = fileEditorManager.getSelectedFiles();
    if (selectedFiles.length > 0) {
        PsiFile file = PsiManager.getInstance(myProject).findFile(selectedFiles[0]);
        selectFile(file, false);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) Editor(com.intellij.openapi.editor.Editor) FileEditor(com.intellij.openapi.fileEditor.FileEditor)

Example 60 with TextEditor

use of com.intellij.openapi.fileEditor.TextEditor in project intellij-community by JetBrains.

the class AnnotateRevisionAction method getEditor.

@Nullable
@Override
protected Editor getEditor(@NotNull AnActionEvent e) {
    Project project = e.getProject();
    if (project == null)
        return null;
    FilePath filePath = e.getData(VcsDataKeys.FILE_PATH);
    if (filePath == null)
        return null;
    VirtualFile virtualFile = filePath.getVirtualFile();
    if (virtualFile == null)
        return null;
    Editor editor = e.getData(CommonDataKeys.EDITOR);
    if (editor != null) {
        VirtualFile editorFile = FileDocumentManager.getInstance().getFile(editor.getDocument());
        if (Comparing.equal(editorFile, virtualFile))
            return editor;
    }
    FileEditor fileEditor = FileEditorManager.getInstance(project).getSelectedEditor(virtualFile);
    if (fileEditor instanceof TextEditor) {
        return ((TextEditor) fileEditor).getEditor();
    }
    return null;
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) Editor(com.intellij.openapi.editor.Editor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

TextEditor (com.intellij.openapi.fileEditor.TextEditor)75 FileEditor (com.intellij.openapi.fileEditor.FileEditor)52 Editor (com.intellij.openapi.editor.Editor)29 VirtualFile (com.intellij.openapi.vfs.VirtualFile)23 Project (com.intellij.openapi.project.Project)20 Document (com.intellij.openapi.editor.Document)13 Nullable (org.jetbrains.annotations.Nullable)12 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)11 PsiFile (com.intellij.psi.PsiFile)8 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)6 NotNull (org.jetbrains.annotations.NotNull)6 Disposable (com.intellij.openapi.Disposable)3 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)3 EditorNotificationPanel (com.intellij.ui.EditorNotificationPanel)3 LightweightHint (com.intellij.ui.LightweightHint)3 NonNls (org.jetbrains.annotations.NonNls)3 HighlightingPass (com.intellij.codeHighlighting.HighlightingPass)2 TextEditorHighlightingPass (com.intellij.codeHighlighting.TextEditorHighlightingPass)2 TemplateBuilder (com.intellij.codeInsight.template.TemplateBuilder)2 UndoManager (com.intellij.openapi.command.undo.UndoManager)2