Java 类com.intellij.ui.FileColorManager 实例源码

项目:ActiveTabHighlighterPlugin    文件:TabHighlighterFileEditorListener.java   
@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(project);

    final VirtualFile oldFile = fileEditorManagerEvent.getOldFile();
    final VirtualFile newFile = fileEditorManagerEvent.getNewFile();

    for (EditorWindow editorWindow : manager.getWindows()) {
        setUnfocusedTabWithColorManagerDefaultColor(fileColorManager, oldFile, editorWindow);

        setFocusedTabHighlighterColor(highlighterSettingsConfig, newFile, editorWindow);
    }
}
项目:ActiveTabHighlighterPlugin    文件:CustomEditorTabColorProvider.java   
@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(project);

    EditorWindow activeWindow = fileEditorManagerEx.getCurrentWindow();
    if (activeWindow != null) {
        final EditorWithProviderComposite selectedEditor = activeWindow.getSelectedEditor();

        if (selectedEditor != null && selectedEditor.getFile() != null && selectedEditor.getFile().equals(virtualFile)) {
            return highlighterSettingsConfig.buildHighlightColor();
        }
    }

    return fileColorManager.getFileColor(virtualFile);
}
项目:intellij-ce-playground    文件:FileColorsOptionsTopHitProvider.java   
@NotNull
@Override
public Collection<BooleanOptionDescription> getOptions(@Nullable Project project) {
  if (project != null) {
    FileColorManager manager = FileColorManager.getInstance(project);
    if (manager != null) {
      BooleanOptionDescription enabled = new Option(manager, "File Colors enabled", "isEnabled", "setEnabled");
      return !enabled.isOptionEnabled()
             ? Collections.singletonList(enabled)
             : Collections.unmodifiableCollection(Arrays.asList(
               enabled,
               new Option(manager, "Use File Colors in Editor Tabs", "isEnabledForTabs", "setEnabledForTabs"),
               new Option(manager, "Use File Colors in Project View", "isEnabledForProjectView", "setEnabledForProjectView")));
    }
  }
  return Collections.emptyList();
}
项目:intellij-ce-playground    文件:FileColorConfigurationEditDialog.java   
public FileColorConfigurationEditDialog(@NotNull final FileColorManager manager, @Nullable final FileColorConfiguration configuration) {
  super(true);

  setTitle(configuration == null ? "Add Color Label" : "Edit Color Label");
  setResizable(false);

  myManager = manager;
  myConfiguration = configuration;
  myColorSelectionComponent = new ColorSelectionComponent();
  myColorSelectionComponent.initDefault(manager, configuration == null ? null : configuration.getColorName());
  myColorSelectionComponent.setChangeListener(new ChangeListener() {
    @Override
    public void stateChanged(ChangeEvent e) {
      updateOKButton();
    }
  });

  init();
  updateCustomButton();
  if (myConfiguration != null && !StringUtil.isEmpty(myConfiguration.getScopeName())) {
    myScopeComboBox.setSelectedItem(myConfiguration.getScopeName());
  }
  updateOKButton();
}
项目:intellij-ce-playground    文件:ShowUsagesTableCellRenderer.java   
private Color getBackgroundColor(boolean isSelected, Usage usage) {
  Color fileBgColor = null;
  if (isSelected) {
    fileBgColor = UIUtil.getListSelectionBackground();
  }
  else {
    VirtualFile virtualFile = usage instanceof UsageInFile ? ((UsageInFile)usage).getFile() : null;
    if (virtualFile != null) {
      Project project = myUsageView.getProject();
      PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
      if (psiFile != null && psiFile.isValid()) {
        final Color color = FileColorManager.getInstance(project).getRendererBackground(psiFile);
        if (color != null) fileBgColor = color;
      }
    }
  }
  return fileBgColor;
}
项目:intellij-ce-playground    文件:NavigationItemListCellRenderer.java   
protected static Color getBackgroundColor(@Nullable Object value) {
  if (value instanceof PsiElement || value instanceof DataProvider) {
    final PsiElement psiElement = value instanceof PsiElement
                                  ? (PsiElement)value
                                  : CommonDataKeys.PSI_ELEMENT.getData((DataProvider) value);
    if (psiElement != null && psiElement.isValid()) {
      final FileColorManager fileColorManager = FileColorManager.getInstance(psiElement.getProject());
      final Color fileColor = fileColorManager.getRendererBackground(psiElement.getContainingFile());
      if (fileColor != null) {
        return fileColor;
      }
    }
  }

  return UIUtil.getListBackground();
}
项目:material-theme-jetbrains    文件:MTAddFileColorsAction.java   
private void addDisabledFileColors(Project project) {
  final FileColorManager manager = FileColorManager.getInstance(project);
  manager.addScopeColor(NonProjectFilesScope.NAME, MTOceanicTheme.DISABLED, false);
  manager.addScopeColor(NonProjectFilesScope.NAME, MTDarkerTheme.DISABLED, false);
  manager.addScopeColor(NonProjectFilesScope.NAME, MTLighterTheme.DISABLED, false);
  manager.addScopeColor(NonProjectFilesScope.NAME, MTPalenightTheme.DISABLED, false);

  Notify.show(project,
              "",
              MaterialThemeBundle.message("mt.fileColorsInstalled"),
              NotificationType.INFORMATION,
              new NotificationListener.Adapter() {
                @Override
                protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
                  ApplicationManager.getApplication().invokeLater(() -> ShowSettingsUtil.getInstance().showSettingsDialog(
                      project,
                      "File Colors"), ModalityState.NON_MODAL);
                }
              });
}
项目:tools-idea    文件:FileColorConfigurationEditDialog.java   
public FileColorConfigurationEditDialog(@NotNull final FileColorManager manager, @Nullable final FileColorConfiguration configuration) {
  super(true);

  setTitle(configuration == null ? "Add color label" : "Edit color label");
  setResizable(false);

  myManager = manager;
  myConfiguration = configuration;
  myColorSelectionComponent = new ColorSelectionComponent();
  myColorSelectionComponent.initDefault(manager, configuration == null ? null : configuration.getColorName());
  myColorSelectionComponent.setChangeListener(new ChangeListener() {
    @Override
    public void stateChanged(ChangeEvent e) {
      updateOKButton();
    }
  });

  init();
  updateCustomButton();
  if (myConfiguration != null && !StringUtil.isEmpty(myConfiguration.getScopeName())) {
    myScopeComboBox.setSelectedItem(myConfiguration.getScopeName());
  }
  updateOKButton();
}
项目:tools-idea    文件:ShowUsagesTableCellRenderer.java   
private Color getBackgroundColor(boolean isSelected, Usage usage) {
  Color fileBgColor = null;
  if (isSelected) {
    fileBgColor = UIUtil.getListSelectionBackground();
  }
  else {
    VirtualFile virtualFile = usage instanceof UsageInFile ? ((UsageInFile)usage).getFile() : null;
    if (virtualFile != null) {
      Project project = myUsageView.getProject();
      PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
      if (psiFile != null && psiFile.isValid()) {
        final Color color = FileColorManager.getInstance(project).getRendererBackground(psiFile);
        if (color != null) fileBgColor = color;
      }
    }
  }
  return fileBgColor;
}
项目:tools-idea    文件:NavigationItemListCellRenderer.java   
protected static Color getBackgroundColor(@Nullable Object value) {
  if (value instanceof PsiElement || value instanceof DataProvider) {
    final PsiElement psiElement = value instanceof PsiElement
                                  ? (PsiElement)value
                                  : LangDataKeys.PSI_ELEMENT.getData((DataProvider) value);
    if (psiElement != null) {
      final FileColorManager fileColorManager = FileColorManager.getInstance(psiElement.getProject());
      final Color fileColor = fileColorManager.getRendererBackground(psiElement.getContainingFile());
      if (fileColor != null) {
        return fileColor;
      }
    }
  }

  return UIUtil.getListBackground();
}
项目:dagger-intellij-plugin    文件:ShowUsagesTableCellRenderer.java   
private Color getBackgroundColor(boolean isSelected, Usage usage) {
  Color fileBgColor = null;
  if (isSelected) {
    fileBgColor = UIUtil.getListSelectionBackground();
  } else {
    VirtualFile virtualFile =
        usage instanceof UsageInFile ? ((UsageInFile) usage).getFile() : null;
    if (virtualFile != null) {
      Project project = myUsageView.getProject();
      PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
      if (psiFile != null && psiFile.isValid()) {
        final Color color = FileColorManager.getInstance(project).getRendererBackground(psiFile);
        if (color != null) fileBgColor = color;
      }
    }
  }
  return fileBgColor;
}
项目:consulo    文件:FileColorConfigurationEditDialog.java   
public FileColorConfigurationEditDialog(@Nonnull final FileColorManager manager, @Nullable final FileColorConfiguration configuration) {
  super(true);

  setTitle(configuration == null ? "Add color label" : "Edit color label");
  setResizable(false);

  myManager = manager;
  myConfiguration = configuration;

  init();
  updateCustomButton();
  if (myConfiguration != null && !StringUtil.isEmpty(myConfiguration.getScopeName())) {
    myScopeComboBox.setSelectedItem(myConfiguration.getScopeName());
  }
  updateOKButton();
}
项目:consulo    文件:ShowUsagesTableCellRenderer.java   
private Color getBackgroundColor(boolean isSelected, Usage usage) {
  Color fileBgColor = null;
  if (isSelected) {
    fileBgColor = UIUtil.getListSelectionBackground();
  }
  else {
    VirtualFile virtualFile = usage instanceof UsageInFile ? ((UsageInFile)usage).getFile() : null;
    if (virtualFile != null) {
      Project project = myUsageView.getProject();
      PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
      if (psiFile != null && psiFile.isValid()) {
        final Color color = FileColorManager.getInstance(project).getRendererBackground(psiFile);
        if (color != null) fileBgColor = color;
      }
    }
  }
  return fileBgColor;
}
项目:otto-intellij-plugin    文件:ShowUsagesTableCellRenderer.java   
private Color getBackgroundColor(boolean isSelected, Usage usage) {
  Color fileBgColor = null;
  if (isSelected) {
    fileBgColor = UIUtil.getListSelectionBackground();
  }
  else {
    VirtualFile virtualFile = usage instanceof UsageInFile ? ((UsageInFile)usage).getFile() : null;
    if (virtualFile != null) {
      Project project = myUsageView.getProject();
      PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
      if (psiFile != null && psiFile.isValid()) {
        final Color color = FileColorManager.getInstance(project).getRendererBackground(psiFile);
        if (color != null) fileBgColor = color;
      }
    }
  }
  return fileBgColor;
}
项目:intellij-ce-playground    文件:FileColorsConfigurable.java   
@Override
public JComponent createComponent() {
  if (myPanel == null) {
    myPanel = new FileColorsConfigurablePanel((FileColorManagerImpl) FileColorManager.getInstance(myProject));
  }

  return myPanel;
}
项目:intellij-ce-playground    文件:ColorSelectionComponent.java   
public void initDefault(@NotNull FileColorManager manager, @Nullable String selectedColorName) {
  for (String name : manager.getColorNames()) {
    addColorButton(name, ObjectUtils.assertNotNull(manager.getColor(name)));
  }
  addCustomColorButton();
  setSelectedColor(selectedColorName);
}
项目:intellij-ce-playground    文件:FileColorSettingsTable.java   
public FileColorSettingsTable(@NotNull final FileColorManager manager, @NotNull final List<FileColorConfiguration> configurations) {
  super(new ModelAdapter(manager, copy(configurations)));
  myManager = manager;
  setStriped(true);
  myOriginal = configurations;

  setAutoResizeMode(AUTO_RESIZE_LAST_COLUMN);

  final TableColumnModel columnModel = getColumnModel();
  final TableColumn nameColumn = columnModel.getColumn(NAME_COLUMN);
  nameColumn.setCellRenderer(new ScopeNameRenderer());

  final TableColumn colorColumn = columnModel.getColumn(COLOR_COLUMN);
  colorColumn.setCellRenderer(new ColorCellRenderer(manager));
}
项目:intellij-ce-playground    文件:ProjectViewTree.java   
@Nullable
public static <T> Color getColorForObject(T object, Project project, @NotNull Function<T, PsiElement> converter) {
  Color color = null;
  final PsiElement psi = converter.fun(object);
  if (psi != null) {
    if (!psi.isValid()) return null;

    final VirtualFile file = PsiUtilCore.getVirtualFile(psi);

    if (file != null) {
      color = FileColorManager.getInstance(project).getFileColor(file);
    } else if (psi instanceof PsiDirectory) {
      color = FileColorManager.getInstance(project).getFileColor(((PsiDirectory)psi).getVirtualFile());
    } else if (psi instanceof PsiDirectoryContainer) {
      final PsiDirectory[] dirs = ((PsiDirectoryContainer)psi).getDirectories();
      for (PsiDirectory dir : dirs) {
        Color c = FileColorManager.getInstance(project).getFileColor(dir.getVirtualFile());
        if (c != null && color == null) {
          color = c;
        } else if (c != null) {
          color = null;
          break;
        }
      }
    }
  }
  return color == null ? null : ColorUtil.softer(color);
}
项目:js-graphql-intellij-plugin    文件:JSGraphQLSchemaEditorTabColorProvider.java   
@Nullable
@Override
public Color getEditorTabColor(@NotNull Project project, @NotNull VirtualFile file) {
    if (JSGraphQLSchemaLanguageProjectService.isProjectSchemaFile(file)) {
        FileColorManager colorManager = FileColorManager.getInstance(project);
        if (colorManager.isEnabledForTabs()) {
            return colorManager.getScopeColor(NonProjectFilesScope.NAME);
        }
    }
    return null;
}
项目:material-theme-jetbrains    文件:MTEditorTabColor.java   
@Override
public Color getEditorTabColor(@NotNull final Project project, @NotNull final VirtualFile virtualFile) {
  final FileColorManager colorManager = FileColorManager.getInstance(project);
  if (colorManager.isEnabledForTabs()) {
    final Color fileColor = colorManager.getFileColor(virtualFile);
    return fileColor != null ? fileColor : getDefaultTabColor();
  }
  return getDefaultTabColor();
}
项目:material-theme-jetbrains    文件:MTScopeComponent.java   
/**
 * At start, check if Material Theme File Colors are added, otherwise add them
 * Note: If the scope has changed somehow (by changing the name or the color), it will add a duplicate.
 */
