Custom Coverage View

Hi All,

The default Java Coverage View displays 4 metrics (Class %, Method %, Line %, Branch %).
I would like to write a plugin that displays 2 different metrics, with a toggle button to switch between both views.

The plugin already contains a custom JavaCoverageEngine, so I can easily have a custom JavaCoverageViewExtension which overrides createExtraToolbarActions and adds a custom ToggleAction.

However, I have no clue how to actually refresh the UI in ToggleAction.setSelected so that the correct metrics get displayed based on whether the custom view or the default one is selected.

I have tried to override createColumnInfos in the custom JavaCoverageViewExtension to dynamically return the correct values, but as far as I understand, this method is called when CoverageView is created and never again.

I have tried to override getPercentage to return my metrics or the default ones, that kind of works, but the view has 4 columns even though my plugin would only display 2. Also, changing the name of the headers (e.g. from ‘Class %’ to ‘My Metrics’) is a pain.

I guess another approach would have been to work at the com.intellij.coverage.view.CoverageView/CoverageTableModel level but, not only is there no easy way to retrieve a reference to those 2 instances, but the classes are package private any way. Which is fine, those are probably implementation details that we should not use.

So, I’m stuck.
Did I miss something? Any pointer?

Thanks in advance.