List of usage examples for com.intellij.openapi.fileEditor FileEditorManager getProject
@NotNull public abstract Project getProject();
From source file:com.atlassian.theplugin.idea.ui.linkhiglighter.FileEditorListenerImpl.java
License:Apache License
public void selectionChanged(final FileEditorManagerEvent event) { final FileEditorManager editorManager = event.getManager(); if (project != editorManager.getProject()) { assert false : this; return;//w ww. ja v a 2s . c o m } VirtualFile newFile = event.getNewFile(); VirtualFile oldFile = event.getOldFile(); if (oldFile != null && newFile == null) { removeHighlighter(oldFile); linkHighlighters.remove(oldFile); } else if (newFile != null && !linkHighlighters.containsKey(newFile)) { PsiFile psiFile = safeFindFile(newFile); if (psiFile != null) { Editor editor = editorManager.getSelectedTextEditor(); if (editor != null) { addHighlighter(newFile, psiFile, editor); } } } }
From source file:com.intellij.lang.jsgraphql.ide.project.JSGraphQLLanguageUIProjectService.java
License:Open Source License
private void insertEditorHeaderComponentIfApplicable(@NotNull FileEditorManager source, @NotNull VirtualFile file) {/* ww w .j a v a 2s . c o m*/ if (file.getFileType() == JSGraphQLFileType.INSTANCE || JSGraphQLFileType.isGraphQLScratchFile(source.getProject(), file)) { FileEditor fileEditor = source.getSelectedEditor(file); if (fileEditor instanceof TextEditor) { final Editor editor = ((TextEditor) fileEditor).getEditor(); if (editor.getHeaderComponent() instanceof JSGraphQLEditorHeaderComponent) { return; } UIUtil.invokeLaterIfNeeded(() -> { // ensure components are created on the swing thread final JComponent headerComponent = createHeaderComponent(fileEditor, editor); editor.setHeaderComponent(headerComponent); if (editor instanceof EditorEx) { ((EditorEx) editor).setPermanentHeaderComponent(headerComponent); } editor.getScrollingModel().scrollVertically(-1000); }); } } }
From source file:com.maddyhome.idea.vim.helper.EditorHelper.java
License:Open Source License
/** * Gets the editor for the virtual file within the editor manager. * * @param manager The file editor manager * @param file The virtual file get the editor for * @return The matching editor or null if no match was found *//*from w ww .ja va 2 s . c om*/ @Nullable public static Editor getEditor(@NotNull final FileEditorManager manager, @Nullable final VirtualFile file) { if (file == null) { return null; } final Document doc = FileDocumentManager.getInstance().getDocument(file); if (doc == null) { return null; } final Editor[] editors = EditorFactory.getInstance().getEditors(doc, manager.getProject()); if (editors.length > 0) { return editors[0]; } return null; }