Blame SOURCES/eclipse-hide-droplets-from-install-wizard.patch

d433ea
commit 4bfc5a7c6d8c2aaf954c113d805419472de2bcaf
d433ea
Author: Mat Booth <mat.booth@redhat.com>
d433ea
Date:   Thu May 3 15:58:49 2018 +0100
d433ea
d433ea
    Bug 534326 - Awkward p2 UI when many droplets are installed
d433ea
    
d433ea
    Filter out software site locations where we know that they are p2
d433ea
    droplets in places we show the list to the user.
d433ea
    
d433ea
    Change-Id: I12364223850862783cb7cffd32fb7428fbf6b270
d433ea
    Signed-off-by: Mat Booth <mat.booth@redhat.com>
d433ea
d433ea
diff --git a/rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositorySelectionGroup.java b/rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositorySelectionGroup.java
d433ea
index e6eef8c39..fe5970e79 100644
d433ea
--- a/rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositorySelectionGroup.java
d433ea
+++ b/rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositorySelectionGroup.java
d433ea
@@ -303,6 +303,19 @@ public class RepositorySelectionGroup {
d433ea
 	void fillRepoCombo(final String selection) {
d433ea
 		RepositoryTracker tracker = ui.getRepositoryTracker();
d433ea
 		URI[] sites = tracker.getKnownRepositories(ui.getSession());
d433ea
+		// Filter out sites that are actually installed p2 droplets
d433ea
+		String fragments = System.getProperty("p2.fragments"); //$NON-NLS-1$
d433ea
+		ArrayList<URI> filteredSites = new ArrayList<>(Arrays.asList(sites));
d433ea
+		if (fragments != null) {
d433ea
+			for (String root : fragments.split(",")) { //$NON-NLS-1$
d433ea
+				for (URI uri : sites) {
d433ea
+					if (uri.getPath() != null && uri.getPath().startsWith(root)) {
d433ea
+						filteredSites.remove(uri);
d433ea
+					}
d433ea
+				}
d433ea
+			}
d433ea
+		}
d433ea
+		sites = filteredSites.toArray(new URI[0]);
d433ea
 		boolean hasLocalSites = getLocalSites().length > 0;
d433ea
 		final String[] items;
d433ea
 		if (hasLocalSites) {
d433ea
diff --git a/rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java b/rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java
d433ea
index d796aefd0..c03924f90 100644
d433ea
--- a/rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java
d433ea
+++ b/rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java
d433ea
@@ -133,9 +133,22 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
d433ea
 			if (cachedElements == null) {
d433ea
 				Object[] children = super.fetchChildren(o, monitor);
d433ea
 				cachedElements = new Hashtable<>(children.length);
d433ea
+				String fragments = System.getProperty("p2.fragments"); //$NON-NLS-1$
d433ea
 				for (int i = 0; i < children.length; i++) {
d433ea
 					if (children[i] instanceof MetadataRepositoryElement) {
d433ea
-						put((MetadataRepositoryElement) children[i]);
d433ea
+						// Filter out locations that are actually installed p2 droplets
d433ea
+						if (fragments != null) {
d433ea
+							boolean isDroplet = false;
d433ea
+							for (String root : fragments.split(",")) { //$NON-NLS-1$
d433ea
+								URI childLoc = ((MetadataRepositoryElement) children[i]).getLocation();
d433ea
+								if (childLoc.getPath() != null && childLoc.getPath().startsWith(root)) {
d433ea
+									isDroplet = true;
d433ea
+								}
d433ea
+							}
d433ea
+							if (!isDroplet) {
d433ea
+								put((MetadataRepositoryElement) children[i]);
d433ea
+							}
d433ea
+						}
d433ea
 					}
d433ea
 				}
d433ea
 			}