Automatic Update [message #459827] |
Thu, 07 December 2006 07:53  |
Eclipse User |
|
|
|
Hi, I've developed an RCP application that updates automatically from a
remote site. To do this, the user has to click a button, and then go through
some wizard steps to install and restart the application. I'm trying to do
that the user click on that button but avoid the update wizard, to be
completely automatic. Can somebody help me with this?
|
|
|
|
|
Re: Automatic Update [message #460045 is a reply to message #459827] |
Tue, 12 December 2006 07:51   |
Eclipse User |
|
|
|
Originally posted by: vconesa.hotmail.com
I've used this code to implement my own update action, I hope it will be
useful to you:
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
try {
ISite rs = SiteManager.getSite(new URL(
"http://192.168.1.5/EVC"), monitor);
IFeatureReference[] frs = rs.getFeatureReferences();
ILocalSite ls = SiteManager.getLocalSite();
IConfiguredSite ics = ls.getCurrentConfiguration()
.getConfiguredSites()[0];
IFeatureReference[] lfrs = ics.getConfiguredFeatures();
List installOps = new ArrayList();
for (int i = 0; i < frs.length; i++) {
for (int j = 0; j < lfrs.length; j++) {
if (frs[i].getVersionedIdentifier().getIdentifier()
.equals(
lfrs[j].getVersionedIdentifier()
.getIdentifier())) {
if (frs[i]
.getVersionedIdentifier()
.getVersion()
.isGreaterThan(
lfrs[j]
.getVersionedIdentifier()
.getVersion())) {
installOps.add(OperationsManager
.getOperationFactory()
.createInstallOperation(ics,
frs[i].getFeature(monitor),
null, null, null));
}
}
}
}
if (installOps.size() > 0) {
for (Iterator iter = installOps.iterator(); iter
.hasNext();) {
IInstallFeatureOperation op = (IInstallFeatureOperation) iter
.next();
op.execute(monitor, null);
}
ls.save();
MessageBox exception = new MessageBox(
getWindowConfigurer().getWindow().getShell(),
SWT.OK);
exception
.setMessage("The application will be restarted");
exception.open();
getWindowConfigurer().getWindow().getWorkbench()
.restart();
} else {
monitor.setTaskName("No updates pending.");
Thread.sleep(2000);
}
} catch (MalformedURLException e) {
/*
* MessageBox exception = new
* MessageBox(getWindowConfigurer().getWindow().getShell(),
* SWT.OK); exception.setMessage("Internal error: please
* check the logs file");
*/
EVCConstants.log.error(this, e);
e.printStackTrace();
// exception.open();
} catch (CoreException e) {
/*
* MessageBox exception = new
* MessageBox(getWindowConfigurer().getWindow().getShell(),
* SWT.OK); exception.setMessage("Internal error: please
* check the logs file");
*/
EVCConstants.log.error(this, e);
e.printStackTrace();
// exception.open();
} catch (Exception e) {
EVCConstants.log.error(this, e);
e.printStackTrace();
}
}
};
ProgressMonitorDialog pmd = new ProgressMonitorDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
try {
pmd.run(true, true, op);
"Jos
|
|
|
|
Powered by
FUDForum. Page generated in 0.03533 seconds