/* (non-Javadoc) * @see com.siteview.mde.internal.core.target.impl.AbstractBundleContainer#resolveBundles(com.siteview.mde.internal.core.target.provisional.ITargetDefinition, org.eclipse.core.runtime.IProgressMonitor) */ protected IResolvedBundle[] resolveBundles(ITargetDefinition definition, IProgressMonitor monitor) throws CoreException { File dir = getDirectory(); if (dir.isDirectory()) { File site = getSite(dir); File[] files = site.listFiles(); SubMonitor localMonitor = SubMonitor.convert(monitor, Messages.DirectoryBundleContainer_0, files.length); List bundles = new ArrayList(files.length); for (int i = 0; i < files.length; i++) { if (localMonitor.isCanceled()) { return new IResolvedBundle[0]; } try { IResolvedBundle rb = generateBundle(files[i]); if (rb != null) { bundles.add(rb); } } catch (CoreException e) { // ignore invalid bundles } localMonitor.worked(1); } localMonitor.done(); return (IResolvedBundle[]) bundles.toArray(new IResolvedBundle[bundles.size()]); } throw new CoreException( new Status( IStatus.ERROR, MDECore.PLUGIN_ID, NLS.bind(Messages.DirectoryBundleContainer_1, dir.toString()))); }
public SubMonitor newChild(int paramInt, boolean paramBoolean) { double d = Math.min(paramInt, this.aTotalChildren - this.aUsedForChildren); cleanupChild(); SubMonitor localSubMonitor = new SubMonitor(this.aRootMonitor, consume(d), 0); localSubMonitor.setSuppressBeginTask(paramBoolean); this.aChild = localSubMonitor; return localSubMonitor; }
public IStatus getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor) { SubMonitor subMonitor = SubMonitor.convert(monitor, requests.length); try { MultiStatus overallStatus = new MultiStatus(TestActivator.PI_PROV_TESTS, IStatus.OK, null, null); for (int i = 0; i < requests.length; i++) { overallStatus.add(getArtifact((ArtifactRequest) requests[i], subMonitor.newChild(1))); } return (monitor.isCanceled() ? Status.CANCEL_STATUS : overallStatus); } finally { subMonitor.done(); } }
@Override protected void computeProfileChangeRequest(MultiStatus status, IProgressMonitor monitor) { SubMonitor sub = SubMonitor.convert(monitor, 1); if (currentRemedy != null) { request = currentRemedy.getRequest(); sub.worked(1); return; } try { status.add(computeAllRemediations(sub.newChild(1))); } catch (OperationCanceledException e) { status.add(Status.CANCEL_STATUS); } determineBestSolutions(); }
/* * (non-Javadoc) * @see org.eclipse.equinox.p2.operations.RepositoryTracker#refreshRepositories(java.net.URI[], org.eclipse.equinox.p2.operations.ProvisioningSession, org.eclipse.core.runtime.IProgressMonitor) */ public void refreshRepositories( URI[] locations, ProvisioningSession session, IProgressMonitor monitor) { ui.signalRepositoryOperationStart(); SubMonitor mon = SubMonitor.convert(monitor, locations.length * 100); for (int i = 0; i < locations.length; i++) { try { getArtifactRepositoryManager().refreshRepository(locations[i], mon.newChild(50)); getMetadataRepositoryManager().refreshRepository(locations[i], mon.newChild(50)); } catch (ProvisionException e) { // ignore problematic repositories when refreshing } } // We have no idea how many repos may have been added/removed as a result of // refreshing these, this one, so we do not use a specific repository event to represent it. ui.signalRepositoryOperationComplete(null, true); }
void perform( MultiStatus status, EngineSession session, Operand[] operands, IProgressMonitor monitor) { SubMonitor subMonitor = SubMonitor.convert(monitor, prePerformWork + mainPerformWork + postPerformWork); session.recordPhaseEnter(this); prePerform(status, session, subMonitor.newChild(prePerformWork)); if (status.matches(IStatus.ERROR | IStatus.CANCEL)) return; session.recordPhaseStart(this); subMonitor.setWorkRemaining(mainPerformWork + postPerformWork); mainPerform(status, session, operands, subMonitor.newChild(mainPerformWork)); if (status.matches(IStatus.ERROR | IStatus.CANCEL)) return; session.recordPhaseEnd(this); subMonitor.setWorkRemaining(postPerformWork); postPerform(status, session, subMonitor.newChild(postPerformWork)); phaseParameters.clear(); if (status.matches(IStatus.ERROR | IStatus.CANCEL)) return; session.recordPhaseExit(this); subMonitor.done(); }
private IStatus computeAllRemediations(IProgressMonitor monitor) { SubMonitor sub = SubMonitor.convert(monitor, remedyConfigs.length); sub.setTaskName(Messages.RemediationOperation_ProfileChangeRequestProgress); List<Remedy> tmpRemedies = new ArrayList<Remedy>(remedyConfigs.length); try { for (int i = 0; i < remedyConfigs.length; i++) { sub.subTask((i + 1) + " / " + remedyConfigs.length); // $NON-NLS-1$ if (sub.isCanceled()) return Status.CANCEL_STATUS; Remedy remedy = computeRemedy(remedyConfigs[i], sub.newChild(1, SubMonitor.SUPPRESS_ALL_LABELS)); if (remedy != null) { tmpRemedies.add(remedy); } } } finally { sub.done(); } remedies = tmpRemedies; return getResolutionResult(); }
private void mainPerform( MultiStatus status, EngineSession session, Operand[] operands, SubMonitor subMonitor) { IProfile profile = session.getProfile(); subMonitor.beginTask(null, operands.length); for (int i = 0; i < operands.length; i++) { subMonitor.setWorkRemaining(operands.length - i); if (subMonitor.isCanceled()) throw new OperationCanceledException(); Operand operand = operands[i]; if (!isApplicable(operand)) continue; session.recordOperandStart(operand); List<ProvisioningAction> actions = getActions(operand); operandParameters = new HashMap<String, Object>(phaseParameters); operandParameters.put(PARM_OPERAND, operand); mergeStatus(status, initializeOperand(profile, operand, operandParameters, subMonitor)); if (status.matches(IStatus.ERROR | IStatus.CANCEL)) { operandParameters = null; return; } Touchpoint operandTouchpoint = (Touchpoint) operandParameters.get(PARM_TOUCHPOINT); if (operandTouchpoint != null) { mergeStatus( status, initializeTouchpointParameters(profile, operand, operandTouchpoint, subMonitor)); if (status.matches(IStatus.ERROR | IStatus.CANCEL)) return; operandParameters = touchpointToTouchpointOperandParameters.get(operandTouchpoint); } operandParameters = Collections.unmodifiableMap(operandParameters); if (actions != null) { for (int j = 0; j < actions.size(); j++) { ProvisioningAction action = actions.get(j); Map<String, Object> parameters = operandParameters; Touchpoint touchpoint = action.getTouchpoint(); if (touchpoint != null) { mergeStatus( status, initializeTouchpointParameters(profile, operand, touchpoint, subMonitor)); if (status.matches(IStatus.ERROR | IStatus.CANCEL)) return; parameters = touchpointToTouchpointOperandParameters.get(touchpoint); } IStatus actionStatus = null; try { session.recordActionExecute(action, parameters); actionStatus = action.execute(parameters); } catch (RuntimeException e) { if (!forced) throw e; // "action.execute" calls user code and might throw an unchecked exception // we catch the error here to gather information on where the problem occurred. actionStatus = new Status( IStatus.ERROR, EngineActivator.ID, NLS.bind(Messages.forced_action_execute_error, action.getClass().getName()), e); } catch (LinkageError e) { if (!forced) throw e; // Catch linkage errors as these are generally recoverable but let other Errors // propagate (see bug 222001) actionStatus = new Status( IStatus.ERROR, EngineActivator.ID, NLS.bind(Messages.forced_action_execute_error, action.getClass().getName()), e); } if (forced && actionStatus != null && actionStatus.matches(IStatus.ERROR)) { MultiStatus result = new MultiStatus(EngineActivator.ID, IStatus.ERROR, getProblemMessage(), null); result.add( new Status( IStatus.ERROR, EngineActivator.ID, session.getContextString(this, operand, action), null)); LogHelper.log(result); actionStatus = Status.OK_STATUS; } mergeStatus(status, actionStatus); if (status.matches(IStatus.ERROR | IStatus.CANCEL)) return; } } mergeStatus( status, touchpointCompleteOperand(profile, operand, operandParameters, subMonitor)); mergeStatus(status, completeOperand(profile, operand, operandParameters, subMonitor)); if (status.matches(IStatus.ERROR | IStatus.CANCEL)) return; operandParameters = null; session.recordOperandEnd(operand); subMonitor.worked(1); } }