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

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

Introduction

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

Prototype

public abstract void addTopComponent(@NotNull final FileEditor editor, @NotNull final JComponent component);

Source Link

Document

Adds the specified component above the editor and paints a separator line below it.

Usage

From source file:com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl.java

License:Apache License

@Override
public void addFileLevelHighlight(@NotNull final Project project, final int group,
        @NotNull final HighlightInfo info, @NotNull final PsiFile psiFile) {
    VirtualFile vFile = psiFile.getViewProvider().getVirtualFile();
    final FileEditorManager manager = FileEditorManager.getInstance(project);
    for (FileEditor fileEditor : manager.getEditors(vFile)) {
        if (fileEditor instanceof TextEditor) {
            FileLevelIntentionComponent component = new FileLevelIntentionComponent(info.getDescription(),
                    info.getSeverity(), info.quickFixActionRanges, project, psiFile,
                    ((TextEditor) fileEditor).getEditor());
            manager.addTopComponent(fileEditor, component);
            List<HighlightInfo> fileLevelInfos = fileEditor.getUserData(FILE_LEVEL_HIGHLIGHTS);
            if (fileLevelInfos == null) {
                fileLevelInfos = new ArrayList<HighlightInfo>();
                fileEditor.putUserData(FILE_LEVEL_HIGHLIGHTS, fileLevelInfos);
            }//from   w w w. jav a2  s.com
            info.fileLevelComponent = component;
            info.setGroup(group);
            fileLevelInfos.add(info);
        }
    }
}

From source file:org.jetbrains.plugins.groovy.compiler.GroovyCompilerLoader.java

License:Apache License

private void decorateStubFile(final VirtualFile file, FileEditorManager fileEditorManager, FileEditor editor) {
    final EditorNotificationPanel panel = new EditorNotificationPanel();
    panel.setText("This stub is generated for Groovy class to make Groovy-Java cross-compilation possible");
    panel.createActionLabel("Go to the Groovy class", new Runnable() {
        @Override/*from  w w  w.j a  v  a2  s .  c  o  m*/
        public void run() {
            final PsiClass original = GroovycStubGenerator.findClassByStub(myProject, file);
            if (original != null) {
                original.navigate(true);
            }
        }
    });
    panel.createActionLabel("Exclude from stub generation", new Runnable() {
        @Override
        public void run() {
            final PsiClass psiClass = GroovycStubGenerator.findClassByStub(myProject, file);
            if (psiClass != null) {
                ExcludeFromStubGenerationAction.doExcludeFromStubGeneration(psiClass.getContainingFile());
            }
        }
    });
    fileEditorManager.addTopComponent(editor, panel);
}