How to set the Content to show Green Circle in Tool Window

Answered

How can I add the litlle green circle to the Content display name of a tool window?

I would like one just like Sync has in the Build tool window below.

content.setIcon(ExecutionUtil.getLiveIndicator(null));

does not seem to do anything. Additionally, content.setIcon(...) with any valid Icon also doesn't work. Thank you.

4 comments
Comment actions Permalink

Please show the code calling setIcon(). What IDE version are you using?

0
Comment actions Permalink

These are the methods I would like to implement. I am making sure that every content has a unique name. Please let me know if there is a better way.

public static void setContentActive(Project project, String contentName) {
getCpWindow(project).getContentManager().findContent(contentName).setIcon(PluginIcons.TOOL_WINDOW);
}

public static void setContentInactive(Project project, String contentName) {
getCpWindow(project).getContentManager().findContent(contentName).setIcon(null);
}

getCpWindow:

public static ToolWindow getCpWindow(Project project) {
return ToolWindowManager.getInstance(project).getToolWindow("CPWindow");
}

And here is the line from PluginIcons:

public interface PluginIcons {
Icon TOOL_WINDOW = IconLoader.getIcon("/icons/tool-window.png");
}

The TOOL_WINDOW (13 x 13) is just used as an example. I would like any way to indicate that a process is runnning in the content, either with an Icon or with the green circle under the name. Thanks

0
Avatar
Vassiliy Kudryashov
Comment actions Permalink

First of all, "green indicator" is additional layer for some base icon, so it cannot be added to the text directly. We still don't have API for showing icon for a certain content (tab of tool window), instead of it there is a piece of magic:

content.putUserData(ToolWindow.SHOW_CONTENT_ICON, Boolean.TRUE);
content.setIcon({baseIcon});

After that, you can manage icons like this:

content.setIcon(myLiveState ? ExecutionUtil.getLiveIndicator({baseIcon}) : {baseIcon});
1
Comment actions Permalink

Thank you so much Vassiliy, works like a charm!

0

Please sign in to leave a comment.