I believe the headers use icons, not sure if you can use text. You could add an entry to the context (popup) menu which will display the number of traces and when the item is clicked launch your view.
I based this off of the Hello, World Command template that comes with Eclipse, and added a menu contribution.
I extended CompoundContributionItem to act as the menu contribution as follows.
/**
* Menu contribution which will update it's label to show the number of current
* traces.
*/
public class TraceWindowContributionItem extends CompoundContributionItem {
private static int demoTraceCount = 0;
/**
* Implemented to create a label which displays the number of traces.
*/
@Override
protected IContributionItem[] getContributionItems() {
//Here is your dynamic label.
final String label = getTraceCount() + " traces";
//Create other items needed for creation of contribution.
final String id = "test.dynamicContribution";
final IServiceLocator serviceLocator = findServiceLocator();
final String commandId = "test.commands.sampleCommand";
final Map parameters = new HashMap();
//Here is the contribution which will be displayed in the menu.
final CommandContributionItem contribution = new CommandContributionItem(
serviceLocator, id, commandId, parameters, null, null, null,
label, null, null, SWT.NONE);
return new IContributionItem[] { contribution };
}
/**
* Demo method simply increments by 1 each time the popup is shown. Your
* code would store or query for the actual trace count each time.
* @return
*/
private int getTraceCount() {
return demoTraceCount++;
}
/**
* Find the service locator to give to the contribution.
*/
private IServiceLocator findServiceLocator() {
return PlatformUI.getWorkbench().getActiveWorkbenchWindow();
}
}
Now we need to wire this into the command and handler that will launch your view.
Here is my plugin.xml.
<!-- Wire up our dynamic menu contribution which will show the number of traces -->
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:org.eclipse.ui.popup.any?after=additions">
<dynamic
class="test.TraceWindowContributionItem"
id="test.dynamicContribution">
</dynamic>
</menuContribution>
</extension>
<!-- Command and handler for launching the traces view -->
<extension
point="org.eclipse.ui.commands">
<category
name="Sample Category"
id="test.commands.category">
</category>
<command
categoryId="test.commands.category"
defaultHandler="test.handlers.SampleHandler"
id="test.commands.sampleCommand"
name="Sample Command">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
commandId="test.commands.sampleCommand"
class="test.handlers.SampleHandler">
</handler>
</extension>