Search in sources :

Example 46 with FileEditor

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

the class FindUtil method searchAgain.

public static boolean searchAgain(Project project, FileEditor fileEditor, @Nullable DataContext context) {
    if (!(fileEditor instanceof TextEditor))
        return false;
    TextEditor textEditor = (TextEditor) fileEditor;
    Editor editor = textEditor.getEditor();
    return searchAgain(project, editor, context);
}
Also used : TextEditor(com.intellij.openapi.fileEditor.TextEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) FileEditor(com.intellij.openapi.fileEditor.FileEditor)

Example 47 with FileEditor

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

the class SearchAgainAction method actionPerformed.

@Override
public void actionPerformed(final AnActionEvent e) {
    final Project project = e.getData(CommonDataKeys.PROJECT);
    final FileEditor editor = e.getData(PlatformDataKeys.FILE_EDITOR);
    if (editor == null || project == null)
        return;
    CommandProcessor commandProcessor = CommandProcessor.getInstance();
    commandProcessor.executeCommand(project, () -> {
        PsiDocumentManager.getInstance(project).commitAllDocuments();
        IdeDocumentHistory.getInstance(project).includeCurrentCommandAsNavigation();
        FindManager findManager = FindManager.getInstance(project);
        if (!findManager.selectNextOccurrenceWasPerformed() && findManager.findNextUsageInEditor(editor)) {
            return;
        }
        FindUtil.searchAgain(project, editor, e.getDataContext());
    }, IdeBundle.message("command.find.next"), null);
}
Also used : Project(com.intellij.openapi.project.Project) FileEditor(com.intellij.openapi.fileEditor.FileEditor) FindManager(com.intellij.find.FindManager) CommandProcessor(com.intellij.openapi.command.CommandProcessor)

Example 48 with FileEditor

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

the class SearchAgainAction method update.

@Override
public void update(AnActionEvent event) {
    Presentation presentation = event.getPresentation();
    Project project = event.getData(CommonDataKeys.PROJECT);
    if (project == null) {
        presentation.setEnabled(false);
        return;
    }
    FileEditor editor = event.getData(PlatformDataKeys.FILE_EDITOR);
    presentation.setEnabled(editor instanceof TextEditor);
}
Also used : Project(com.intellij.openapi.project.Project) FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor)

Example 49 with FileEditor

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

the class DetectedIndentOptionsNotificationProvider method updateIndentNotification.

public static void updateIndentNotification(@NotNull PsiFile file, boolean enforce) {
    VirtualFile vFile = file.getVirtualFile();
    if (vFile == null)
        return;
    if (!ApplicationManager.getApplication().isHeadlessEnvironment() || ApplicationManager.getApplication().isUnitTestMode() && myShowNotificationInTest) {
        Project project = file.getProject();
        FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
        if (fileEditorManager == null)
            return;
        FileEditor fileEditor = fileEditorManager.getSelectedEditor(vFile);
        if (fileEditor != null) {
            Boolean notifiedFlag = fileEditor.getUserData(NOTIFIED_FLAG);
            if (notifiedFlag == null || enforce) {
                fileEditor.putUserData(NOTIFIED_FLAG, Boolean.TRUE);
                EditorNotifications.getInstance(project).updateNotifications(vFile);
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) FileEditor(com.intellij.openapi.fileEditor.FileEditor)

Example 50 with FileEditor

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

the class WolfTheProblemSolverImpl method willBeHighlightedAnyway.

private boolean willBeHighlightedAnyway(final VirtualFile file) {
    // opened in some editor, and hence will be highlighted automatically sometime later
    FileEditor[] selectedEditors = FileEditorManager.getInstance(myProject).getSelectedEditors();
    for (FileEditor editor : selectedEditors) {
        if (!(editor instanceof TextEditor))
            continue;
        Document document = ((TextEditor) editor).getEditor().getDocument();
        PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getCachedPsiFile(document);
        if (psiFile == null)
            continue;
        if (Comparing.equal(file, psiFile.getVirtualFile()))
            return true;
    }
    return false;
}
Also used : FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) Document(com.intellij.openapi.editor.Document)

Aggregations

FileEditor (com.intellij.openapi.fileEditor.FileEditor)140 TextEditor (com.intellij.openapi.fileEditor.TextEditor)54 VirtualFile (com.intellij.openapi.vfs.VirtualFile)53 Editor (com.intellij.openapi.editor.Editor)41 Project (com.intellij.openapi.project.Project)34 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)27 DataContext (com.intellij.openapi.actionSystem.DataContext)20 Nullable (org.jetbrains.annotations.Nullable)19 PsiFile (com.intellij.psi.PsiFile)16 Document (com.intellij.openapi.editor.Document)14 IpnbFileEditor (org.jetbrains.plugins.ipnb.editor.IpnbFileEditor)14 NotNull (org.jetbrains.annotations.NotNull)13 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)9 IpnbFilePanel (org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel)8 StructureViewBuilder (com.intellij.ide.structureView.StructureViewBuilder)6 StructureViewComponent (com.intellij.ide.structureView.newStructureView.StructureViewComponent)6 StructureViewComposite (com.intellij.ide.structureView.impl.StructureViewComposite)5 FileEditorManagerEx (com.intellij.openapi.fileEditor.ex.FileEditorManagerEx)5 PsiElement (com.intellij.psi.PsiElement)5 List (java.util.List)5