Search in sources :

Example 1 with FileColorManager

use of com.intellij.ui.FileColorManager in project ActiveTabHighlighterPlugin by tobszarny.

the class CustomEditorTabColorProvider method getEditorTabColor.

@Nullable
@Override
public Color getEditorTabColor(@NotNull Project project, @NotNull VirtualFile virtualFile) {
    final FileEditorManagerEx fileEditorManagerEx = FileEditorManagerEx.getInstanceEx(project);
    FileColorManager fileColorManager = FileColorManager.getInstance(project);
    HighlighterSettingsConfig highlighterSettingsConfig = HighlighterSettingsConfig.getInstance();
    if (highlighterSettingsConfig.isBackgroundColorUsed()) {
        EditorWindow activeWindow = fileEditorManagerEx.getCurrentWindow();
        if (activeWindow != null) {
            final EditorWithProviderComposite selectedEditor = activeWindow.getSelectedEditor();
            if (selectedEditor != null && selectedEditor.getFile() != null && selectedEditor.getFile().equals(virtualFile)) {
                return highlighterSettingsConfig.getBackgroundColor();
            }
        }
    }
    return fileColorManager.getFileColor(virtualFile);
}
Also used : EditorWithProviderComposite(com.intellij.openapi.fileEditor.impl.EditorWithProviderComposite) FileColorManager(com.intellij.ui.FileColorManager) FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx) EditorWindow(com.intellij.openapi.fileEditor.impl.EditorWindow) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with FileColorManager

use of com.intellij.ui.FileColorManager in project ActiveTabHighlighterPlugin by tobszarny.

the class TabHighlighterFileEditorListener method selectionChanged.

@Override
public void selectionChanged(@NotNull FileEditorManagerEvent fileEditorManagerEvent) {
    final Project project = fileEditorManagerEvent.getManager().getProject();
    final FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(project);
    final FileColorManager fileColorManager = FileColorManager.getInstance(project);
    final HighlighterSettingsConfig highlighterSettingsConfig = HighlighterSettingsConfig.getInstance();
    final VirtualFile oldFile = fileEditorManagerEvent.getOldFile();
    final VirtualFile newFile = fileEditorManagerEvent.getNewFile();
    for (EditorWindow editorWindow : manager.getWindows()) {
        setUnfocusedTabWithColorManagerDefaultColor(fileColorManager, oldFile, editorWindow);
        setFocusedTabHighlighterColor(highlighterSettingsConfig, newFile, editorWindow);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) FileColorManager(com.intellij.ui.FileColorManager) FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx) EditorWindow(com.intellij.openapi.fileEditor.impl.EditorWindow)

Aggregations

FileEditorManagerEx (com.intellij.openapi.fileEditor.ex.FileEditorManagerEx)2 EditorWindow (com.intellij.openapi.fileEditor.impl.EditorWindow)2 FileColorManager (com.intellij.ui.FileColorManager)2 EditorWithProviderComposite (com.intellij.openapi.fileEditor.impl.EditorWithProviderComposite)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 Nullable (org.jetbrains.annotations.Nullable)1