Blob Blame History Raw
From 051d84daff808349fc3eb4d44b2f9d56f7fe89ba Mon Sep 17 00:00:00 2001
From: Roland Grunberg <rgrunber@redhat.com>
Date: Wed, 18 Jan 2017 15:51:40 -0500
Subject: [PATCH] Don't show p2 Droplet locations in the UI.

Don't show p2 Droplets in the Repository Selection Combo Box, or in the
Available Software Sites preferences.

Change-Id: I4afddffbaaeae3f33958629eebb32861087a93de
---
 .../internal/p2/ui/dialogs/RepositorySelectionGroup.java  | 14 ++++++++++++++
 .../eclipse/equinox/p2/ui/RepositoryManipulationPage.java | 15 ++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositorySelectionGroup.java rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositorySelectionGroup.java
index 8d08101..59567c0 100644
--- rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositorySelectionGroup.java
+++ rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositorySelectionGroup.java
@@ -16,6 +16,7 @@ import java.lang.reflect.InvocationTargetException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.*;
+import java.util.List;
 import org.eclipse.core.runtime.*;
 import org.eclipse.equinox.internal.p2.ui.*;
 import org.eclipse.equinox.internal.p2.ui.query.IUViewQueryContext;
@@ -322,6 +323,19 @@ public class RepositorySelectionGroup {
 	void fillRepoCombo(final String selection) {
 		RepositoryTracker tracker = ui.getRepositoryTracker();
 		URI[] sites = tracker.getKnownRepositories(ui.getSession());
+		String fragments = System.getProperty("p2.fragments");
+		List<URI> tmp = new ArrayList<URI>(Arrays.asList(sites));
+		if (fragments != null) {
+			String[] rootPaths = fragments.split(",");
+			for (String root : rootPaths) {
+				for (URI uri : sites) {
+					if (uri.getPath() != null && uri.getPath().startsWith(root)) {
+						tmp.remove(uri);
+					}
+				}
+			}
+		}
+		sites = tmp.toArray(new URI[0]);
 		boolean hasLocalSites = getLocalSites().length > 0;
 		final String[] items;
 		if (hasLocalSites) {
diff --git rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java
index c0f2ca1..03515c7 100644
--- rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java
+++ rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java
@@ -132,9 +132,22 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
 			if (cachedElements == null) {
 				Object[] children = super.fetchChildren(o, monitor);
 				cachedElements = new Hashtable<>(children.length);
+				String fragments = System.getProperty("p2.fragments");
 				for (int i = 0; i < children.length; i++) {
 					if (children[i] instanceof MetadataRepositoryElement) {
-						put((MetadataRepositoryElement) children[i]);
+						if (fragments != null) {
+							String[] rootPaths = fragments.split(",");
+							boolean isDroplet = false;
+							for (String root : rootPaths) {
+								URI childLoc = ((MetadataRepositoryElement)children[i]).getLocation();
+								if (childLoc.getPath() != null && childLoc.getPath().startsWith(root)) {
+									isDroplet = true;
+								}
+							}
+							if (!isDroplet) {
+								put((MetadataRepositoryElement) children[i]);
+							}
+						}
 					}
 				}
 			}
-- 
2.9.3