Showing posts with label Jobs. Show all posts
Showing posts with label Jobs. Show all posts

Tuesday, August 8, 2017

Showing progress dialog using Eclipse jobs API

Below piece of code shows how can we run the eclipse jobs interactively by showing eclipse progress dialog using Eclipse Jobs API.

Job installationJob = new Job("Creating a new creating catalog...")
{
@Override
public IStatus run(IProgressMonitor monitor)
{
try
{
monitor.beginTask("creating catalog...", 10);
//do your task here
}
finally
{

monitor.done();
}
return Status.OK_STATUS;
}
};

installationJob.setPriority(Job.INTERACTIVE);

//This is alternative to the installationJob.setUser(true);
//sometimes setUser(true) doesn't show up the progress dialog, in those cases below piece of code can be used.

PlatformUI.getWorkbench().getProgressService()
.showInDialog(Display.getDefault().getActiveShell(), installationJob);

installationJob.schedule();

Thursday, April 9, 2015

Eclipse Jobs framework best practice: Handling the long running background jobs while Eclipse shutdown

How to handle background jobs which are running silently for a long time during the Eclipse shutdown ?

Solution would be to cancel all the jobs before before plugin stops,so that jobs won't complain about the other resources availablity. If we don't do this, some times we can get some null pointer issues in the log.

In Plugin Activator class, just invoke Job.getJobManager().cancel(jobName);


import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.osgi.framework.BundleContext;

public abstract class AbstractJob extends Job
{

private String jobFamilyName;

public AbstractJob(String name, String jobFamilyName)
{
super(name);
this.jobFamilyName = jobFamilyName;
}

@Override
public boolean belongsTo(Object family)
{
return this.jobFamilyName.equals(family);
}
}

Your Actual Job Implementation:

Job coreJob = new AbstractJob("Collecting assets", "ASSETS_FAMILY")
{

@Override
protected IStatus run(IProgressMonitor monitor)
{
//TODO: some long work job

return Status.OK_STATUS;
}
};

coreJob.schedule();


In Activate Class:

public void stop(BundleContext context) throws Exception {
plugin = null;
Job.getJobManager().cancel("ASSETS_FAMILY");
super.stop(context);
}

This will cancel all the jobs who's family name is ASSETS_FAMILY.


Tuesday, July 16, 2013

Companies which are working on Eclipse related development

Companies which are working on Eclipse Plug-in development related work.

Hyderabad:
IBM ISL -Many products they have on Eclipse- Rational rose, myEclipse, OpenStack development
Kony Labs - KonyOne IDE
Pramati - Pramati servers which are based on OSGI
Progress Software - Many products which are based on Eclipse
ModelN - Enterprise modeling tools
Xilinx Inc - Embeded/chip modeling tools/Programmable logic development
Rockwell Collins - Aircraft solutions
Oracle
..very few!!!

Bangalore:
IBM ISL
SAP Labs - BO IDT, HANA Studio, BRM/BPM Tool
Mercedes Benz Research Lab
Robert Bosch
..many more!!!