You can create a new plug-in project and create such functionality for yourself. The IJobchangeListener of the Eclipse Jobs API is probably very interesting for you.
IJobChangeListener is an interface in which you can receive notifications for different types of job states.
I created a class called JobListener that adds an IJobChangeListener to the JobManager . With the SampleAction action SampleAction you can register or unregister the listener. this means that if the listener is registered and your application is minimized, you will be notified using MessageDialog (without a blinking taskbar).
I found a link where someone started their swing application. This function must be included in the public void done(final IJobChangeEvent event) method. I did not do this in my test class.
You can also get more information about Job with
event.getJob();
Here you can check the job name:
String jobName = event.getJob().getName();
The name of the task is read by a person, for example, “Garbage collection”, “Update for decoration”, “Construction workspace”, etc.
Class JobListener .
public class JobListener { private MyJobListener listener = null; private IWorkbenchWindow window = null; private boolean active = false; public JobListener(IWorkbenchWindow window) { this.window = window; } public void register() { listener = new MyJobListener(window); IJobManager jobMan = Job.getJobManager(); jobMan.addJobChangeListener(listener); active = true; } public void unregister() { IJobManager jobMan = Job.getJobManager(); jobMan.removeJobChangeListener(listener); active = false; } public boolean isActive() { return active; } class MyJobListener implements IJobChangeListener { private IWorkbenchWindow window; public MyJobListener(IWorkbenchWindow window) { this.window = window; } @Override public void sleeping(IJobChangeEvent event) { } @Override public void scheduled(IJobChangeEvent event) { } @Override public void running(IJobChangeEvent event) { } @Override public void done(final IJobChangeEvent event) { window.getShell().getDisplay().asyncExec(new Runnable() { @Override public void run() { if(window.getShell().getMinimized()) { MessageDialog.openInformation( window.getShell(), "Test", "Job " + event.getJob().getName() + " done."); } } }); } @Override public void awake(IJobChangeEvent event) { } @Override public void aboutToRun(IJobChangeEvent event) { System.out.println("About to run: " + event.getJob().getName()); } } }
I called this class from the SampleAction.java class
public class SampleAction implements IWorkbenchWindowActionDelegate { private IWorkbenchWindow window; private JobListener listener; public SampleAction() { } public void run(IAction action) { if(listener.isActive()) { listener.unregister(); MessageDialog.openInformation( window.getShell(), "Lrt", "Unregistered"); } else { listener.register(); MessageDialog.openInformation( window.getShell(), "Lrt", "Registered"); } } public void selectionChanged(IAction action, ISelection selection) { } public void dispose() { } public void init(IWorkbenchWindow window) { this.window = window; this.listener = new JobListener(window); }
You can start by developing the eclipse plugin by creating a new plugin project:
File > New > Project > Plugin Project
I used the Hello World project template to verify the code above.