Example usage for com.intellij.openapi.fileEditor FileEditorManager getAllEditors

List of usage examples for com.intellij.openapi.fileEditor FileEditorManager getAllEditors

Introduction

In this page you can find the example usage for com.intellij.openapi.fileEditor FileEditorManager getAllEditors.

Prototype

public abstract FileEditor @NotNull [] getAllEditors();

Source Link

Usage

From source file:com.weebly.opus1269.smoothscroller.FileEditorListener.java

License:Open Source License

@Override
public void fileClosed(@NotNull FileEditorManager fileEditorManager, @NotNull VirtualFile virtualFile) {
    Set<FileEditor> destroyedEditors = new HashSet<FileEditor>(mListeners.keySet());

    // Remove all the editors that are still active from the set of destroyed editors.
    for (FileEditor editor : fileEditorManager.getAllEditors()) {
        if (destroyedEditors.contains(editor)) {
            destroyedEditors.remove(editor);
        }//from  w w w.ja v  a2s .c o  m
    }

    // Remove the wheel listener from all the destroyed editors.
    for (FileEditor fileEditor : destroyedEditors) {
        SmoothScrollerMouseWheelListener listener = mListeners.get(fileEditor);

        if (listener != null) {
            listener.stopAnimating();

            Editor editor = ((TextEditor) fileEditor).getEditor();
            editor.getContentComponent().removeMouseWheelListener(listener);
        }
    }
}

From source file:org.jetbrains.plugins.clojure.repl.LanguageConsoleImpl.java

License:Apache License

private void installEditorFactoryListener() {
    myProject.getMessageBus().connect(this).subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER,
            new FileEditorManagerAdapter() {
                @Override/*from  ww  w.j  av  a2  s. c  o m*/
                public void fileOpened(FileEditorManager source, VirtualFile file) {
                    if (file != myFile.getVirtualFile()) {
                        return;
                    }
                    if (myConsoleEditor != null) {
                        for (FileEditor fileEditor : source.getAllEditors()) {
                            if (!(fileEditor instanceof TextEditor)) {
                                continue;
                            }
                            final Editor editor = ((TextEditor) fileEditor).getEditor();
                            registerActionShortcuts(editor.getComponent());
                            editor.getContentComponent().addFocusListener(new FocusListener() {
                                public void focusGained(FocusEvent e) {
                                    myCurrentEditor = editor;
                                }

                                public void focusLost(FocusEvent e) {
                                }
                            });
                        }
                    }
                }

                @Override
                public void fileClosed(FileEditorManager source, VirtualFile file) {
                }
            });
}