Fixed bug 398308: Samples cannot be loaded from the welcome page
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java
index 3d7b12e..f86b29c 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2012 IBM Corporation and others.
+ * Copyright (c) 2005, 2013 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
@@ -1513,6 +1513,8 @@
public static String ShowSampleAction_title;
public static String ShowSampleAction_msgDesc;
public static String ShowSampleAction_msgTitle;
+
+ public static String ShowSampleAction_NoSamplesFound;
public static String DependencyExtent_singular;
public static String DependencyExtent_plural;
public static String DetailsBlock_horizontal;
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties
index 73a79e5..54395c8 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2012 IBM Corporation and others.
+# Copyright (c) 2000, 2013 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
@@ -1782,6 +1782,7 @@
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
+ShowSampleAction_NoSamplesFound=The samples could not be accessed at {0}
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:
diff --git a/ui/org.eclipse.pde.ui/src_samples/org/eclipse/pde/internal/ui/samples/ShowSampleAction.java b/ui/org.eclipse.pde.ui/src_samples/org/eclipse/pde/internal/ui/samples/ShowSampleAction.java
index dec79eb..a0c5e6d 100644
--- a/ui/org.eclipse.pde.ui/src_samples/org/eclipse/pde/internal/ui/samples/ShowSampleAction.java
+++ b/ui/org.eclipse.pde.ui/src_samples/org/eclipse/pde/internal/ui/samples/ShowSampleAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 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
@@ -14,18 +14,17 @@
import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.Collection;
-import java.util.Properties;
+import java.util.*;
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.metadata.IInstallableUnit;
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.query.*;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.jface.action.Action;
@@ -33,6 +32,7 @@
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.internal.ui.*;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
@@ -44,8 +44,7 @@
public class ShowSampleAction extends Action implements IIntroAction {
private static final String SAMPLE_FEATURE_ID = "org.eclipse.sdk.samples"; //$NON-NLS-1$
- private static final String SAMPLE_FEATURE_VERSION = "3.3.0"; //$NON-NLS-1$
- private static final String UPDATE_SITE = "http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/pde-ui-home/samples/"; //$NON-NLS-1$
+ private static final String UPDATE_SITE = "http://www.eclipse.org/pde/samples/site.xml"; //$NON-NLS-1$
private String sampleId;
private ProvisioningUI provUI;
@@ -162,7 +161,7 @@
}
IQuery getSampleFeatureQuery() {
- return QueryUtil.createIUQuery(SAMPLE_FEATURE_ID, org.eclipse.equinox.p2.metadata.Version.parseVersion(SAMPLE_FEATURE_VERSION));
+ return QueryUtil.createIUQuery(SAMPLE_FEATURE_ID);
}
/**
@@ -210,7 +209,20 @@
*/
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();
+ IQueryResult allSamples = repository.query(getSampleFeatureQuery(), monitor.newChild(5));
+ if (allSamples.isEmpty()) {
+ throw new ProvisionException(NLS.bind(PDEUIMessages.ShowSampleAction_NoSamplesFound, location.toString()));
+ }
+ IInstallableUnit toInstall = null;
+ for (Iterator iterator = allSamples.iterator(); iterator.hasNext();) {
+ IInstallableUnit current = (IInstallableUnit) iterator.next();
+ if (toInstall == null || toInstall.getVersion().compareTo(current.getVersion()) < 0) {
+ toInstall = current;
+ }
+ }
+ Collection result = new ArrayList(1);
+ result.add(toInstall);
+ return result;
}
/**