Feb 4, 2008

How to automatically update my RCP Application?

Updating a RCP application might be different from updating Eclipse IDE. In Eclipse IDE, the update *usually* triggered by the user and he is allowed to select the updates he wants to install and cancel it at any time. But in RCP application, the situation might be different. You might have a requirement that you should be always running the latest version. In this case, the application update need not be triggered by the user, rather it can be triggered automatically during startup (like Gchat) and/or periodically by a job.

To enable such updates, you need to specify the update site in your feature:


In your Application's startup code, add this:

ProgressMonitorDialog dialog = new ProgressMonitorDialog(new Shell(display, SWT.NONE));
dialog.run(false, false, new IRunnableWithProgress() {

public void run(IProgressMonitor monitor) {
UpdateCommand command = new UpdateCommand("in.cypal.studio.wsdlEditor", "false");
command.run(monitor);
}
});

The comman.run() method returns a boolean value indicating whether an update happened or not. Depending on that you can decide whether to proceed normally or to force a restart by returning IApplication.EXIT_RESTART from the start method of your Application.

0 comments: