Search in sources :

Example 1 with UpdateHelper

use of name.abuchen.portfolio.ui.update.UpdateHelper in project portfolio by buchen.

the class StartupAddon method checkForUpdates.

@Inject
@Optional
public // NOSONAR
void checkForUpdates(// NOSONAR
@UIEventTopic(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE) Event event, final IWorkbench workbench, final EPartService partService, @Preference(value = UIConstants.Preferences.AUTO_UPDATE) boolean autoUpdate) {
    if (autoUpdate) {
        Job job = new Job(Messages.JobMsgCheckingForUpdates) {

            @Override
            protected IStatus run(IProgressMonitor monitor) {
                try {
                    monitor.beginTask(Messages.JobMsgCheckingForUpdates, 200);
                    UpdateHelper updateHelper = new UpdateHelper(workbench, partService);
                    updateHelper.runUpdate(monitor, true);
                } catch (// NOSONAR
                CoreException e) {
                    PortfolioPlugin.log(e.getStatus());
                }
                return Status.OK_STATUS;
            }
        };
        job.setSystem(true);
        job.schedule(500);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) UpdateHelper(name.abuchen.portfolio.ui.update.UpdateHelper) CoreException(org.eclipse.core.runtime.CoreException) Job(org.eclipse.core.runtime.jobs.Job) Inject(javax.inject.Inject) Optional(org.eclipse.e4.core.di.annotations.Optional)

Example 2 with UpdateHelper

use of name.abuchen.portfolio.ui.update.UpdateHelper in project portfolio by buchen.

the class UpdateHandler method execute.

@Execute
public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, final IWorkbench workbench, final EPartService partService) {
    try {
        new ProgressMonitorDialog(shell).run(true, true, monitor -> {
            try // NOSONAR
            {
                UpdateHelper updateHelper = new UpdateHelper(workbench, partService);
                updateHelper.runUpdate(monitor, false);
            } catch (CoreException e) {
                PortfolioPlugin.log(e);
                Display.getDefault().asyncExec(() -> ErrorDialog.openError(Display.getDefault().getActiveShell(), Messages.LabelError, Messages.MsgErrorUpdating, e.getStatus()));
            }
        });
    } catch (InvocationTargetException | InterruptedException e) {
        PortfolioPlugin.log(e);
    }
}
Also used : UpdateHelper(name.abuchen.portfolio.ui.update.UpdateHelper) CoreException(org.eclipse.core.runtime.CoreException) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) Execute(org.eclipse.e4.core.di.annotations.Execute)

Aggregations

UpdateHelper (name.abuchen.portfolio.ui.update.UpdateHelper)2 CoreException (org.eclipse.core.runtime.CoreException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Inject (javax.inject.Inject)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Job (org.eclipse.core.runtime.jobs.Job)1 Execute (org.eclipse.e4.core.di.annotations.Execute)1 Optional (org.eclipse.e4.core.di.annotations.Optional)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1