# HG changeset patch # User stechong # Date 1284489449 18000 # Node ID 75d787292eea2255ff328cef66fd7d703872c969 # Parent 9078a58d3988af23c05c7f59cfa3bbd805ec4d2a Updated the dynamic p2 installer to improve progress reporting and check for cancel during install. diff -r 9078a58d3988 -r 75d787292eea core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/NewPluginChecker.java --- a/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/NewPluginChecker.java Tue Sep 14 11:40:12 2010 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/NewPluginChecker.java Tue Sep 14 13:37:29 2010 -0500 @@ -22,8 +22,8 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbench; @@ -53,6 +53,8 @@ protected IStatus run(IProgressMonitor monitor) { boolean installed = false; boolean oneSDKWasScanned = false; + SubMonitor subMonitor = SubMonitor.convert(monitor, 100); + int worked = 100 / sdkList.size(); for (ISymbianSDK sdk : sdkList) { ISBSv2BuildInfo sbsv2BuildInfo = (ISBSv2BuildInfo)sdk.getBuildInfo(ISymbianBuilderID.SBSV2_BUILDER); if (sbsv2BuildInfo != null) { @@ -62,7 +64,7 @@ sbsv2BuildInfo.setPreviouslyScanned(true); File featureDir = new File(sdk.getEPOCROOT() + SDK_FEATURE_SUBDIR); try { - IStatus status = DynamicP2Installer.install(featureDir, new NullProgressMonitor()); + IStatus status = DynamicP2Installer.install(featureDir, subMonitor); if (status.isOK()) { // TODO advise user?? installed = true; @@ -76,6 +78,8 @@ // Otherwise, these errors will be logged every time this check is done (workspace is opened) // Originally, this was used to install MBS build support, but now is only used for SDK documentation // ResourcesPlugin.getPlugin().getLog().log(new Status(IStatus.ERROR, SDKCorePlugin.PLUGIN_ID, IStatus.ERROR, "Unable to install plug-ins dynamically.", e)); + } finally { + subMonitor.worked(worked); } } } diff -r 9078a58d3988 -r 75d787292eea core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/p2/DynamicP2Installer.java --- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/p2/DynamicP2Installer.java Tue Sep 14 11:40:12 2010 -0500 +++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/p2/DynamicP2Installer.java Tue Sep 14 13:37:29 2010 -0500 @@ -24,6 +24,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.equinox.internal.provisional.p2.director.IDirector; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.p2.core.IProvisioningAgent; @@ -118,6 +119,7 @@ } private void doInstall(IProgressMonitor monitor) throws CoreException { + SubMonitor subMonitor = SubMonitor.convert(monitor, "Installing plugins from " + repositoryLocation.toOSString(), 100); URI uri = URIUtil.toURI(repositoryLocation); IMetadataRepositoryManager metadataRepoManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME); @@ -125,26 +127,34 @@ (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME); try { // add and load repository + checkIfCanceled(subMonitor); metadataRepoManager.addRepository(uri); IMetadataRepository metadataRepository = metadataRepoManager.loadRepository(uri, null); artifactRepoManager.addRepository(uri); artifactRepoManager.loadRepository(uri, null); + subMonitor.worked(10); // get IU from repository - IQueryResult units = metadataRepository.query(QueryUtil.createIUGroupQuery(), monitor); + checkIfCanceled(subMonitor); + IQueryResult units = metadataRepository.query(QueryUtil.createIUGroupQuery(), subMonitor); if (units.isEmpty()) throw new CoreException(Activator.makeErrorStatus("Could not find installable unit", null)); + subMonitor.worked(10); // check if installed - IQueryResult result = profile.query(QueryUtil.createIUQuery(units.iterator().next()), monitor); + checkIfCanceled(subMonitor); + IQueryResult result = profile.query(QueryUtil.createIUQuery(units.iterator().next()), subMonitor); if (!result.isEmpty()) throw new CoreException(Activator.makeStatus(IStatus.CANCEL, null, null)); // already installed + subMonitor.worked(10); // do provisioning operation + checkIfCanceled(subMonitor); ProfileChangeRequest request = new ProfileChangeRequest(profile); request.addAll(units.toUnmodifiableSet()); IDirector director = (IDirector) agent.getService(IDirector.SERVICE_NAME); - IStatus status = director.provision(request, null, monitor); + IStatus status = director.provision(request, null, subMonitor); + subMonitor.worked(70); if (!status.isOK()) throw new CoreException(status); @@ -152,6 +162,7 @@ finally { metadataRepoManager.removeRepository(uri); artifactRepoManager.removeRepository(uri); + subMonitor.done(); } } @@ -160,4 +171,10 @@ return profileRegistry.getProfile(provisioningUI.getProfileId()); } + private void checkIfCanceled(IProgressMonitor monitor) throws CoreException { + if (monitor.isCanceled()) { + throw new CoreException(Activator.makeStatus(IStatus.CANCEL, null, null)); // installation canceled + } + } + }