1 11 package org.eclipse.update.internal.scheduler; 12 13 import org.eclipse.core.runtime.jobs.IJobChangeEvent; 14 import org.eclipse.core.runtime.jobs.JobChangeAdapter; 15 import org.eclipse.jface.dialogs.MessageDialog; 16 import org.eclipse.jface.wizard.WizardDialog; 17 import org.eclipse.swt.custom.BusyIndicator; 18 import org.eclipse.update.internal.ui.UpdateUI; 19 import org.eclipse.update.internal.ui.UpdateUIMessages; 20 import org.eclipse.update.internal.ui.wizards.InstallWizard; 21 import org.eclipse.update.internal.ui.wizards.InstallWizard2; 22 import org.eclipse.update.internal.ui.wizards.ResizableInstallWizardDialog; 23 24 class UpdateJobChangeAdapter extends JobChangeAdapter { 25 private SchedulerStartup startup; 26 27 public UpdateJobChangeAdapter(SchedulerStartup startup) { 28 this.startup = startup; 29 } 30 31 public void done(IJobChangeEvent event) { 32 if (event.getJob() == startup.getJob()) { 33 34 if (((AutomaticUpdateJob) startup.getJob()).getUpdates().length > 0 36 && !InstallWizard.isRunning()) { 37 if (UpdateSchedulerPlugin.getDefault().getPluginPreferences() 38 .getBoolean(UpdateSchedulerPlugin.P_DOWNLOAD)) { 39 UpdateUI.getStandardDisplay().asyncExec(new Runnable () { 40 public void run() { 41 asyncNotifyDownloadUser(); 42 startup.scheduleUpdateJob(); 43 } 44 }); 45 } else { 46 UpdateUI.getStandardDisplay().asyncExec(new Runnable () { 47 public void run() { 48 asyncNotifyUser(); 49 startup.scheduleUpdateJob(); 50 } 51 }); 52 } 53 } 54 } 55 } 56 57 private void asyncNotifyUser() { 58 UpdateUI.getStandardDisplay().beep(); 60 if (MessageDialog.openQuestion(UpdateUI.getActiveWorkbenchShell(), 61 UpdateUIMessages.AutomaticUpdatesJob_EclipseUpdates1, 62 UpdateUIMessages.AutomaticUpdatesJob_UpdatesAvailable)) { 63 BusyIndicator.showWhile(UpdateUI.getStandardDisplay(), 64 new Runnable () { 65 public void run() { 66 openInstallWizard2(); 67 } 68 }); 69 } 70 } 73 74 private void asyncNotifyDownloadUser() { 75 UpdateUI.getStandardDisplay().beep(); 77 if (MessageDialog.openQuestion(UpdateUI.getActiveWorkbenchShell(), 78 UpdateUIMessages.AutomaticUpdatesJob_EclipseUpdates2, 79 UpdateUIMessages.AutomaticUpdatesJob_UpdatesDownloaded)) { 80 BusyIndicator.showWhile(UpdateUI.getStandardDisplay(), 81 new Runnable () { 82 public void run() { 83 openInstallWizard2(); 84 } 85 }); 86 } else { 87 90 } 94 } 97 98 private void openInstallWizard2() { 99 if (InstallWizard.isRunning()) 100 return; 102 AutomaticUpdateJob ujob = (AutomaticUpdateJob) startup.getJob(); 103 InstallWizard2 wizard = new InstallWizard2(ujob.getSearchRequest(), 104 ujob.getUpdates(), true); 105 WizardDialog dialog = new ResizableInstallWizardDialog(UpdateUI 106 .getActiveWorkbenchShell(), wizard, 107 UpdateUIMessages.AutomaticUpdatesJob_Updates); 108 dialog.create(); 109 dialog.open(); 110 } 111 112 } 113 | Popular Tags |