com.intellij.ui.FileColorManager Java Examples

The following examples show how to use com.intellij.ui.FileColorManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShowUsagesTableCellRenderer.java    From dagger-intellij-plugin with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #2
Source File: FileColorConfigurationEditDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example #3
Source File: ShowUsagesTableCellRenderer.java    From consulo with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #4
Source File: ShowUsagesTableCellRenderer.java    From otto-intellij-plugin with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #5
Source File: FileColorsConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public JComponent createComponent() {
  if (myPanel == null) {
    myPanel = new FileColorsConfigurablePanel((FileColorManagerImpl) FileColorManager.getInstance(myProject));
  }

  return myPanel;
}
 
Example #6
Source File: FileColorSettingsTable.java    From consulo with Apache License 2.0 5 votes vote down vote up
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));
}
 
Example #7
Source File: DefaultSearchScopeProviders.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static GlobalSearchScope wrapNamedScope(@Nonnull Project project, @Nonnull NamedScope namedScope, boolean colored) {
  GlobalSearchScope scope = GlobalSearchScopesCore.filterScope(project, namedScope);
  if (!colored && !(namedScope instanceof WeighedItem)) return scope;
  int weight = namedScope instanceof WeighedItem ? ((WeighedItem)namedScope).getWeight() : -1;
  Color color = !colored ? null :
                //namedScope instanceof ColoredItem ? ((ColoredItem)namedScope).getColor() :
                FileColorManager.getInstance(project).getScopeColor(namedScope.getName());
  return new MyWeightedScope(scope, weight, color);
}
 
Example #8
Source File: XDebuggerFramesList.java    From consulo with Apache License 2.0 4 votes vote down vote up
public XDebuggerFrameListRenderer(@Nonnull Project project) {
  myColorsManager = FileColorManager.getInstance(project);
}
 
Example #9
Source File: EditorTabColorProviderImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nullable
public Color getEditorTabColor(Project project, VirtualFile file) {
  FileColorManager colorManager = FileColorManager.getInstance(project);
  return colorManager.isEnabledForTabs() ? colorManager.getFileColor(file) : null;
}
 
Example #10
Source File: EditorTabColorProviderImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public Color getProjectViewColor(@Nonnull Project project, @Nonnull VirtualFile file) {
  FileColorManager colorManager = FileColorManager.getInstance(project);
  return colorManager.isEnabledForProjectView() ? colorManager.getFileColor(file) : null;
}
 
Example #11
Source File: FileColorSharedConfigurationManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public Element getState() {
  return ((FileColorManagerImpl)FileColorManager.getInstance(myProject)).getState(true);
}
 
Example #12
Source File: FileColorSharedConfigurationManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void loadState(Element state) {
  ((FileColorManagerImpl)FileColorManager.getInstance(myProject)).loadState(state, true);
}
 
Example #13
Source File: FileColorSettingsTable.java    From consulo with Apache License 2.0 4 votes vote down vote up
private ModelAdapter(FileColorManager manager, final List<FileColorConfiguration> configurations) {
  myManager = manager;
  myConfigurations = configurations;
}
 
Example #14
Source File: FileColorSettingsTable.java    From consulo with Apache License 2.0 3 votes vote down vote up
private ColorCellRenderer(final FileColorManager manager) {
  setOpaque(true);

  myManager = manager;

  setIcon(EmptyIcon.ICON_16);
}