| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2010, 2017 IBM Corporation and others. |
| 3 |
* |
| 4 |
* This program and the accompanying materials |
| 5 |
* are made available under the terms of the Eclipse Public License 2.0 |
| 6 |
* which accompanies this distribution, and is available at |
| 7 |
* https://www.eclipse.org/legal/epl-2.0/ |
| 8 |
* |
| 9 |
* SPDX-License-Identifier: EPL-2.0 |
| 10 |
* |
| 11 |
* Contributors: |
| 12 |
* IBM Corporation - initial API and implementation |
| 13 |
*******************************************************************************/ |
| 14 |
package org.eclipse.equinox.internal.p2.operations; |
| 15 |
|
| 16 |
import java.lang.reflect.InvocationTargetException; |
| 17 |
import org.eclipse.core.runtime.*; |
| 18 |
import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest; |
| 19 |
import org.eclipse.equinox.p2.engine.ProvisioningContext; |
| 20 |
import org.eclipse.equinox.p2.operations.ProvisioningSession; |
| 21 |
import org.eclipse.equinox.p2.operations.RemediationOperation; |
| 22 |
import org.eclipse.equinox.p2.repository.IRunnableWithProgress; |
| 23 |
|
| 24 |
public class RemediationResolutionJob extends PlannerResolutionJob { |
| 25 |
|
| 26 |
IRunnableWithProgress computeRemediationRunnable; |
| 27 |
RemediationOperation operation; |
| 28 |
ProfileChangeRequest[] requestHolder; |
| 29 |
|
| 30 |
public RemediationResolutionJob(String label, ProvisioningSession session, String profileId, ProfileChangeRequest request, ProvisioningContext context, IFailedStatusEvaluator evaluator, MultiStatus additionalStatus, IRunnableWithProgress computeRemediationRunnable, ProfileChangeRequest[] requestFromOperation, RemediationOperation operation) { |
| 31 |
super(label, session, profileId, request, context, evaluator, additionalStatus); |
| 32 |
this.computeRemediationRunnable = computeRemediationRunnable; |
| 33 |
this.operation = operation; |
| 34 |
this.requestHolder = requestFromOperation; |
| 35 |
} |
| 36 |
|
| 37 |
@Override |
| 38 |
public IStatus runModal(IProgressMonitor monitor) { |
| 39 |
SubMonitor sub = SubMonitor.convert(monitor, 2); |
| 40 |
try { |
| 41 |
computeRemediationRunnable.run(sub.newChild(1)); |
| 42 |
if (requestHolder.length > 0) |
| 43 |
this.request = requestHolder[0]; |
| 44 |
} catch (OperationCanceledException e) { |
| 45 |
return Status.CANCEL_STATUS; |
| 46 |
} catch (InvocationTargetException e) { |
| 47 |
// ignore, we don't actually throw this in the supplied runnable |
| 48 |
} |
| 49 |
if (request != null) |
| 50 |
return super.runModal(sub.newChild(1)); |
| 51 |
return operation.getResolutionResult(); |
| 52 |
} |
| 53 |
} |