Search in sources :

Example 1 with ProvisioningJob

use of org.eclipse.equinox.p2.operations.ProvisioningJob in project portfolio by buchen.

the class UpdateHelper method runUpdateOperation.

private void runUpdateOperation(IProgressMonitor monitor) throws OperationCanceledException, CoreException {
    if (operation == null)
        checkForUpdates(monitor);
    ProvisioningJob job = operation.getProvisioningJob(null);
    IStatus status = job.runModal(monitor);
    if (status.getSeverity() == IStatus.CANCEL)
        throw new OperationCanceledException();
    if (status.getSeverity() != IStatus.OK)
        throw new CoreException(status);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) ProvisioningJob(org.eclipse.equinox.p2.operations.ProvisioningJob)

Example 2 with ProvisioningJob

use of org.eclipse.equinox.p2.operations.ProvisioningJob in project epp.mpc by eclipse.

the class MarketplaceWizard method performFinish.

@Override
public boolean performFinish() {
    if (profileChangeOperation != null && profileChangeOperation.getResolutionResult().getSeverity() != IStatus.ERROR) {
        if (computeMustCheckLicenseAcceptance()) {
            if (acceptLicensesPage != null && acceptLicensesPage.isPageComplete()) {
                acceptLicensesPage.performFinish();
            }
        }
        ProvisioningJob provisioningJob = profileChangeOperation.getProvisioningJob(null);
        if (provisioningJob != null) {
            if (!operationNewInstallItems.isEmpty()) {
                provisioningJob.addJobChangeListener(new ProvisioningJobListener(operationNewInstallItems));
            }
            ProvisioningUI.getDefaultUI().schedule(provisioningJob, StatusManager.SHOW | StatusManager.LOG);
            addedRepositoryLocations = null;
            return true;
        }
    }
    return false;
}
Also used : ProvisioningJob(org.eclipse.equinox.p2.operations.ProvisioningJob)

Example 3 with ProvisioningJob

use of org.eclipse.equinox.p2.operations.ProvisioningJob in project knime-core by knime.

the class KNIMEApplication method checkForUpdates.

private boolean checkForUpdates() {
    final IPreferenceStore prefStore = ProductPlugin.getDefault().getPreferenceStore();
    if (prefStore.getBoolean(JUSTUPDATED)) {
        prefStore.setValue(JUSTUPDATED, false);
        return false;
    }
    final ProvisioningUI provUI = ProvisioningUI.getDefaultUI();
    if (provUI.getRepositoryTracker() == null) {
        LogHelper.log(new Status(IStatus.WARNING, ProductPlugin.getDefault().getBundle().getSymbolicName(), "Updating is not possible of KNIME is started from " + "within the IDE."));
        return false;
    }
    final IProvisioningAgent agent = (IProvisioningAgent) ServiceHelper.getService(ProductPlugin.getDefault().getBundle().getBundleContext(), IProvisioningAgent.SERVICE_NAME);
    if (agent == null) {
        LogHelper.log(new Status(IStatus.ERROR, ProductPlugin.getDefault().getBundle().getSymbolicName(), "No provisioning agent found. This application is " + "not set up for updates."));
    }
    final MutableBoolean restart = new MutableBoolean(false);
    IRunnableWithProgress runnable = new IRunnableWithProgress() {

        @Override
        public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            ProvisioningSession session = new ProvisioningSession(agent);
            UpdateOperation operation = new UpdateOperation(session);
            SubMonitor sub = SubMonitor.convert(monitor, "Checking for application updates...", 200);
            IStatus status = operation.resolveModal(sub.newChild(100));
            if (status.getSeverity() == IStatus.CANCEL) {
                throw new OperationCanceledException();
            } else if (status.getSeverity() != IStatus.ERROR) {
                ProvisioningJob job = operation.getProvisioningJob(null);
                status = job.runModal(sub.newChild(100));
                if (status.getSeverity() == IStatus.CANCEL) {
                    throw new OperationCanceledException();
                }
                if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
                    // ok, just proceed
                    LogHelper.log(new Status(IStatus.INFO, ProductPlugin.getDefault().getBundle().getSymbolicName(), "No updates found."));
                } else if (status.getSeverity() != IStatus.ERROR) {
                    prefStore.setValue(JUSTUPDATED, true);
                    restart.setValue(true);
                } else {
                    LogHelper.log(status);
                }
            } else {
                LogHelper.log(status);
            }
        }
    };
    try {
        new ProgressMonitorDialog(null).run(true, true, runnable);
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
    }
    return restart.booleanValue();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ProvisioningSession(org.eclipse.equinox.p2.operations.ProvisioningSession) IStatus(org.eclipse.core.runtime.IStatus) IProvisioningAgent(org.eclipse.equinox.p2.core.IProvisioningAgent) MutableBoolean(org.knime.core.util.MutableBoolean) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) SubMonitor(org.eclipse.core.runtime.SubMonitor) ProvisioningJob(org.eclipse.equinox.p2.operations.ProvisioningJob) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProvisioningUI(org.eclipse.equinox.p2.ui.ProvisioningUI) UpdateOperation(org.eclipse.equinox.p2.operations.UpdateOperation) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Aggregations

ProvisioningJob (org.eclipse.equinox.p2.operations.ProvisioningJob)3 IStatus (org.eclipse.core.runtime.IStatus)2 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Status (org.eclipse.core.runtime.Status)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 IProvisioningAgent (org.eclipse.equinox.p2.core.IProvisioningAgent)1 ProvisioningSession (org.eclipse.equinox.p2.operations.ProvisioningSession)1 UpdateOperation (org.eclipse.equinox.p2.operations.UpdateOperation)1 ProvisioningUI (org.eclipse.equinox.p2.ui.ProvisioningUI)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 MutableBoolean (org.knime.core.util.MutableBoolean)1