Search code examples
intellij-ideaintellij-plugin

Intellij Plugin - How to color project view files background?


enter image description here

As seen in the picture. Color Notification is colored. This is done by creating a scope and adding that file in that scope.

However I want to mark files according to my need. For example I will click that color notification and mark that file green or yellow.

I only need to know how I can reach this project view and alter background color programmatically.

I know there arent so many intellij plugin creators but still I will try my luck.

From my investigation there are FileColorManager, ProjectView, UIManager etc but I couldnt find which one is responsible for these color handling changes...


Solution

  • Just a guess. Have you tried to implement the com.intellij.ide.projectView.ProjectViewNodeDecorator extension point? It seems like this lets you decorate the nodes in the project view.

    As we found out, setting the background-color is not easily possible. But you can add a string (like a checkmark) at the end of each node that you want to highlight. Here is an example:

    public class ProvectViewColorer implements ProjectViewNodeDecorator {
    
      @Override
      public void decorate(ProjectViewNode node, PresentationData data) {
        final VirtualFile virtualFile = node.getVirtualFile();
        if (virtualFile != null && virtualFile.getFileType().equals(MathematicaFileType.INSTANCE)) {
          data.setLocationString("✓");
        }
      }
    
      @Override
      public void decorate(PackageDependenciesNode node, ColoredTreeCellRenderer cellRenderer) {
    
      }
    }
    

    img