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