Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 163590 Details for
Bug 210529
[update] Error installing examples with p2-provisioned SDK
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Draft fix v2
patch.txt (text/plain), 6.39 KB, created by
John Arthorne
on 2010-03-31 18:09:26 EDT
(
hide
)
Description:
Draft fix v2
Filename:
MIME Type:
Creator:
John Arthorne
Created:
2010-03-31 18:09:26 EDT
Size:
6.39 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.ui >Index: src_samples/org/eclipse/pde/internal/ui/samples/ShowSampleAction.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src_samples/org/eclipse/pde/internal/ui/samples/ShowSampleAction.java,v >retrieving revision 1.10 >diff -u -r1.10 ShowSampleAction.java >--- src_samples/org/eclipse/pde/internal/ui/samples/ShowSampleAction.java 27 May 2009 20:38:23 -0000 1.10 >+++ src_samples/org/eclipse/pde/internal/ui/samples/ShowSampleAction.java 31 Mar 2010 22:07:47 -0000 >@@ -11,14 +11,26 @@ > package org.eclipse.pde.internal.ui.samples; > > import java.lang.reflect.InvocationTargetException; >+import java.net.URI; >+import java.net.URISyntaxException; >+import java.util.Collection; > import java.util.Properties; > import org.eclipse.core.runtime.*; >+import org.eclipse.equinox.p2.core.IProvisioningAgent; >+import org.eclipse.equinox.p2.core.ProvisionException; >+import org.eclipse.equinox.p2.engine.IProfile; >+import org.eclipse.equinox.p2.engine.IProfileRegistry; >+import org.eclipse.equinox.p2.operations.InstallOperation; >+import org.eclipse.equinox.p2.operations.ProvisioningJob; >+import org.eclipse.equinox.p2.query.IQuery; >+import org.eclipse.equinox.p2.query.QueryUtil; >+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; >+import org.eclipse.equinox.p2.ui.ProvisioningUI; > import org.eclipse.jface.action.Action; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.operation.IRunnableWithProgress; > import org.eclipse.jface.window.Window; > import org.eclipse.jface.wizard.WizardDialog; >-import org.eclipse.pde.internal.core.util.VersionUtil; > import org.eclipse.pde.internal.ui.PDEPlugin; > import org.eclipse.pde.internal.ui.PDEUIMessages; > import org.eclipse.swt.widgets.Shell; >@@ -26,10 +38,6 @@ > import org.eclipse.ui.WorkbenchException; > import org.eclipse.ui.intro.IIntroSite; > import org.eclipse.ui.intro.config.*; >-import org.eclipse.update.configurator.ConfiguratorUtils; >-import org.eclipse.update.configurator.IPlatformConfiguration; >-import org.eclipse.update.standalone.InstallCommand; >-import org.osgi.framework.Version; > > public class ShowSampleAction extends Action implements IIntroAction { > private static final String SAMPLE_FEATURE_ID = "org.eclipse.sdk.samples"; //$NON-NLS-1$ >@@ -37,10 +45,13 @@ > private static final String UPDATE_SITE = "http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/pde-ui-home/samples/"; //$NON-NLS-1$ > private String sampleId; > >+ private ProvisioningUI provUI; >+ > /** > * > */ > public ShowSampleAction() { >+ provUI = ProvisioningUI.getDefaultUI(); > } > > public void run(IIntroSite site, Properties params) { >@@ -119,29 +130,43 @@ > return false; > } > >+ /** >+ * Returns <code>true</code> if the sample feature is already installed, and >+ * <code>false</code> otherwise. >+ */ > private boolean checkFeature() { >- IPlatformConfiguration config = ConfiguratorUtils.getCurrentPlatformConfiguration(); >- IPlatformConfiguration.IFeatureEntry[] features = config.getConfiguredFeatureEntries(); >- Version sampleVersion = new Version(SAMPLE_FEATURE_VERSION); >- for (int i = 0; i < features.length; i++) { >- String id = features[i].getFeatureIdentifier(); >- if (SAMPLE_FEATURE_ID.equals(id)) { >- String version = features[i].getFeatureVersion(); >- Version fversion = Version.parseVersion(version); >- if (VersionUtil.isCompatibleWith(fversion, sampleVersion)) >- return true; >- } >- } >- return false; >+ IProvisioningAgent agent = provUI.getSession().getProvisioningAgent(); >+ IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME); >+ IProfile profile = registry.getProfile(provUI.getProfileId()); >+ return !profile.query(getSampleFeatureQuery(), null).isEmpty(); > } > >+ IQuery getSampleFeatureQuery() { >+ return QueryUtil.createIUQuery(SAMPLE_FEATURE_ID, org.eclipse.equinox.p2.metadata.Version.parseVersion(SAMPLE_FEATURE_VERSION)); >+ } >+ >+ /** >+ * Download the sample feature, returning <code>true</code> if the feature >+ * was installed successfully, and <code>false</code> otherwise. >+ */ > private boolean downloadFeature() { > IRunnableWithProgress op = new IRunnableWithProgress() { >- public void run(IProgressMonitor monitor) throws InvocationTargetException { >+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { > try { >- InstallCommand command = new InstallCommand(SAMPLE_FEATURE_ID, SAMPLE_FEATURE_VERSION, UPDATE_SITE, null, "false"); //$NON-NLS-1$ >- command.run(monitor); >- command.applyChangesNow(); >+ SubMonitor sub = SubMonitor.convert(monitor, 100); >+ InstallOperation operation = createInstallOperation(sub.newChild(10)); >+ operation.resolveModal(sub.newChild(20)); >+ IStatus status = operation.getResolutionResult(); >+ if (status.getSeverity() == IStatus.CANCEL) { >+ throw new InterruptedException(); >+ } else if (!(status.isOK() || status.getSeverity() == IStatus.INFO)) { >+ throw new CoreException(status); >+ } >+ ProvisioningJob job = operation.getProvisioningJob(null); >+ status = job.runModal(sub.newChild(70)); >+ if (!(status.isOK() || status.getSeverity() == IStatus.INFO)) { >+ throw new CoreException(status); >+ } > } catch (Exception e) { > throw new InvocationTargetException(e); > } >@@ -157,4 +182,26 @@ > } > return true; > } >+ >+ /** >+ * Returns a Collection<IInstallableUnit> of the installable units that contain the samples >+ * to be installed. >+ */ >+ protected Collection findSampleIUs(URI location, SubMonitor monitor) throws ProvisionException { >+ IMetadataRepository repository = provUI.loadMetadataRepository(location, false, monitor.newChild(5)); >+ return repository.query(getSampleFeatureQuery(), monitor.newChild(5)).toUnmodifiableSet(); >+ } >+ >+ protected IProvisioningAgent getProvisioningAgent() { >+ >+ return null; >+ } >+ >+ InstallOperation createInstallOperation(SubMonitor monitor) throws URISyntaxException, ProvisionException { >+ URI repositoryLocation = new URI(UPDATE_SITE); >+ Collection sampleIUs = findSampleIUs(repositoryLocation, monitor); >+ URI[] repos = new URI[] {repositoryLocation}; >+ InstallOperation operation = provUI.getInstallOperation(sampleIUs, repos); >+ return operation; >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 210529
:
126210
|
163589
|
163590
|
163666