donderdag 10 december 2009

Decorating your Jobs

Reinforcing your brand with every UI contact of your plugin is important in this competitive world. Many plugins launch Jobs when when Eclipse is starting up, to refresh their data, check the license, or whatever. Some Jobs display an icon to reveal the identity and reinforce the brand. Below is an example, showing two jobs that use text only and one with an icon.So how is this achieved?

step 1: register with Workbench ProgressService

An Eclipse Job can belong to a family, where a family can be any java Object. The ProgressService maintains a table of icons associated with each family. So step one is to register your icon and family in your Activator's start() method.
public void start(final BundleContext context) throws Exception {
Rebuilder rebuilder = new Rebuilder("Initializing My Tools");

step 2: override belongsTo() in your Job subclass

Next you override the method belongsTo() in your subclass with some simpel logic, calling super.belongsTo()when not equal top allow for Job class hierarchies.
public class Rebuilder extends Job {
public boolean belongsTo(final Object family) {
if (family.equals(MyTools.PLUGIN_ID)) {
return true;
return super.belongsTo(family);


As always in Eclipse programming this solution took a long time to find, but can be implemented in a few lines of code once you know how.


What remains is that you can only do this for Jobs that you launch yourself, and not for other background tasks like the Auto Build jobs that call your Builders.
They all share the same icon :-(
I have created a bug for this, please support and vote here.