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 163666 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]
Fix v3
patch.txt (text/plain), 18.37 KB, created by
John Arthorne
on 2010-04-01 15:01:24 EDT
(
hide
)
Description:
Fix v3
Filename:
MIME Type:
Creator:
John Arthorne
Created:
2010-04-01 15:01:24 EDT
Size:
18.37 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.ui >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.84 >diff -u -r1.84 MANIFEST.MF >--- META-INF/MANIFEST.MF 31 Mar 2010 15:10:01 -0000 1.84 >+++ META-INF/MANIFEST.MF 1 Apr 2010 18:57:03 -0000 >@@ -80,7 +80,6 @@ > org.eclipse.search;bundle-version="[3.1.0,4.0.0)", > org.eclipse.team.core;bundle-version="[3.2.0,4.0.0)", > org.eclipse.ui;bundle-version="[3.5.0,4.0.0)", >- org.eclipse.update.core;bundle-version="[3.1.0,4.0.0)", > org.eclipse.ui.forms;bundle-version="[3.2.0,4.0.0)", > org.eclipse.ant.ui;bundle-version="[3.1.0,4.0.0)", > org.eclipse.jdt.junit;bundle-version="[3.2.0,4.0.0)", >@@ -107,7 +106,8 @@ > org.eclipse.equinox.frameworkadmin;bundle-version="[2.0.0,3.0.0)", > org.eclipse.equinox.frameworkadmin.equinox;bundle-version="[1.0.100,2.0.0)", > org.eclipse.pde.launching;bundle-version="[3.6.0,4.0.0)";visibility:=reexport, >- org.eclipse.ui.console;bundle-version="[3.5.0,4.0.0)" >+ org.eclipse.ui.console;bundle-version="[3.5.0,4.0.0)", >+ org.eclipse.equinox.simpleconfigurator;bundle-version="1.0.200" > Eclipse-LazyStart: true > Import-Package: com.ibm.icu.text, > org.eclipse.jdt.debug.core >Index: src/org/eclipse/pde/internal/ui/PDEPlugin.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPlugin.java,v >retrieving revision 1.61 >diff -u -r1.61 PDEPlugin.java >--- src/org/eclipse/pde/internal/ui/PDEPlugin.java 22 Sep 2009 19:01:02 -0000 1.61 >+++ src/org/eclipse/pde/internal/ui/PDEPlugin.java 1 Apr 2010 18:57:03 -0000 >@@ -188,6 +188,7 @@ > LogFilesManager.removeLogFileProvider(fLogFileProvider); > fLogFileProvider = null; > } >+ Utilities.shutdown(); > super.stop(context); > } > >Index: src/org/eclipse/pde/internal/ui/PDEUIMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java,v >retrieving revision 1.468 >diff -u -r1.468 PDEUIMessages.java >--- src/org/eclipse/pde/internal/ui/PDEUIMessages.java 31 Mar 2010 15:10:01 -0000 1.468 >+++ src/org/eclipse/pde/internal/ui/PDEUIMessages.java 1 Apr 2010 18:57:03 -0000 >@@ -1441,6 +1441,9 @@ > public static String SearchAction_Declaration; > public static String ShowDescriptionAction_label; > public static String ShowDescriptionAction_title; >+ public static String ShowSampleAction_installing; >+ public static String ShowSampleAction_title; >+ public static String ShowSampleAction_msgDesc; > public static String ShowSampleAction_msgTitle; > public static String DependencyExtent_singular; > public static String DependencyExtent_plural; >@@ -1763,8 +1766,6 @@ > public static String ReviewPage_desc; > public static String ReviewPage_descContent; > public static String ReviewPage_content; >- public static String ShowSampleAction_title; >- public static String ShowSampleAction_msgDesc; > public static String SelfHostingPropertyPage_label; > public static String SelfHostingPropertyPage_viewerLabel; > public static String RuntimePage_tabName; >Index: src/org/eclipse/pde/internal/ui/Utilities.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/Utilities.java >diff -N src/org/eclipse/pde/internal/ui/Utilities.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/Utilities.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,111 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui; >+ >+import java.io.*; >+import java.util.Date; >+import org.eclipse.core.runtime.Platform; >+ >+/** >+ * This class is a collection of utility functions for creating and using temporary working directories. >+ */ >+public class Utilities { >+ >+ private static long tmpseed = (new Date()).getTime(); >+ private static String dirRoot = null; >+ >+ /** >+ * Returns a new working directory (in temporary space). Ensures >+ * the directory exists. Any directory levels that had to be created >+ * are marked for deletion on exit. >+ * >+ * @return working directory >+ * @exception IOException >+ * @since 2.0 >+ */ >+ public static synchronized File createWorkingDirectory() throws IOException { >+ >+ if (dirRoot == null) { >+ dirRoot = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$ >+ // in Linux, returns '/tmp', we must add '/' >+ if (!dirRoot.endsWith(File.separator)) >+ dirRoot += File.separator; >+ >+ // on Unix/Linux, the temp dir is shared by many users, so we need to ensure >+ // that the top working directory is different for each user >+ if (!Platform.getOS().equals("win32")) { //$NON-NLS-1$ >+ String home = System.getProperty("user.home"); //$NON-NLS-1$ >+ home = Integer.toString(home.hashCode()); >+ dirRoot += home + File.separator; >+ } >+ dirRoot += "eclipse" + File.separator + ".update" + File.separator + Long.toString(tmpseed) + File.separator; //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ >+ String tmpName = dirRoot + Long.toString(++tmpseed) + File.separator; >+ >+ File tmpDir = new File(tmpName); >+ verifyPath(tmpDir, false); >+ if (!tmpDir.exists()) >+ throw new FileNotFoundException(tmpName); >+ return tmpDir; >+ } >+ >+ /** >+ * Perform shutdown processing for temporary file handling. >+ * This method is called when platform is shutting down. >+ * It is not intended to be called at any other time under >+ * normal circumstances. A side-effect of calling this method >+ * is that the contents of the temporary directory managed >+ * by this class are deleted. >+ * >+ * @since 2.0 >+ */ >+ public static void shutdown() { >+ if (dirRoot == null) >+ return; >+ File temp = new File(dirRoot); // temp directory root for this run >+ cleanupTemp(temp); >+ temp.delete(); >+ } >+ >+ private static void cleanupTemp(File root) { >+ File[] files = root.listFiles(); >+ for (int i = 0; files != null && i < files.length; i++) { >+ if (files[i].isDirectory()) >+ cleanupTemp(files[i]); >+ files[i].delete(); >+ } >+ } >+ >+ private static void verifyPath(File path, boolean isFile) { >+ // if we are expecting a file back off 1 path element >+ if (isFile) { >+ if (path.getAbsolutePath().endsWith(File.separator)) { >+ // make sure this is a file >+ path = path.getParentFile(); >+ isFile = false; >+ } >+ } >+ >+ // already exists ... just return >+ if (path.exists()) >+ return; >+ >+ // does not exist ... ensure parent exists >+ File parent = path.getParentFile(); >+ verifyPath(parent, false); >+ >+ // ensure directories are made. Mark files or directories for deletion >+ if (!isFile) >+ path.mkdir(); >+ path.deleteOnExit(); >+ } >+} >Index: src/org/eclipse/pde/internal/ui/pderesources.properties >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties,v >retrieving revision 1.1127 >diff -u -r1.1127 pderesources.properties >--- src/org/eclipse/pde/internal/ui/pderesources.properties 31 Mar 2010 19:45:35 -0000 1.1127 >+++ src/org/eclipse/pde/internal/ui/pderesources.properties 1 Apr 2010 18:57:04 -0000 >@@ -1235,7 +1235,6 @@ > SearchAction_Declaration = Find Declaratio&n > ShowDescriptionAction_label = Sho&w Description > ShowDescriptionAction_title=Extension Point Description >-ShowSampleAction_msgTitle=Samples > DefinitionPage_0=Definition > DefinitionPage_1=Target Definition > DependencyExtent_singular = dependency >@@ -1720,6 +1719,8 @@ > <p>If the selection is correct, press <b>Finish</b> to create the sample.</p> > ShowSampleAction_title=Eclipse Samples > ShowSampleAction_msgDesc=The samples are currently not installed. Do you want to download samples from Eclipse.org? >+ShowSampleAction_installing=Installing sample plug-ins >+ShowSampleAction_msgTitle=Samples > SelfHostingPropertyPage_label=By default, all output folders are put on the plug-in's classpath when running a runtime Eclipse application. > SecondaryBundlesSection_title=Automated Management of Dependencies > SelfHostingPropertyPage_viewerLabel=Deselect the folders to be excluded: >Index: src/org/eclipse/pde/internal/ui/search/ShowDescriptionAction.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/search/ShowDescriptionAction.java,v >retrieving revision 1.41 >diff -u -r1.41 ShowDescriptionAction.java >--- src/org/eclipse/pde/internal/ui/search/ShowDescriptionAction.java 17 Jan 2008 16:44:19 -0000 1.41 >+++ src/org/eclipse/pde/internal/ui/search/ShowDescriptionAction.java 1 Apr 2010 18:57:04 -0000 >@@ -32,7 +32,6 @@ > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.browser.IWebBrowser; > import org.eclipse.ui.browser.IWorkbenchBrowserSupport; >-import org.eclipse.update.core.Utilities; > > public class ShowDescriptionAction extends Action { > private String fPointID; >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 1 Apr 2010 18:57:04 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -10,26 +10,37 @@ > *******************************************************************************/ > package org.eclipse.pde.internal.ui.samples; > >+import java.io.IOException; > 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.internal.provisional.configurator.Configurator; >+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.pde.internal.ui.*; > import org.eclipse.swt.widgets.Shell; > import org.eclipse.ui.PlatformUI; > 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; >+import org.osgi.framework.BundleContext; >+import org.osgi.framework.ServiceReference; > > public class ShowSampleAction extends Action implements IIntroAction { > private static final String SAMPLE_FEATURE_ID = "org.eclipse.sdk.samples"; //$NON-NLS-1$ >@@ -37,10 +48,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) { >@@ -109,8 +123,17 @@ > private void enableActivities(IConfigurationElement sample) { > } > >+ /** >+ * Ensure the sample feature is present. If not present, attempt to install it. >+ * >+ * @return <code>true</code> if the sample features are present, and >+ * <code>false</code> otherwise. >+ */ > private boolean ensureSampleFeaturePresent() { >- if (checkFeature()) >+ IProfile profile = getProfile(); >+ if (profile == null) >+ return false; >+ if (checkFeature(profile)) > return true; > // the feature is not present - ask to download > if (MessageDialog.openQuestion(PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.ShowSampleAction_msgTitle, PDEUIMessages.ShowSampleAction_msgDesc)) { >@@ -119,29 +142,52 @@ > return false; > } > >- 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; >+ private boolean checkFeature(IProfile profile) { >+ return !profile.query(getSampleFeatureQuery(), null).isEmpty(); >+ } >+ >+ /** >+ * Returns <code>true</code> if the sample feature is already installed, or if >+ * it won't be possible to install the feature (required services are missing). Returns >+ * <code>false</code> if the features are missing and should be installed. >+ */ >+ private IProfile getProfile() { >+ IProvisioningAgent agent = provUI.getSession().getProvisioningAgent(); >+ if (agent == null) >+ return null; >+ IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME); >+ if (registry == null) >+ return null; >+ return registry.getProfile(provUI.getProfileId()); >+ } >+ >+ 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, PDEUIMessages.ShowSampleAction_installing, 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); >+ } >+ applyConfiguration(); > } catch (Exception e) { > throw new InvocationTargetException(e); > } >@@ -157,4 +203,41 @@ > } > 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(); >+ } >+ >+ /** >+ * Creates the operation that will install the sample features in the running platform. >+ */ >+ 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; >+ } >+ >+ /** >+ * Apply the profile changes to the currently running configuration. >+ */ >+ void applyConfiguration() throws CoreException { >+ BundleContext context = PDEPlugin.getDefault().getBundle().getBundleContext(); >+ ServiceReference reference = context.getServiceReference(Configurator.class.getName()); >+ Configurator configurator = (Configurator) context.getService(reference); >+ try { >+ configurator.applyConfiguration(); >+ } catch (IOException e) { >+ throw new CoreException(new Status(IStatus.ERROR, IPDEUIConstants.PLUGIN_ID, "Unexpected failure applying configuration", e)); //$NON-NLS-1$ >+ } finally { >+ context.ungetService(reference); >+ } >+ } >+ > }
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