c202a65
From a23545ef5b4cbb94ff048fda2839ba08c3593d50 Mon Sep 17 00:00:00 2001
c202a65
From: Mat Booth <mat.booth@redhat.com>
c202a65
Date: Thu, 3 May 2018 15:58:49 +0100
c202a65
Subject: [PATCH] Bug 534326 - Awkward p2 UI when many droplets are installed
c202a65
 Filter out software site locations where we know that they are p2 droplets in
c202a65
 places we show the list to the user. Change-Id:
c202a65
 I12364223850862783cb7cffd32fb7428fbf6b270 Signed-off-by: Mat Booth
c202a65
 <mat.booth@redhat.com>
e7779ed
c202a65
---
c202a65
 .../p2/ui/dialogs/RepositorySelectionGroup.java   | 13 +++++++++++++
c202a65
 .../equinox/p2/ui/RepositoryManipulationPage.java | 15 ++++++++++++++-
c202a65
 2 files changed, 27 insertions(+), 1 deletion(-)
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
c202a65
index d07be5d43..c666f8fdc 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
0932978
@@ -303,6 +303,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
c202a65
index 78fb5398e..b8e724b66 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
0932978
@@ -133,9 +133,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$
c202a65
 				for (Object element : children) {
c202a65
 					if (element instanceof MetadataRepositoryElement) {
c202a65
-						put((MetadataRepositoryElement) element);
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$
c202a65
+								URI childLoc = ((MetadataRepositoryElement) element).getLocation();
e7779ed
+								if (childLoc.getPath() != null && childLoc.getPath().startsWith(root)) {
e7779ed
+									isDroplet = true;
e7779ed
+								}
e7779ed
+							}
e7779ed
+							if (!isDroplet) {
c202a65
+								put((MetadataRepositoryElement) element);
e7779ed
+							}
e7779ed
+						}
e7779ed
 					}
e7779ed
 				}
e7779ed
 			}
c202a65
-- 
c202a65
2.21.1
c202a65