private void addDisabledFileColors() {
  final FileColorManager manager = FileColorManager.getInstance(myProject);
  manager.addScopeColor(NonProjectFilesScope.NAME, MTOceanicTheme.DISABLED, false);
  manager.addScopeColor(NonProjectFilesScope.NAME, MTDarkerTheme.DISABLED, false);
  manager.addScopeColor(NonProjectFilesScope.NAME, MTLighterTheme.DISABLED, false);
  manager.addScopeColor(NonProjectFilesScope.NAME, MTPalenightTheme.DISABLED, false);
}
项目:tools-idea    文件:FileColorsConfigurable.java   
@Override
public JComponent createComponent() {
  if (myPanel == null) {
    myPanel = new FileColorsConfigurablePanel((FileColorManagerImpl) FileColorManager.getInstance(myProject));
  }

  return myPanel;
}
项目:tools-idea    文件:ColorSelectionComponent.java   
public void initDefault(@NotNull FileColorManager manager, @Nullable String selectedColorName) {
  for (String name : manager.getColorNames()) {
    addColorButton(name, ObjectUtils.assertNotNull(manager.getColor(name)));
  }
  addCustomColorButton();
  setSelectedColor(selectedColorName);
}
项目:tools-idea    文件:FileColorSettingsTable.java   
public FileColorSettingsTable(@NotNull final FileColorManager manager, @NotNull final List<FileColorConfiguration> configurations) {
  super(new ModelAdapter(manager, copy(configurations)));
  myManager = manager;
  setStriped(true);
  myOriginal = configurations;

  setAutoResizeMode(AUTO_RESIZE_LAST_COLUMN);

  final TableColumnModel columnModel = getColumnModel();
  final TableColumn nameColumn = columnModel.getColumn(NAME_COLUMN);
  nameColumn.setCellRenderer(new ScopeNameRenderer());

  final TableColumn colorColumn = columnModel.getColumn(COLOR_COLUMN);
  colorColumn.setCellRenderer(new ColorCellRenderer(manager));
}
项目:tools-idea    文件:ProjectViewTree.java   
@Nullable
public static <T> Color getColorForObject(T object, Project project, @NotNull Function<T, PsiElement> converter) {
  Color color = null;
  final PsiElement psi = converter.fun(object);
  if (psi != null) {
    if (!psi.isValid()) return null;

    final VirtualFile file = PsiUtilCore.getVirtualFile(psi);

    if (file != null) {
      color = FileColorManager.getInstance(project).getFileColor(file);
    } else if (psi instanceof PsiDirectory) {
      color = FileColorManager.getInstance(project).getFileColor(((PsiDirectory)psi).getVirtualFile());
    } else if (psi instanceof PsiDirectoryContainer) {
      final PsiDirectory[] dirs = ((PsiDirectoryContainer)psi).getDirectories();
      for (PsiDirectory dir : dirs) {
        Color c = FileColorManager.getInstance(project).getFileColor(dir.getVirtualFile());
        if (c != null && color == null) {
          color = c;
        } else if (c != null) {
          color = null;
          break;
        }
      }
    }
  }
  return color == null ? null : ColorUtil.softer(color);
}
项目:consulo    文件:FileColorsConfigurable.java   
@Override
public JComponent createComponent() {
  if (myPanel == null) {
    myPanel = new FileColorsConfigurablePanel((FileColorManagerImpl) FileColorManager.getInstance(myProject));
  }

  return myPanel;
}
项目:consulo    文件:EditorTabColorProviderImpl.java   
@Override
@Nullable
public Color getEditorTabColor(Project project, VirtualFile file) {
  final FileColorManager colorManager = FileColorManagerImpl.getInstance(project);
  final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
  return psiFile != null && colorManager.isEnabledForTabs() ? colorManager.getFileColor(psiFile) : null;
}
项目:consulo    文件:FileColorSettingsTable.java   
public FileColorSettingsTable(@Nonnull final FileColorManager manager, @Nonnull final List<FileColorConfiguration> configurations) {
  super(new ModelAdapter(manager, copy(configurations)));
  myManager = manager;
  setStriped(true);
  myOriginal = configurations;

  setAutoResizeMode(AUTO_RESIZE_LAST_COLUMN);

  final TableColumnModel columnModel = getColumnModel();
  final TableColumn nameColumn = columnModel.getColumn(NAME_COLUMN);
  nameColumn.setCellRenderer(new ScopeNameRenderer());

  final TableColumn colorColumn = columnModel.getColumn(COLOR_COLUMN);
  colorColumn.setCellRenderer(new ColorCellRenderer(manager));
}
项目:consulo    文件:ProjectViewTree.java   
@Nullable
public static <T> Color getColorForObject(T object, Project project, @Nonnull Function<T, PsiElement> converter) {
  Color color = null;
  final PsiElement psi = converter.fun(object);
  if (psi != null) {
    if (!psi.isValid()) return null;

    final VirtualFile file = PsiUtilCore.getVirtualFile(psi);

    if (file != null) {
      color = FileColorManager.getInstance(project).getFileColor(file);
    }
    else if (psi instanceof PsiDirectory) {
      color = FileColorManager.getInstance(project).getFileColor(((PsiDirectory)psi).getVirtualFile());
    }
    else if (psi instanceof PsiDirectoryContainer) {
      final PsiDirectory[] dirs = ((PsiDirectoryContainer)psi).getDirectories();
      for (PsiDirectory dir : dirs) {
        Color c = FileColorManager.getInstance(project).getFileColor(dir.getVirtualFile());
        if (c != null && color == null) {
          color = c;
        }
        else if (c != null) {
          color = null;
          break;
        }
      }
    }
  }
  return color == null ? null : ColorUtil.softer(color);
}
项目:ActiveTabHighlighterPlugin    文件:TabHighlighterFileEditorListener.java   
private void setUnfocusedTabWithColorManagerDefaultColor(@NotNull FileColorManager fileColorManager, VirtualFile file, EditorWindow editorWindow) {
    if (null != file) {
        setTabColor(fileColorManager.getFileColor(file), file, editorWindow);
    }
}
项目:intellij-ce-playground    文件:XDebuggerFramesList.java   
public XDebuggerFrameListRenderer(Project project) {
  myColorsManager = FileColorManager.getInstance(project);
}
项目:intellij-ce-playground    文件:FileColorsOptionsTopHitProvider.java   
public Option(FileColorManager manager, String option, String getter, String setter) {
  super(option, "reference.settings.ide.settings.file-colors", getter, setter);
  myManager = manager;
}
项目:intellij-ce-playground    文件:EditorTabColorProviderImpl.java   
@Override
@Nullable
public Color getEditorTabColor(@NotNull Project project, @NotNull VirtualFile file) {
  FileColorManager colorManager = FileColorManager.getInstance(project);
  return colorManager.isEnabledForTabs() ? colorManager.getFileColor(file) : null;
}
项目:intellij-ce-playground    文件:FileColorProjectLevelConfigurationManager.java   
@Override
public Element getState() {
  return ((FileColorManagerImpl)FileColorManager.getInstance(myProject)).getState(true);
}
项目:intellij-ce-playground    文件:FileColorProjectLevelConfigurationManager.java   
@Override
public void loadState(Element state) {
  ((FileColorManagerImpl)FileColorManager.getInstance(myProject)).loadState(state, true);
}
项目:intellij-ce-playground    文件:FileColorSettingsTable.java   
private ModelAdapter(FileColorManager manager, final List<FileColorConfiguration> configurations) {
  myManager = manager;
  myConfigurations = configurations;
}
项目:intellij-ce-playground    文件:FileColorSettingsTable.java   
private ColorCellRenderer(final FileColorManager manager) {
  myManager = manager;
}
项目:tools-idea    文件:XDebuggerFramesList.java   
public XDebuggerFrameListRenderer(Project project) {
  myPsiManager = PsiManager.getInstance(project);
  myColorsManager = FileColorManager.getInstance(project);
}
项目:tools-idea    文件:EditorTabColorProviderImpl.java   
@Override
@Nullable
public Color getEditorTabColor(Project project, VirtualFile file) {
  FileColorManager colorManager = FileColorManager.getInstance(project);
  return colorManager.isEnabledForTabs() ? colorManager.getFileColor(file) : null;
}
项目:tools-idea    文件:FileColorSharedConfigurationManager.java   
@Override
public Element getState() {
  return ((FileColorManagerImpl)FileColorManager.getInstance(myProject)).getState(true);
}