Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSusan Franklin2008-01-07 23:04:49 +0000
committerSusan Franklin2008-01-07 23:04:49 +0000
commit1c3406f15cc85eff155e4c4fa451209df91d59bb (patch)
treeeb9aaf988e62423c58ed55728bc3c221aa597ecb
parente5e0fd273caee15aee957f2ef8313be64aed77b9 (diff)
downloadrt.equinox.p2-1c3406f15cc85eff155e4c4fa451209df91d59bb.tar.gz
rt.equinox.p2-1c3406f15cc85eff155e4c4fa451209df91d59bb.tar.xz
rt.equinox.p2-1c3406f15cc85eff155e4c4fa451209df91d59bb.zip
Bug 214524 - [prov] [repo] Need access to "implementation only" key without loading repository
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/AbstractDeltaProcessorStep.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java55
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/p2/artifact/repository/IArtifactRepositoryManager.java63
-rw-r--r--bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/phases/Sizing.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryManager.java79
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/p2/metadata/repository/IMetadataRepositoryManager.java64
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ArtifactRepositoriesView.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoriesView.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminQueryProvider.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/RepositoriesView.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/AddArtifactRepositoryDialog.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/AddMetadataRepositoryDialog.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/AddColocatedRepositoryDialog.java19
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKQueryProvider.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/RepositoryManipulationDialog.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RevertProfileWizardPage.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ArtifactRepositoryElement.java74
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/QueriedElementCollector.java (renamed from bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/QueriedElementCollector.java)10
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/AddRepositoryDialog.java60
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/RepositoryPropertyPage.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UpdateAndInstallGroup.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/MetadataRepositoryElement.java57
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/RepositoryElement.java25
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/RollbackRepositoryElement.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/AddArtifactRepositoryOperation.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/AddColocatedRepositoryOperation.java13
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/AddMetadataRepositoryOperation.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProvisioningUtil.java61
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RemoveArtifactRepositoryOperation.java13
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RemoveColocatedRepositoryOperation.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RemoveMetadataRepositoryOperation.java13
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/AvailableIUCollector.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/CategoryElementCollector.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/FilteredRepositoryQuery.java48
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/InstalledIUCollector.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/OtherIUVersionsCollector.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/ProfileElementCollector.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/QueriedElement.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/QueryableArtifactRepositoryManager.java19
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/QueryableMetadataRepositoryManager.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/RepositoryCollector.java49
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/RepositoryPropertyQuery.java48
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/ProvElementComparer.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/ProvElementLabelProvider.java10
50 files changed, 703 insertions, 339 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/AbstractDeltaProcessorStep.java b/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/AbstractDeltaProcessorStep.java
index 7963cb4ec..fb6ff5ecd 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/AbstractDeltaProcessorStep.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/AbstractDeltaProcessorStep.java
@@ -46,14 +46,12 @@ public abstract class AbstractDeltaProcessorStep extends AbstractDeltaStep {
return;
}
- URL[] repositories = repoMgr.getKnownRepositories();
+ URL[] repositories = repoMgr.getKnownRepositories(IArtifactRepositoryManager.REPOSITORIES_LOCAL_ONLY);
for (int i = 0; i < repositories.length; i++) {
- if ("file".equals(repositories[i].getProtocol())) {//$NON-NLS-1$
- IArtifactRepository currentRepo = repoMgr.loadRepository(repositories[i], null);
- if (currentRepo != null && currentRepo.contains(key)) {
- repository = currentRepo;
- return;
- }
+ IArtifactRepository currentRepo = repoMgr.loadRepository(repositories[i], null);
+ if (currentRepo != null && currentRepo.contains(key)) {
+ repository = currentRepo;
+ return;
}
}
status = new Status(IStatus.ERROR, Activator.ID, "No repository available containing key " + key);
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java
index c64432798..ad6cd3c43 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java
@@ -19,6 +19,7 @@ import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifact
import org.eclipse.equinox.internal.p2.core.helpers.*;
import org.eclipse.equinox.p2.artifact.repository.*;
import org.eclipse.equinox.p2.core.location.AgentLocation;
+import org.eclipse.equinox.p2.core.repository.IRepository;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.spi.p2.artifact.repository.IArtifactRepositoryFactory;
import org.osgi.service.prefs.BackingStoreException;
@@ -32,6 +33,7 @@ public class ArtifactRepositoryManager implements IArtifactRepositoryManager {
String description;
URL location;
String name;
+ boolean implementationOnly = false;
SoftReference repository;
}
@@ -45,6 +47,7 @@ public class ArtifactRepositoryManager implements IArtifactRepositoryManager {
private static final String KEY_TYPE = "type"; //$NON-NLS-1$
private static final String KEY_URL = "url"; //$NON-NLS-1$
private static final String KEY_VERSION = "version"; //$NON-NLS-1$
+ private static final String KEY_IMPLEMENTATION_ONLY = "implementationOnly"; //$NON-NLS-1$
private static final String NODE_REPOSITORIES = "repositories"; //$NON-NLS-1$
/**
@@ -65,6 +68,8 @@ public class ArtifactRepositoryManager implements IArtifactRepositoryManager {
info.name = repository.getName();
info.description = repository.getDescription();
info.location = repository.getLocation();
+ String value = (String) repository.getProperties().get(IRepository.IMPLEMENTATION_ONLY_KEY);
+ info.implementationOnly = value == null ? false : Boolean.valueOf(value).booleanValue();
synchronized (repositoryLock) {
if (repositories == null)
restoreRepositories();
@@ -176,20 +181,33 @@ public class ArtifactRepositoryManager implements IArtifactRepositoryManager {
return location.toExternalForm().replace('/', '_');
}
- public URL[] getKnownRepositories() {
+ public URL[] getKnownRepositories(int flags) {
synchronized (repositoryLock) {
if (repositories == null)
restoreRepositories();
- URL[] result = new URL[repositories.size()];
+ ArrayList result = new ArrayList();
int i = 0;
for (Iterator it = repositories.values().iterator(); it.hasNext(); i++) {
RepositoryInfo info = (RepositoryInfo) it.next();
- result[i] = info.location;
+ if (matchesFlags(info, flags))
+ result.add(info.location);
}
- return result;
+ return (URL[]) result.toArray(new URL[result.size()]);
}
}
+ private boolean matchesFlags(RepositoryInfo info, int flags) {
+ if ((flags & REPOSITORIES_IMPLEMENTATION_ONLY) == REPOSITORIES_IMPLEMENTATION_ONLY)
+ if (!info.implementationOnly)
+ return false;
+ if ((flags & REPOSITORIES_PUBLIC_ONLY) == REPOSITORIES_PUBLIC_ONLY)
+ if (info.implementationOnly)
+ return false;
+ if ((flags & REPOSITORIES_LOCAL_ONLY) == REPOSITORIES_LOCAL_ONLY)
+ return "file".equals(info.location.getProtocol()); //$NON-NLS-1$
+ return true;
+ }
+
/*
* Return the root preference node where we store the repository information.
*/
@@ -267,6 +285,9 @@ public class ArtifactRepositoryManager implements IArtifactRepositoryManager {
value = repository.getVersion();
if (value != null)
node.put(KEY_VERSION, value);
+ value = (String) repository.getProperties().get(IRepository.IMPLEMENTATION_ONLY_KEY);
+ if (value != null)
+ node.put(KEY_IMPLEMENTATION_ONLY, value);
value = repository.getLocation().toExternalForm();
node.put(KEY_URL, value);
saveToPreferences();
@@ -278,6 +299,7 @@ public class ArtifactRepositoryManager implements IArtifactRepositoryManager {
private void remember(RepositoryInfo info) {
Preferences node = getPreferences().node(getKey(info.location));
node.put(KEY_URL, info.location.toExternalForm());
+ node.put(KEY_IMPLEMENTATION_ONLY, Boolean.toString(info.implementationOnly));
if (info.description != null)
node.put(KEY_DESCRIPTION, info.description);
if (info.name != null)
@@ -338,6 +360,7 @@ public class ArtifactRepositoryManager implements IArtifactRepositoryManager {
info.location = new URL(locationString);
info.name = child.get(KEY_NAME, null);
info.description = child.get(KEY_DESCRIPTION, null);
+ info.implementationOnly = child.getBoolean(KEY_IMPLEMENTATION_ONLY, false);
repositories.put(getKey(info.location), info);
} catch (MalformedURLException e) {
log("Error while restoring repository: " + locationString, e); //$NON-NLS-1$
@@ -383,4 +406,28 @@ public class ArtifactRepositoryManager implements IArtifactRepositoryManager {
log("Error while saving repositories in preferences", e); //$NON-NLS-1$
}
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.equinox.p2.artifact.repository.IArtifactRepositoryManager#getRepositoryProperty(java.net.URL, java.lang.String)
+ */
+ public String getRepositoryProperty(URL location, String key) {
+ synchronized (repositoryLock) {
+ if (repositories == null)
+ restoreRepositories();
+ for (Iterator it = repositories.values().iterator(); it.hasNext();) {
+ RepositoryInfo info = (RepositoryInfo) it.next();
+ if (URLUtil.sameURL(info.location, location)) {
+ if (PROP_DESCRIPTION.equals(key))
+ return info.description;
+ if (PROP_NAME.equals(key))
+ return info.name;
+ // Key not known, return null
+ return null;
+ }
+ }
+ // Repository not found, return null
+ return null;
+ }
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/p2/artifact/repository/IArtifactRepositoryManager.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/p2/artifact/repository/IArtifactRepositoryManager.java
index d908f50f7..67effe49d 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/p2/artifact/repository/IArtifactRepositoryManager.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/p2/artifact/repository/IArtifactRepositoryManager.java
@@ -14,9 +14,36 @@ import java.net.URL;
import java.util.Properties;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.equinox.p2.core.repository.IRepository;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
public interface IArtifactRepositoryManager {
+ /**
+ * Constant used to indicate that all repositories are of interest.
+ */
+ public static final int REPOSITORIES_ALL = 0;
+ /**
+ * Constant used to indicate that implementation-only repositories are of interest.
+ */
+ public static final int REPOSITORIES_IMPLEMENTATION_ONLY = 1 << 1;
+ /**
+ * Constant used to indicate that public (non-implementation-only) repositories are of interest.
+ */
+ public static final int REPOSITORIES_PUBLIC_ONLY = 1 << 2;
+ /**
+ * Constant used to indicate that local repositories are of interest.
+ */
+ public static final int REPOSITORIES_LOCAL_ONLY = 1 << 3;
+
+ /**
+ * Property key used to query a repository's name without loading the repository first.
+ */
+ public static final String PROP_NAME = "name"; //$NON-NLS-1$
+ /**
+ * Property key used to query a repository's description without loading the repository first.
+ */
+ public static final String PROP_DESCRIPTION = "description"; //$NON-NLS-1$
+
public static final IArtifactRequest[] NO_ARTIFACT_REQUEST = new IArtifactRequest[0];
/**
@@ -71,9 +98,43 @@ public interface IArtifactRepositoryManager {
* A subsequent attempt to load a repository at any of the given locations may
* or may not succeed.
*
+ * @param flags an integer bit-mask indicating which repositories should be
+ * returned. <code>REPOSITORIES_ALL</code> can be used as the mask when
+ * all repositories should be returned.
+ *
* @return the locations of the repositories managed by this repository manager.
+ *
+ * @see #REPOSITORIES_ALL
+ * @see #REPOSITORIES_IMPLEMENTATION_ONLY
+ * @see #REPOSITORIES_LOCAL_ONLY
+ * @see #REPOSITORIES_PUBLIC_ONLY
+ */
+ public URL[] getKnownRepositories(int flags);
+
+ /**
+ * Returns the property associated with the repository at the given URL,
+ * without loading the repository.
+ * <p>
+ * Note that some properties for a repository can only be
+ * determined when that repository is loaded. This method will return <code>null</code>
+ * for such properties. Only values for the properties that are already
+ * known by a repository manager will be returned.
+ * <p>
+ * If a client wishes to retrieve a property value from a repository
+ * regardless of the cost of retrieving it, the client should load the
+ * repository and then retrieve the property from the repository itself.
+ *
+ * @param location the URL of the repository in question
+ * @param key the String key of the property desired
+ * @return the value of the property, or <code>null</code> if the repository
+ * does not exist, the value does not exist, or the property value
+ * could not be determined without loading the repository.
+ *
+ * @see #loadRepository(URL, IProgressMonitor)
+ * @see IRepository#getProperties()
+ *
*/
- public URL[] getKnownRepositories();
+ public String getRepositoryProperty(URL location, String key);
/**
* Loads the repository at the given location. The location is expected to contain
diff --git a/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java b/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java
index d58d2849d..47d13b75f 100644
--- a/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java
+++ b/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java
@@ -159,7 +159,7 @@ public class ProvisioningHelper {
if (manager == null)
// TODO log here
return null;
- URL[] repos = manager.getKnownRepositories();
+ URL[] repos = manager.getKnownRepositories(IMetadataRepositoryManager.REPOSITORIES_ALL);
if (repos.length > 0)
return repos;
return null;
@@ -232,7 +232,7 @@ public class ProvisioningHelper {
if (manager == null)
// TODO log here
return null;
- URL[] repos = manager.getKnownRepositories();
+ URL[] repos = manager.getKnownRepositories(IArtifactRepositoryManager.REPOSITORIES_ALL);
if (repos.length > 0)
return repos;
return null;
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
index 786d688f2..9843cd4db 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
@@ -217,7 +217,7 @@ public class SimplePlanner implements IPlanner {
IMetadataRepositoryManager repoMgr = (IMetadataRepositoryManager) ServiceHelper.getService(DirectorActivator.context, IMetadataRepositoryManager.class.getName());
if (metadataRepositories == null)
- metadataRepositories = repoMgr.getKnownRepositories();
+ metadataRepositories = repoMgr.getKnownRepositories(IMetadataRepositoryManager.REPOSITORIES_ALL);
for (int i = 0; i < metadataRepositories.length; i++) {
IMetadataRepository repository = repoMgr.loadRepository(metadataRepositories[i], null);
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/phases/Sizing.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/phases/Sizing.java
index 02af76851..678db1b58 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/phases/Sizing.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/phases/Sizing.java
@@ -65,7 +65,7 @@ public class Sizing extends Phase {
}
IArtifactRepositoryManager repoMgr = (IArtifactRepositoryManager) ServiceHelper.getService(EngineActivator.getContext(), IArtifactRepositoryManager.class.getName());
- URL[] repositories = repoMgr.getKnownRepositories();
+ URL[] repositories = repoMgr.getKnownRepositories(IArtifactRepositoryManager.REPOSITORIES_ALL);
for (Iterator iterator = artifactsToObtain.iterator(); iterator.hasNext();) {
IArtifactRequest artifactRequest = (IArtifactRequest) iterator.next();
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryManager.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryManager.java
index 015e8abdd..ea281de23 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryManager.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryManager.java
@@ -18,6 +18,7 @@ import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.preferences.ConfigurationScope;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.core.helpers.URLUtil;
+import org.eclipse.equinox.p2.core.repository.IRepository;
import org.eclipse.equinox.p2.metadata.repository.IMetadataRepository;
import org.eclipse.equinox.p2.metadata.repository.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.query.Collector;
@@ -32,6 +33,7 @@ public class MetadataRepositoryManager implements IMetadataRepositoryManager {
String description;
URL location;
String name;
+ boolean implementationOnly = false;
SoftReference repository;
}
@@ -43,6 +45,7 @@ public class MetadataRepositoryManager implements IMetadataRepositoryManager {
private static final String KEY_TYPE = "type"; //$NON-NLS-1$
private static final String KEY_URL = "url"; //$NON-NLS-1$
private static final String KEY_VERSION = "version"; //$NON-NLS-1$
+ private static final String KEY_IMPLEMENTATION_ONLY = "implementationOnly"; //$NON-NLS-1$
private static final String NODE_REPOSITORIES = "repositories"; //$NON-NLS-1$
/**
@@ -63,6 +66,8 @@ public class MetadataRepositoryManager implements IMetadataRepositoryManager {
info.name = repository.getName();
info.description = repository.getDescription();
info.location = repository.getLocation();
+ String value = (String) repository.getProperties().get(IRepository.IMPLEMENTATION_ONLY_KEY);
+ info.implementationOnly = value == null ? false : Boolean.valueOf(value).booleanValue();
synchronized (repositoryLock) {
if (repositories == null)
restoreRepositories();
@@ -175,20 +180,33 @@ public class MetadataRepositoryManager implements IMetadataRepositoryManager {
return location.toExternalForm().replace('/', '_');
}
- public URL[] getKnownRepositories() {
+ public URL[] getKnownRepositories(int flags) {
synchronized (repositoryLock) {
if (repositories == null)
restoreRepositories();
- URL[] result = new URL[repositories.size()];
+ ArrayList result = new ArrayList();
int i = 0;
for (Iterator it = repositories.values().iterator(); it.hasNext(); i++) {
RepositoryInfo info = (RepositoryInfo) it.next();
- result[i] = info.location;
+ if (matchesFlags(info, flags))
+ result.add(info.location);
}
- return result;
+ return (URL[]) result.toArray(new URL[result.size()]);
}
}
+ private boolean matchesFlags(RepositoryInfo info, int flags) {
+ if ((flags & REPOSITORIES_IMPLEMENTATION_ONLY) == REPOSITORIES_IMPLEMENTATION_ONLY)
+ if (!info.implementationOnly)
+ return false;
+ if ((flags & REPOSITORIES_PUBLIC_ONLY) == REPOSITORIES_PUBLIC_ONLY)
+ if (info.implementationOnly)
+ return false;
+ if ((flags & REPOSITORIES_LOCAL_ONLY) == REPOSITORIES_LOCAL_ONLY)
+ return "file".equals(info.location.getProtocol()); //$NON-NLS-1$
+ return true;
+ }
+
/*
* Return the preference node which is the root for where we store the repository information.
*/
@@ -253,11 +271,28 @@ public class MetadataRepositoryManager implements IMetadataRepositoryManager {
LogHelper.log(new Status(IStatus.ERROR, Activator.PI_METADATA_REPOSITORY, message, t));
}
- /* (non-Javadoc)
- * @see org.eclipse.equinox.p2.query.IQueryable#query(org.eclipse.equinox.p2.query.Query, org.eclipse.equinox.p2.query.Collector, org.eclipse.core.runtime.IProgressMonitor)
+ /**
+ * Performs a query against all of the installable units of each known
+ * repository, accumulating any objects that satisfy the query in the
+ * provided collector.
+ * <p>
+ * Note that using this method can be quite expensive, as every known
+ * metadata repository will be loaded in order to query each one. If a
+ * client wishes to query only certain repositories, it is better to use
+ * {@link #getKnownRepositories(int)} to filter the list of repositories
+ * loaded and then query each of the returned repositories.
+ * <p>
+ * This method is long-running; progress and cancellation are provided
+ * by the given progress monitor.
+ *
+ * @param query The query to perform against each installable unit in each known repository
+ * @param collector Collects the results of the query
+ * @param monitor a progress monitor, or <code>null</code> if progress
+ * reporting is not desired
+ * @return The collector argument
*/
public Collector query(Query query, Collector collector, IProgressMonitor monitor) {
- URL[] locations = getKnownRepositories();
+ URL[] locations = getKnownRepositories(REPOSITORIES_ALL);
SubMonitor sub = SubMonitor.convert(monitor, locations.length * 10);
for (int i = 0; i < locations.length; i++) {
IMetadataRepository repository = loadRepository(locations[i], sub.newChild(9));
@@ -290,6 +325,10 @@ public class MetadataRepositoryManager implements IMetadataRepositoryManager {
value = repository.getVersion();
if (value != null)
node.put(KEY_VERSION, value);
+ value = (String) repository.getProperties().get(IRepository.IMPLEMENTATION_ONLY_KEY);
+ if (value != null)
+ node.put(KEY_IMPLEMENTATION_ONLY, value);
+
saveToPreferences();
}
@@ -299,6 +338,7 @@ public class MetadataRepositoryManager implements IMetadataRepositoryManager {
private void remember(RepositoryInfo info) {
Preferences node = getPreferences().node(getKey(info.location));
node.put(KEY_URL, info.location.toExternalForm());
+ node.put(KEY_IMPLEMENTATION_ONLY, Boolean.toString(info.implementationOnly));
if (info.description != null)
node.put(KEY_DESCRIPTION, info.description);
if (info.name != null)
@@ -348,6 +388,7 @@ public class MetadataRepositoryManager implements IMetadataRepositoryManager {
info.location = new URL(locationString);
info.name = child.get(KEY_NAME, null);
info.description = child.get(KEY_DESCRIPTION, null);
+ info.implementationOnly = child.getBoolean(KEY_IMPLEMENTATION_ONLY, false);
repositories.put(getKey(info.location), info);
} catch (MalformedURLException e) {
log("Error while restoring repository: " + locationString, e); //$NON-NLS-1$
@@ -396,4 +437,28 @@ public class MetadataRepositoryManager implements IMetadataRepositoryManager {
log("Error while saving repositories in preferences", e); //$NON-NLS-1$
}
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.equinox.p2.metadata.repository.IMetadataRepositoryManager#getRepositoryProperty(java.net.URL, java.lang.String)
+ */
+ public String getRepositoryProperty(URL location, String key) {
+ synchronized (repositoryLock) {
+ if (repositories == null)
+ restoreRepositories();
+ for (Iterator it = repositories.values().iterator(); it.hasNext();) {
+ RepositoryInfo info = (RepositoryInfo) it.next();
+ if (URLUtil.sameURL(info.location, location)) {
+ if (PROP_DESCRIPTION.equals(key))
+ return info.description;
+ if (PROP_NAME.equals(key))
+ return info.name;
+ // Key not known, return null
+ return null;
+ }
+ }
+ // Repository not found, return null
+ return null;
+ }
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/p2/metadata/repository/IMetadataRepositoryManager.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/p2/metadata/repository/IMetadataRepositoryManager.java
index eff7a4b16..e1c70b85f 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/p2/metadata/repository/IMetadataRepositoryManager.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/p2/metadata/repository/IMetadataRepositoryManager.java
@@ -12,9 +12,37 @@ package org.eclipse.equinox.p2.metadata.repository;
import java.net.URL;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.equinox.p2.core.repository.IRepository;
import org.eclipse.equinox.p2.query.IQueryable;
public interface IMetadataRepositoryManager extends IQueryable {
+
+ /**
+ * Constant used to indicate that all repositories are of interest.
+ */
+ public static final int REPOSITORIES_ALL = 0;
+ /**
+ * Constant used to indicate that implementation-only repositories are of interest.
+ */
+ public static final int REPOSITORIES_IMPLEMENTATION_ONLY = 1 << 1;
+ /**
+ * Constant used to indicate that public (non-implementation-only) repositories are of interest.
+ */
+ public static final int REPOSITORIES_PUBLIC_ONLY = 1 << 2;
+ /**
+ * Constant used to indicate that local repositories are of interest.
+ */
+ public static final int REPOSITORIES_LOCAL_ONLY = 1 << 3;
+
+ /**
+ * Property key used to query a repository's name without loading the repository first.
+ */
+ public static final String PROP_NAME = "name"; //$NON-NLS-1$
+ /**
+ * Property key used to query a repository's description without loading the repository first.
+ */
+ public static final String PROP_DESCRIPTION = "description"; //$NON-NLS-1$
+
/**
* Repository type for a simple repository based on a URL or local file system location.
*/
@@ -46,9 +74,18 @@ public interface IMetadataRepositoryManager extends IQueryable {
* A subsequent attempt to load a repository at any of the given locations may
* or may not succeed.
*
+ * @param flags an integer bit-mask indicating which repositories should be
+ * returned. <code>REPOSITORIES_ALL</code> can be used as the mask when
+ * all repositories should be returned.
+ *
* @return the locations of the repositories managed by this repository manager.
+ *
+ * @see #REPOSITORIES_ALL
+ * @see #REPOSITORIES_IMPLEMENTATION_ONLY
+ * @see #REPOSITORIES_LOCAL_ONLY
+ * @see #REPOSITORIES_PUBLIC_ONLY
*/
- public URL[] getKnownRepositories();
+ public URL[] getKnownRepositories(int flags);
/**
* Loads a repository corresponding to the given URL.
@@ -69,4 +106,29 @@ public interface IMetadataRepositoryManager extends IQueryable {
* <code>false</code> otherwise.
*/
public boolean removeRepository(URL location);
+
+ /**
+ * Returns the property associated with the repository at the given URL,
+ * without loading the repository.
+ * <p>
+ * Note that some properties for a repository can only be
+ * determined when that repository is loaded. This method will return <code>null</code>
+ * for such properties. Only values for the properties that are already
+ * known by a repository manager will be returned.
+ * <p>
+ * If a client wishes to retrieve a property value from a repository
+ * regardless of the cost of retrieving it, the client should load the
+ * repository and then retrieve the property from the repository itself.
+ *
+ * @param location the URL of the repository in question
+ * @param key the String key of the property desired
+ * @return the value of the property, or <code>null</code> if the repository
+ * does not exist, the value does not exist, or the property value
+ * could not be determined without loading the repository.
+ *
+ * @see #loadRepository(URL, IProgressMonitor)
+ * @see IRepository#getProperties()
+ *
+ */
+ public String getRepositoryProperty(URL location, String key);
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java
index e62ded039..fbd92d3f0 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java
@@ -65,7 +65,7 @@ public class MetadataRepositoryManagerTest extends AbstractProvisioningTest {
* to a repository at the given location.
*/
private boolean managerContains(URL location) {
- URL[] locations = manager.getKnownRepositories();
+ URL[] locations = manager.getKnownRepositories(IMetadataRepositoryManager.REPOSITORIES_ALL);
for (int i = 0; i < locations.length; i++) {
if (locations[i].equals(location))
return true;
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java
index b5a8b05fa..d33b7a71a 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java
@@ -89,7 +89,7 @@ public class Util {
bundleRepositories.add(Util.getBundlePoolRepository(profile));
IArtifactRepositoryManager manager = getArtifactRepositoryManager();
- URL[] knownRepositories = manager.getKnownRepositories();
+ URL[] knownRepositories = manager.getKnownRepositories(IArtifactRepositoryManager.REPOSITORIES_ALL);
for (int i = 0; i < knownRepositories.length; i++) {
IArtifactRepository repository = manager.loadRepository(knownRepositories[i], null);
if (repository == null)
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ArtifactRepositoriesView.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ArtifactRepositoriesView.java
index 2bee45b42..431d0a680 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ArtifactRepositoriesView.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ArtifactRepositoriesView.java
@@ -10,11 +10,12 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.admin;
+import java.net.URL;
import java.util.ArrayList;
import org.eclipse.equinox.internal.p2.ui.admin.dialogs.AddArtifactRepositoryDialog;
-import org.eclipse.equinox.p2.artifact.repository.IArtifactRepository;
-import org.eclipse.equinox.p2.ui.ProvUI;
+import org.eclipse.equinox.internal.p2.ui.model.ArtifactRepositoryElement;
import org.eclipse.equinox.p2.ui.model.ArtifactRepositories;
+import org.eclipse.equinox.p2.ui.model.RepositoryElement;
import org.eclipse.equinox.p2.ui.operations.ProvisioningOperation;
import org.eclipse.equinox.p2.ui.operations.RemoveArtifactRepositoryOperation;
import org.eclipse.swt.widgets.Shell;
@@ -49,22 +50,21 @@ public class ArtifactRepositoriesView extends RepositoriesView {
return ProvAdminUIMessages.ArtifactRepositoriesView_RemoveRepositoryTooltip;
}
- protected int openAddRepositoryDialog(Shell shell, Object[] elements) {
- return new AddArtifactRepositoryDialog(shell, elements).open();
+ protected int openAddRepositoryDialog(Shell shell, URL[] knownRepos) {
+ return new AddArtifactRepositoryDialog(shell, knownRepos).open();
}
protected ProvisioningOperation getRemoveOperation(Object[] elements) {
- ArrayList repos = new ArrayList();
+ ArrayList urls = new ArrayList();
for (int i = 0; i < elements.length; i++) {
- IArtifactRepository repo = (IArtifactRepository) ProvUI.getAdapter(elements[i], IArtifactRepository.class);
- if (repo != null)
- repos.add(repo);
+ if (elements[i] instanceof RepositoryElement)
+ urls.add(((RepositoryElement) elements[i]).getURL());
}
- return new RemoveArtifactRepositoryOperation(ProvAdminUIMessages.ArtifactRepositoriesView_RemoveRepositoryOperationLabel, (IArtifactRepository[]) repos.toArray(new IArtifactRepository[repos.size()]));
+ return new RemoveArtifactRepositoryOperation(ProvAdminUIMessages.ArtifactRepositoriesView_RemoveRepositoryOperationLabel, (URL[]) urls.toArray(new URL[urls.size()]));
}
protected boolean isRepository(Object element) {
- return ProvUI.getAdapter(element, IArtifactRepository.class) != null;
+ return element instanceof ArtifactRepositoryElement;
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoriesView.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoriesView.java
index 581043437..b8e67981d 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoriesView.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoriesView.java
@@ -10,18 +10,17 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.admin;
+import java.net.URL;
import java.util.ArrayList;
import org.eclipse.equinox.internal.p2.ui.admin.dialogs.AddMetadataRepositoryDialog;
import org.eclipse.equinox.internal.p2.ui.admin.dialogs.AddProfileDialog;
import org.eclipse.equinox.p2.engine.Profile;
-import org.eclipse.equinox.p2.metadata.repository.IMetadataRepository;
import org.eclipse.equinox.p2.ui.IProfileChooser;
import org.eclipse.equinox.p2.ui.ProvUI;
import org.eclipse.equinox.p2.ui.actions.InstallAction;
import org.eclipse.equinox.p2.ui.actions.RevertAction;
import org.eclipse.equinox.p2.ui.admin.ProvAdminUIActivator;
-import org.eclipse.equinox.p2.ui.model.MetadataRepositories;
-import org.eclipse.equinox.p2.ui.model.Profiles;
+import org.eclipse.equinox.p2.ui.model.*;
import org.eclipse.equinox.p2.ui.operations.ProvisioningOperation;
import org.eclipse.equinox.p2.ui.operations.RemoveMetadataRepositoryOperation;
import org.eclipse.equinox.p2.ui.viewers.*;
@@ -67,18 +66,17 @@ public class MetadataRepositoriesView extends RepositoriesView {
return ProvAdminUIMessages.MetadataRepositoriesView_RemoveRepositoryTooltip;
}
- protected int openAddRepositoryDialog(Shell shell, Object[] elements) {
- return new AddMetadataRepositoryDialog(shell, elements).open();
+ protected int openAddRepositoryDialog(Shell shell, URL[] knownRepos) {
+ return new AddMetadataRepositoryDialog(shell, knownRepos).open();
}
protected ProvisioningOperation getRemoveOperation(Object[] elements) {
- ArrayList repos = new ArrayList();
+ ArrayList urls = new ArrayList();
for (int i = 0; i < elements.length; i++) {
- IMetadataRepository repo = (IMetadataRepository) ProvUI.getAdapter(elements[i], IMetadataRepository.class);
- if (repo != null)
- repos.add(repo);
+ if (elements[i] instanceof RepositoryElement)
+ urls.add(((RepositoryElement) elements[i]).getURL());
}
- return new RemoveMetadataRepositoryOperation(ProvAdminUIMessages.MetadataRepositoriesView_RemoveRepositoryOperationLabel, (IMetadataRepository[]) repos.toArray(new IMetadataRepository[repos.size()]));
+ return new RemoveMetadataRepositoryOperation(ProvAdminUIMessages.ArtifactRepositoriesView_RemoveRepositoryOperationLabel, (URL[]) urls.toArray(new URL[urls.size()]));
}
protected void makeActions() {
@@ -133,7 +131,7 @@ public class MetadataRepositoriesView extends RepositoriesView {
}
protected boolean isRepository(Object element) {
- return ProvUI.getAdapter(element, IMetadataRepository.class) != null;
+ return element instanceof MetadataRepositoryElement;
}
protected void configureViewer(final TreeViewer treeViewer) {
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminQueryProvider.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminQueryProvider.java
index 568247892..81b969069 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminQueryProvider.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminQueryProvider.java
@@ -11,12 +11,13 @@
package org.eclipse.equinox.internal.p2.ui.admin;
import org.eclipse.equinox.internal.p2.ui.admin.preferences.PreferenceConstants;
-import org.eclipse.equinox.p2.core.repository.IRepository;
+import org.eclipse.equinox.p2.artifact.repository.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.metadata.query.CapabilityQuery;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.metadata.repository.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.query.*;
import org.eclipse.equinox.p2.ui.ProvUI;
import org.eclipse.equinox.p2.ui.admin.ProvAdminUIActivator;
@@ -54,8 +55,8 @@ public class ProvAdminQueryProvider implements IProvElementQueryProvider {
switch (queryType) {
case IProvElementQueryProvider.ARTIFACT_REPOS :
queryable = new QueryableArtifactRepositoryManager();
- query = hideImpl ? new RepositoryPropertyQuery(IRepository.IMPLEMENTATION_ONLY_KEY, Boolean.toString(true), false) : allQuery;
- return new ElementQueryDescriptor(queryable, query, new QueriedElementCollector(this, queryable));
+ query = hideImpl ? new FilteredRepositoryQuery(IArtifactRepositoryManager.REPOSITORIES_PUBLIC_ONLY) : allQuery;
+ return new ElementQueryDescriptor(queryable, query, new RepositoryCollector(this, queryable));
case IProvElementQueryProvider.AVAILABLE_IUS :
// Is it a rollback repository?
if (element instanceof RollbackRepositoryElement) {
@@ -114,8 +115,8 @@ public class ProvAdminQueryProvider implements IProvElementQueryProvider {
return new ElementQueryDescriptor(profile, query, new InstalledIUCollector(this, profile));
case IProvElementQueryProvider.METADATA_REPOS :
queryable = new QueryableMetadataRepositoryManager();
- query = hideImpl ? new RepositoryPropertyQuery(IRepository.IMPLEMENTATION_ONLY_KEY, Boolean.toString(true), false) : allQuery;
- return new ElementQueryDescriptor(queryable, query, new QueriedElementCollector(this, queryable));
+ query = hideImpl ? new FilteredRepositoryQuery(IMetadataRepositoryManager.REPOSITORIES_PUBLIC_ONLY) : allQuery;
+ return new ElementQueryDescriptor(queryable, query, new RepositoryCollector(this, queryable));
case IProvElementQueryProvider.PROFILES :
queryable = new QueryableProfileRegistry();
return new ElementQueryDescriptor(queryable, new Query() {
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/RepositoriesView.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/RepositoriesView.java
index f0ecafbce..0dc5deed0 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/RepositoriesView.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/RepositoriesView.java
@@ -10,11 +10,14 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.admin;
+import java.net.URL;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.equinox.internal.p2.ui.admin.preferences.PreferenceConstants;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.ui.*;
import org.eclipse.equinox.p2.ui.admin.ProvAdminUIActivator;
+import org.eclipse.equinox.p2.ui.model.RepositoryElement;
import org.eclipse.equinox.p2.ui.operations.ProvisioningOperation;
import org.eclipse.equinox.p2.ui.viewers.RepositoryContentProvider;
import org.eclipse.equinox.p2.ui.viewers.StructuredViewerProvisioningListener;
@@ -57,7 +60,12 @@ abstract class RepositoriesView extends ProvView {
}
public void run() {
- openAddRepositoryDialog(getShell(), ((ITreeContentProvider) viewer.getContentProvider()).getElements(getInput()));
+ Object[] elements = ((ITreeContentProvider) viewer.getContentProvider()).getElements(getInput());
+ ArrayList urls = new ArrayList();
+ for (int i = 0; i < elements.length; i++)
+ if (elements[i] instanceof RepositoryElement)
+ urls.add(((RepositoryElement) elements[i]).getURL());
+ openAddRepositoryDialog(getShell(), (URL[]) urls.toArray(new URL[urls.size()]));
}
}
@@ -153,7 +161,7 @@ abstract class RepositoriesView extends ProvView {
}
- protected abstract int openAddRepositoryDialog(Shell shell, Object[] elements);
+ protected abstract int openAddRepositoryDialog(Shell shell, URL[] knownRepos);
protected abstract ProvisioningOperation getRemoveOperation(Object[] elements);
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/AddArtifactRepositoryDialog.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/AddArtifactRepositoryDialog.java
index c93ed074c..a73e6bab6 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/AddArtifactRepositoryDialog.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/AddArtifactRepositoryDialog.java
@@ -10,10 +10,8 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.admin.dialogs;
-import java.net.MalformedURLException;
import java.net.URL;
import org.eclipse.equinox.internal.p2.ui.admin.ProvAdminUIMessages;
-import org.eclipse.equinox.p2.ui.ProvUI;
import org.eclipse.equinox.p2.ui.dialogs.AddRepositoryDialog;
import org.eclipse.equinox.p2.ui.operations.AddArtifactRepositoryOperation;
import org.eclipse.equinox.p2.ui.operations.ProvisioningOperation;
@@ -27,7 +25,7 @@ import org.eclipse.swt.widgets.Shell;
*/
public class AddArtifactRepositoryDialog extends AddRepositoryDialog {
- public AddArtifactRepositoryDialog(Shell parentShell, Object[] knownRepositories) {
+ public AddArtifactRepositoryDialog(Shell parentShell, URL[] knownRepositories) {
super(parentShell, knownRepositories);
}
@@ -35,16 +33,10 @@ public class AddArtifactRepositoryDialog extends AddRepositoryDialog {
return new AddArtifactRepositoryOperation(ProvAdminUIMessages.AddArtifactRepositoryDialog_OperationLabel, url);
}
- protected URL makeRepositoryURL(String urlString) {
- try {
- return new URL(urlString);
- } catch (MalformedURLException e) {
- // TODO need friendlier user message rather than just reporting exception
- ProvUI.handleException(e, ProvAdminUIMessages.AddRepositoryDialog_InvalidURL);
- return null;
- }
+ protected URL makeRepositoryURL(URL newURL) {
// TODO need to do better validation of the URL
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=211102
-
+ // For now we don't further process the URL
+ return newURL;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/AddMetadataRepositoryDialog.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/AddMetadataRepositoryDialog.java
index fd8cd4d8f..4427b8b7e 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/AddMetadataRepositoryDialog.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/AddMetadataRepositoryDialog.java
@@ -10,10 +10,8 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.admin.dialogs;
-import java.net.MalformedURLException;
import java.net.URL;
import org.eclipse.equinox.internal.p2.ui.admin.ProvAdminUIMessages;
-import org.eclipse.equinox.p2.ui.ProvUI;
import org.eclipse.equinox.p2.ui.dialogs.AddRepositoryDialog;
import org.eclipse.equinox.p2.ui.operations.AddMetadataRepositoryOperation;
import org.eclipse.equinox.p2.ui.operations.ProvisioningOperation;
@@ -27,7 +25,7 @@ import org.eclipse.swt.widgets.Shell;
*/
public class AddMetadataRepositoryDialog extends AddRepositoryDialog {
- public AddMetadataRepositoryDialog(Shell parentShell, Object[] knownRepositories) {
+ public AddMetadataRepositoryDialog(Shell parentShell, URL[] knownRepositories) {
super(parentShell, knownRepositories);
}
@@ -35,16 +33,10 @@ public class AddMetadataRepositoryDialog extends AddRepositoryDialog {
return new AddMetadataRepositoryOperation(ProvAdminUIMessages.AddMetadataRepositoryDialog_OperationLabel, url);
}
- protected URL makeRepositoryURL(String urlString) {
- try {
- return new URL(urlString);
- } catch (MalformedURLException e) {
- // TODO need friendlier user message rather than just reporting exception
- ProvUI.handleException(e, ProvAdminUIMessages.AddRepositoryDialog_InvalidURL);
- return null;
- }
+ protected URL makeRepositoryURL(URL newURL) {
// TODO need to do better validation of the URL
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=211102
-
+ // For now we don't further process the URL
+ return newURL;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/AddColocatedRepositoryDialog.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/AddColocatedRepositoryDialog.java
index 762b2813c..79f4aa412 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/AddColocatedRepositoryDialog.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/AddColocatedRepositoryDialog.java
@@ -12,8 +12,6 @@ package org.eclipse.equinox.internal.p2.ui.sdk;
import java.net.MalformedURLException;
import java.net.URL;
-import org.eclipse.equinox.p2.core.repository.IRepository;
-import org.eclipse.equinox.p2.ui.ProvUI;
import org.eclipse.equinox.p2.ui.dialogs.AddRepositoryDialog;
import org.eclipse.equinox.p2.ui.operations.AddColocatedRepositoryOperation;
import org.eclipse.equinox.p2.ui.operations.ProvisioningOperation;
@@ -28,7 +26,7 @@ import org.eclipse.swt.widgets.Shell;
*/
public class AddColocatedRepositoryDialog extends AddRepositoryDialog {
- public AddColocatedRepositoryDialog(Shell parentShell, IRepository[] knownRepositories) {
+ public AddColocatedRepositoryDialog(Shell parentShell, URL[] knownRepositories) {
super(parentShell, knownRepositories);
}
@@ -37,25 +35,16 @@ public class AddColocatedRepositoryDialog extends AddRepositoryDialog {
return new AddColocatedRepositoryOperation(getShell().getText(), url);
}
- protected URL makeRepositoryURL(String urlString) {
+ protected URL makeRepositoryURL(URL userURL) {
// TODO need to do better validation of the URL
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=211102
- URL newURL;
- try {
- newURL = new URL(urlString);
- } catch (MalformedURLException e) {
- // TODO need friendlier user message rather than just reporting exception
- ProvUI.handleException(e, ProvSDKMessages.AddColocatedRepositoryDialog_InvalidURL);
- return null;
- }
- String urlSpec = newURL.toExternalForm();
+ String urlSpec = userURL.toExternalForm();
try {
if (!urlSpec.endsWith("/")) //$NON-NLS-1$
urlSpec += "/"; //$NON-NLS-1$
- newURL = new URL(urlSpec);
+ return new URL(urlSpec);
} catch (MalformedURLException e) {
return null;
}
- return newURL;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKQueryProvider.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKQueryProvider.java
index f5ad9c312..64d7e205c 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKQueryProvider.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKQueryProvider.java
@@ -11,12 +11,13 @@
package org.eclipse.equinox.internal.p2.ui.sdk;
import org.eclipse.equinox.internal.p2.ui.sdk.prefs.PreferenceConstants;
-import org.eclipse.equinox.p2.core.repository.IRepository;
+import org.eclipse.equinox.p2.artifact.repository.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.metadata.query.CapabilityQuery;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.metadata.repository.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.query.*;
import org.eclipse.equinox.p2.ui.ProvUI;
import org.eclipse.equinox.p2.ui.model.*;
@@ -43,7 +44,7 @@ public class ProvSDKQueryProvider implements IProvElementQueryProvider {
switch (queryType) {
case IProvElementQueryProvider.ARTIFACT_REPOS :
queryable = new QueryableArtifactRepositoryManager();
- return new ElementQueryDescriptor(queryable, new RepositoryPropertyQuery(IRepository.IMPLEMENTATION_ONLY_KEY, Boolean.toString(true), false), new QueriedElementCollector(this, queryable));
+ return new ElementQueryDescriptor(queryable, new FilteredRepositoryQuery(IArtifactRepositoryManager.REPOSITORIES_PUBLIC_ONLY), new RepositoryCollector(this, queryable));
case IProvElementQueryProvider.AVAILABLE_IUS :
if (element instanceof RollbackRepositoryElement) {
Query profileIdQuery = new InstallableUnitQuery(((RollbackRepositoryElement) element).getProfileId());
@@ -79,7 +80,7 @@ public class ProvSDKQueryProvider implements IProvElementQueryProvider {
return new ElementQueryDescriptor(profile, new IUProfilePropertyQuery(profile, IInstallableUnit.PROP_PROFILE_ROOT_IU, Boolean.toString(true)), new InstalledIUCollector(this, profile));
case IProvElementQueryProvider.METADATA_REPOS :
queryable = new QueryableMetadataRepositoryManager();
- return new ElementQueryDescriptor(queryable, new RepositoryPropertyQuery(IRepository.IMPLEMENTATION_ONLY_KEY, Boolean.toString(true), false), new QueriedElementCollector(this, queryable));
+ return new ElementQueryDescriptor(queryable, new FilteredRepositoryQuery(IMetadataRepositoryManager.REPOSITORIES_PUBLIC_ONLY), new RepositoryCollector(this, queryable));
case IProvElementQueryProvider.PROFILES :
queryable = new QueryableProfileRegistry();
return new ElementQueryDescriptor(queryable, new Query() {
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/RepositoryManipulationDialog.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/RepositoryManipulationDialog.java
index b4f635b3f..f7699e060 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/RepositoryManipulationDialog.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/RepositoryManipulationDialog.java
@@ -10,12 +10,14 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.sdk;
+import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.equinox.p2.core.ProvisionException;
-import org.eclipse.equinox.p2.metadata.repository.IMetadataRepository;
+import org.eclipse.equinox.p2.metadata.repository.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.ui.*;
import org.eclipse.equinox.p2.ui.model.MetadataRepositories;
+import org.eclipse.equinox.p2.ui.model.MetadataRepositoryElement;
import org.eclipse.equinox.p2.ui.operations.ProvisioningUtil;
import org.eclipse.equinox.p2.ui.operations.RemoveColocatedRepositoryOperation;
import org.eclipse.equinox.p2.ui.viewers.*;
@@ -183,7 +185,7 @@ public class RepositoryManipulationDialog extends TrayDialog {
button.setData(BUTTONACTION, new Action() {
public void runWithEvent(Event event) {
try {
- new AddColocatedRepositoryDialog(getShell(), ProvisioningUtil.getMetadataRepositories()).open();
+ new AddColocatedRepositoryDialog(getShell(), ProvisioningUtil.getMetadataRepositories(IMetadataRepositoryManager.REPOSITORIES_PUBLIC_ONLY)).open();
} catch (ProvisionException e) {
ProvUI.handleException(e, null);
}
@@ -193,14 +195,13 @@ public class RepositoryManipulationDialog extends TrayDialog {
button.setData(BUTTONACTION, new Action() {
public void runWithEvent(Event event) {
Object[] selection = ((IStructuredSelection) repositoryViewer.getSelection()).toArray();
- List repos = new ArrayList();
+ List urls = new ArrayList();
for (int i = 0; i < selection.length; i++) {
- IMetadataRepository repo = (IMetadataRepository) ProvUI.getAdapter(selection[i], IMetadataRepository.class);
- if (repo != null)
- repos.add(repo);
+ if (selection[i] instanceof MetadataRepositoryElement)
+ urls.add(((MetadataRepositoryElement) selection[i]).getURL());
}
- if (repos.size() > 0) {
- RemoveColocatedRepositoryOperation op = new RemoveColocatedRepositoryOperation(ProvSDKMessages.RepositoryManipulationDialog_RemoveOperationLabel, (IMetadataRepository[]) repos.toArray(new IMetadataRepository[repos.size()]));
+ if (urls.size() > 0) {
+ RemoveColocatedRepositoryOperation op = new RemoveColocatedRepositoryOperation(ProvSDKMessages.RepositoryManipulationDialog_RemoveOperationLabel, (URL[]) urls.toArray(new URL[urls.size()]));
ProvisioningOperationRunner.schedule(op, getShell());
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java
index 0d7a7e6de..1709083b3 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java
@@ -114,8 +114,10 @@ public class ProvUIMessages extends NLS {
// Dialogs
public static String AddRepositoryDialog_DuplicateURL;
+ public static String AddRepositoryDialog_InvalidURL;
public static String AddRepositoryDialog_Title;
public static String AvailableIUElement_ProfileNotFound;
+ public static String MetadataRepositoryElement_RepositoryLoadError;
public static String UpdateAction_UpdateInformationTitle;
public static String UpdateAction_UpdatesAvailableMessage;
public static String UpdateDialog_AssemblingUpdatesProgress;
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RevertProfileWizardPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RevertProfileWizardPage.java
index 6790123a7..4c6133e93 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RevertProfileWizardPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RevertProfileWizardPage.java
@@ -128,7 +128,7 @@ public class RevertProfileWizardPage extends WizardPage {
private Object getInput() {
try {
- RollbackRepositoryElement element = new RollbackRepositoryElement(ProvisioningUtil.getRollbackRepository(null), profileId);
+ RollbackRepositoryElement element = new RollbackRepositoryElement(ProvisioningUtil.getRollbackRepositoryURL(), profileId);
element.setQueryProvider(queryProvider);
return element;
} catch (ProvisionException e) {
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties
index 2adec126c..7b0510702 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties
@@ -86,6 +86,7 @@ AcceptLicensesWizardPage_ReviewLicensesDescription=Licenses must be reviewed and
AcceptLicensesWizardPage_Title=Review Licenses
AddRepositoryDialog_Title=Add Repository
AddRepositoryDialog_DuplicateURL=Duplicate URL
+AddRepositoryDialog_InvalidURL=The provided URL is not valid
UpdateAndInstallGroup_Properties=&Properties...
UpdateAndInstallSelectionDialog_DeselectAllLabel=&Deselect All
@@ -117,6 +118,7 @@ but it may be possible to apply the changes you have made without restarting. \
Would you like to restart now?
ApplyProfileChangesDialog_ApplyChanges=Apply Changes
AvailableIUElement_ProfileNotFound=Could not find profile to use for size computation.
+MetadataRepositoryElement_RepositoryLoadError=Error loading repository {0}
QueryableArtifactRepositoryManager_RepositoryQueryProgress=Getting artifact repositories
QueryableMetadataRepositoryManager_RepositoryQueryProgress=Getting repositories
QueryableProfileRegistry_QueryProfileProgress=Getting profiles
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ArtifactRepositoryElement.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ArtifactRepositoryElement.java
index c76131fb4..3beaa892a 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ArtifactRepositoryElement.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ArtifactRepositoryElement.java
@@ -10,11 +10,21 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.model;
+import java.net.URL;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.p2.artifact.repository.IArtifactRepository;
+import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.core.repository.IRepository;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.ui.ProvUI;
import org.eclipse.equinox.p2.ui.ProvUIImages;
+import org.eclipse.equinox.p2.ui.model.RepositoryElement;
+import org.eclipse.equinox.p2.ui.operations.ProvisioningUtil;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
+import org.eclipse.ui.progress.IElementCollector;
/**
* Element wrapper class for a artifact repository that gets its
@@ -22,19 +32,20 @@ import org.eclipse.equinox.p2.ui.ProvUIImages;
*
* @since 3.4
*/
-public class ArtifactRepositoryElement extends RemoteQueriedElement {
+public class ArtifactRepositoryElement extends ProvElement implements IDeferredWorkbenchAdapter, RepositoryElement {
+ URL url;
IArtifactRepository repo;
- public ArtifactRepositoryElement(IArtifactRepository repo) {
- this.repo = repo;
+ public ArtifactRepositoryElement(URL url) {
+ this.url = url;
}
public Object getAdapter(Class adapter) {
if (adapter == IArtifactRepository.class)
- return repo;
+ return getRepository(null);
if (adapter == IRepository.class)
- return repo;
+ return getRepository(null);
return super.getAdapter(adapter);
}
@@ -43,7 +54,7 @@ public class ArtifactRepositoryElement extends RemoteQueriedElement {
}
protected Object[] fetchChildren(Object o, IProgressMonitor monitor) {
- IArtifactKey[] keys = repo.getArtifactKeys();
+ IArtifactKey[] keys = getRepository(monitor).getArtifactKeys();
ArtifactElement[] elements = new ArtifactElement[keys.length];
for (int i = 0; i < keys.length; i++) {
elements[i] = new ArtifactElement(keys[i], repo);
@@ -52,17 +63,58 @@ public class ArtifactRepositoryElement extends RemoteQueriedElement {
}
public String getLabel(Object o) {
- String name = repo.getName();
+ String name = getName();
if (name != null && name.length() > 0) {
return name;
}
- return repo.getLocation().toExternalForm();
+ return getURL().toExternalForm();
+ }
+
+ private IArtifactRepository getRepository(IProgressMonitor monitor) {
+ if (repo == null)
+ try {
+ repo = ProvisioningUtil.loadArtifactRepository(url, monitor);
+ } catch (ProvisionException e) {
+ ProvUI.handleException(e, NLS.bind(ProvUIMessages.MetadataRepositoryElement_RepositoryLoadError, url));
+ }
+ return repo;
+ }
+
+ public ISchedulingRule getRule(Object object) {
+ return null;
+ }
+
+ public boolean isContainer() {
+ return true;
+ }
+ public void fetchDeferredChildren(Object o, IElementCollector collector, IProgressMonitor monitor) {
+ collector.add(fetchChildren(o, monitor), monitor);
}
- // Not used because we override fetchChildren
- protected int getQueryType() {
- return 0;
+ public Object[] getChildren(Object o) {
+ return fetchChildren(o, null);
}
+ public Object getParent(Object o) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.equinox.p2.ui.model.RepositoryElement#getURL()
+ */
+ public URL getURL() {
+ return url;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.equinox.p2.ui.model.RepositoryElement#getName()
+ */
+ public String getName() {
+ try {
+ return ProvisioningUtil.getArtifactRepositoryName(url);
+ } catch (ProvisionException e) {
+ return ""; //$NON-NLS-1$
+ }
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/QueriedElementCollector.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/QueriedElementCollector.java
index c733d0a56..b17143eb3 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/QueriedElementCollector.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/QueriedElementCollector.java
@@ -8,10 +8,12 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.equinox.p2.ui.query;
+package org.eclipse.equinox.internal.p2.ui.model;
import org.eclipse.equinox.p2.query.Collector;
import org.eclipse.equinox.p2.query.IQueryable;
+import org.eclipse.equinox.p2.ui.query.IProvElementQueryProvider;
+import org.eclipse.equinox.p2.ui.query.QueriedElement;
/**
* Collector that assigns a query provider and the queryable
@@ -20,10 +22,10 @@ import org.eclipse.equinox.p2.query.IQueryable;
*
* @since 3.4
*/
-public class QueriedElementCollector extends Collector {
+public abstract class QueriedElementCollector extends Collector {
- IProvElementQueryProvider queryProvider;
- IQueryable queryable;
+ protected IProvElementQueryProvider queryProvider;
+ protected IQueryable queryable;
public QueriedElementCollector(IProvElementQueryProvider queryProvider, IQueryable queryable) {
this.queryProvider = queryProvider;
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/AddRepositoryDialog.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/AddRepositoryDialog.java
index 9a3b1b955..47ad78e6a 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/AddRepositoryDialog.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/AddRepositoryDialog.java
@@ -10,13 +10,13 @@
*******************************************************************************/
package org.eclipse.equinox.p2.ui.dialogs;
+import java.net.MalformedURLException;
import java.net.URL;
-import java.util.ArrayList;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
-import org.eclipse.equinox.p2.core.repository.IRepository;
-import org.eclipse.equinox.p2.ui.*;
+import org.eclipse.equinox.p2.ui.ProvUIActivator;
+import org.eclipse.equinox.p2.ui.ProvisioningOperationRunner;
import org.eclipse.equinox.p2.ui.operations.ProvisioningOperation;
import org.eclipse.jface.dialogs.*;
import org.eclipse.jface.dialogs.Dialog;
@@ -39,15 +39,15 @@ public abstract class AddRepositoryDialog extends StatusDialog {
Button okButton;
Text url;
- IRepository[] knownRepositories;
+ URL[] knownRepositories;
static final String[] ARCHIVE_EXTENSIONS = new String[] {"*.jar;*.zip"}; //$NON-NLS-1$
static String lastLocalLocation = null;
static String lastArchiveLocation = null;
- public AddRepositoryDialog(Shell parentShell, Object[] knownRepositories) {
+ public AddRepositoryDialog(Shell parentShell, URL[] knownRepositories) {
super(parentShell);
- this.knownRepositories = makeRepositories(knownRepositories);
+ this.knownRepositories = knownRepositories;
setTitle(ProvUIMessages.AddRepositoryDialog_Title);
}
@@ -124,22 +124,33 @@ public abstract class AddRepositoryDialog extends StatusDialog {
}
protected void okPressed() {
- if (addRepository())
+ IStatus status = addRepository();
+ if (status.isOK())
super.okPressed();
+ setOkEnablement(false);
+ updateStatus(status);
+
}
- protected boolean addRepository() {
- URL newURL = makeRepositoryURL(url.getText().trim());
+ protected IStatus addRepository() {
+ URL userURL;
+ try {
+ userURL = new URL(url.getText().trim());
+ } catch (MalformedURLException e) {
+ return new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, 0, ProvUIMessages.AddRepositoryDialog_InvalidURL, null);
+ }
+
+ URL newURL = makeRepositoryURL(userURL);
if (newURL != null) {
ProvisioningOperationRunner.schedule(getOperation(newURL), getShell());
- return true;
+ return Status.OK_STATUS;
}
- return false;
+ return new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, 0, ProvUIMessages.AddRepositoryDialog_InvalidURL, null);
}
protected abstract ProvisioningOperation getOperation(URL repoURL);
- protected abstract URL makeRepositoryURL(String urlString);
+ protected abstract URL makeRepositoryURL(URL userURL);
void verifyComplete() {
if (okButton == null) {
@@ -150,12 +161,17 @@ public abstract class AddRepositoryDialog extends StatusDialog {
if (urlText.length() == 0) {
status = new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, 0, ProvUIMessages.RepositoryGroup_URLRequired, null);
} else {
- for (int i = 0; i < knownRepositories.length; i++) {
- URL repURL = knownRepositories[i].getLocation();
- if (repURL != null && repURL.equals(urlText)) {
- status = new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, IStatus.OK, ProvUIMessages.AddRepositoryDialog_DuplicateURL, null);
- break;
+ URL userURL;
+ try {
+ userURL = new URL(urlText);
+ for (int i = 0; i < knownRepositories.length; i++) {
+ if (knownRepositories[i].equals(userURL)) {
+ status = new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, IStatus.OK, ProvUIMessages.AddRepositoryDialog_DuplicateURL, null);
+ break;
+ }
}
+ } catch (MalformedURLException e) {
+ // we don't report this until the user is done typing.
}
}
setOkEnablement(status.isOK());
@@ -170,14 +186,4 @@ public abstract class AddRepositoryDialog extends StatusDialog {
if (okButton != null && !okButton.isDisposed())
okButton.setEnabled(enable);
}
-
- private IRepository[] makeRepositories(Object[] elements) {
- ArrayList list = new ArrayList();
- for (int i = 0; i < elements.length; i++) {
- IRepository repo = (IRepository) ProvUI.getAdapter(elements[i], IRepository.class);
- if (repo != null)
- list.add(repo);
- }
- return (IRepository[]) list.toArray(new IRepository[list.size()]);
- }
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/RepositoryPropertyPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/RepositoryPropertyPage.java
index 47f378102..6e8800f61 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/RepositoryPropertyPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/RepositoryPropertyPage.java
@@ -33,6 +33,8 @@ public class RepositoryPropertyPage extends PropertyPage {
private Text url;
protected Control createContents(Composite parent) {
+ // TODO if all we are ever going to show is the name, URL, and
+ // description, this could be done without loading the repo.
this.repository = getRepository();
if (repository == null) {
Label label = new Label(parent, SWT.DEFAULT);
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UpdateAndInstallGroup.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UpdateAndInstallGroup.java
index f4929c9bc..af2d3b0ac 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UpdateAndInstallGroup.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UpdateAndInstallGroup.java
@@ -111,22 +111,6 @@ public class UpdateAndInstallGroup {
final IUDetailsLabelProvider labelProvider = new IUDetailsLabelProvider();
labelProvider.setToolTipProperty(IInstallableUnit.PROP_DESCRIPTION);
- // TODO Kind of a hack, but there was no need to go with column label providers
- availableIUViewer.getTree().addListener(SWT.MouseHover, new Listener() {
- public void handleEvent(Event event) {
- switch (event.type) {
- case SWT.MouseHover :
- Tree tree = availableIUViewer.getTree();
- TreeItem item = tree.getItem(new Point(event.x, event.y));
- if (item != null) {
- tree.setToolTipText(labelProvider.getToolTipText(item.getData()));
- }
- break;
- }
- }
-
- });
-
// Filters and sorters before establishing content, so we don't refresh unnecessarily.
availableIUViewer.setComparator(new IUComparator(IUComparator.IU_ID));
availableIUViewer.setComparer(new ProvElementComparer());
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/MetadataRepositoryElement.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/MetadataRepositoryElement.java
index 41ffc732d..0e8d55d04 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/MetadataRepositoryElement.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/MetadataRepositoryElement.java
@@ -10,11 +10,18 @@
*******************************************************************************/
package org.eclipse.equinox.p2.ui.model;
+import java.net.URL;
+import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.internal.p2.ui.model.RemoteQueriedElement;
+import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.core.repository.IRepository;
import org.eclipse.equinox.p2.metadata.repository.IMetadataRepository;
+import org.eclipse.equinox.p2.query.IQueryable;
+import org.eclipse.equinox.p2.ui.ProvUI;
import org.eclipse.equinox.p2.ui.ProvUIImages;
+import org.eclipse.equinox.p2.ui.operations.ProvisioningUtil;
import org.eclipse.equinox.p2.ui.query.IProvElementQueryProvider;
+import org.eclipse.osgi.util.NLS;
/**
* Element wrapper class for a metadata repository that gets its
@@ -22,20 +29,19 @@ import org.eclipse.equinox.p2.ui.query.IProvElementQueryProvider;
*
* @since 3.4
*/
-public class MetadataRepositoryElement extends RemoteQueriedElement {
+public class MetadataRepositoryElement extends RemoteQueriedElement implements RepositoryElement {
- IMetadataRepository repo;
+ URL url;
- public MetadataRepositoryElement(IMetadataRepository repo) {
- this.repo = repo;
- setQueryable(repo);
+ public MetadataRepositoryElement(URL url) {
+ this.url = url;
}
public Object getAdapter(Class adapter) {
if (adapter == IMetadataRepository.class)
- return repo;
+ return getQueryable();
if (adapter == IRepository.class)
- return repo;
+ return getQueryable();
return super.getAdapter(adapter);
}
@@ -48,11 +54,44 @@ public class MetadataRepositoryElement extends RemoteQueriedElement {
}
public String getLabel(Object o) {
- String name = repo.getName();
+ String name = getName();
if (name != null && name.length() > 0) {
return name;
}
- return repo.getLocation().toExternalForm();
+ return getURL().toExternalForm();
+ }
+
+ /*
+ * overridden to lazily fetch repository
+ * (non-Javadoc)
+ * @see org.eclipse.equinox.p2.ui.query.QueriedElement#getQueryable()
+ */
+ public IQueryable getQueryable() {
+ if (queryable == null)
+ try {
+ queryable = ProvisioningUtil.loadMetadataRepository(url, null);
+ } catch (ProvisionException e) {
+ ProvUI.handleException(e, NLS.bind(ProvUIMessages.MetadataRepositoryElement_RepositoryLoadError, url));
+ }
+ return queryable;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.equinox.p2.ui.model.RepositoryElement#getURL()
+ */
+ public URL getURL() {
+ return url;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.equinox.p2.ui.model.RepositoryElement#getName()
+ */
+ public String getName() {
+ try {
+ return ProvisioningUtil.getMetadataRepositoryName(url);
+ } catch (ProvisionException e) {
+ return ""; //$NON-NLS-1$
+ }
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/RepositoryElement.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/RepositoryElement.java
new file mode 100644
index 000000000..dcefe7de3
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/RepositoryElement.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.p2.ui.model;
+
+import java.net.URL;
+
+/**
+ * Interface for elements that represent repositories.
+ *
+ * @since 3.4
+ */
+public interface RepositoryElement {
+
+ public URL getURL();
+
+ public String getName();
+}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/RollbackRepositoryElement.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/RollbackRepositoryElement.java
index 7900fda24..54c5623a5 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/RollbackRepositoryElement.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/model/RollbackRepositoryElement.java
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.p2.ui.model;
-import org.eclipse.equinox.p2.metadata.repository.IMetadataRepository;
+import java.net.URL;
/**
* Element wrapper class for a rollback repository.
@@ -21,8 +21,8 @@ public class RollbackRepositoryElement extends MetadataRepositoryElement {
String profileId;
- public RollbackRepositoryElement(IMetadataRepository repo, String profileId) {
- super(repo);
+ public RollbackRepositoryElement(URL url, String profileId) {
+ super(url);
this.profileId = profileId;
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/AddArtifactRepositoryOperation.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/AddArtifactRepositoryOperation.java
index 721001cef..ac4de7e40 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/AddArtifactRepositoryOperation.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/AddArtifactRepositoryOperation.java
@@ -12,7 +12,6 @@ package org.eclipse.equinox.p2.ui.operations;
import java.net.URL;
import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.p2.artifact.repository.IArtifactRepository;
import org.eclipse.equinox.p2.core.ProvisionException;
/**
@@ -30,10 +29,7 @@ public class AddArtifactRepositoryOperation extends RepositoryOperation {
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
for (int i = 0; i < urls.length; i++) {
- IArtifactRepository repo = ProvisioningUtil.addArtifactRepository(urls[i], monitor);
- if (repo == null) {
- return failureStatus();
- }
+ ProvisioningUtil.addArtifactRepository(urls[i]);
}
added = true;
return okStatus();
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/AddColocatedRepositoryOperation.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/AddColocatedRepositoryOperation.java
index 9b7592e24..69a7119c7 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/AddColocatedRepositoryOperation.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/AddColocatedRepositoryOperation.java
@@ -13,7 +13,6 @@ package org.eclipse.equinox.p2.ui.operations;
import java.net.URL;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.p2.core.ProvisionException;
-import org.eclipse.equinox.p2.core.repository.IRepository;
/**
* Operation that adds colocated artifact and metadata repositories
@@ -31,16 +30,8 @@ public class AddColocatedRepositoryOperation extends RepositoryOperation {
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
for (int i = 0; i < urls.length; i++) {
- IRepository repo = ProvisioningUtil.addMetadataRepository(urls[i], monitor);
- if (repo == null) {
- return failureStatus();
- }
- repo = ProvisioningUtil.addArtifactRepository(urls[i], monitor);
- if (repo == null) {
- // remove the metadata repo we just added
- ProvisioningUtil.removeMetadataRepository(urls[i], monitor);
- return failureStatus();
- }
+ ProvisioningUtil.addMetadataRepository(urls[i]);
+ ProvisioningUtil.addArtifactRepository(urls[i]);
}
added = true;
return okStatus();
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/AddMetadataRepositoryOperation.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/AddMetadataRepositoryOperation.java
index 9f46428ff..cf7d38b48 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/AddMetadataRepositoryOperation.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/AddMetadataRepositoryOperation.java
@@ -13,7 +13,6 @@ package org.eclipse.equinox.p2.ui.operations;
import java.net.URL;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.p2.core.ProvisionException;
-import org.eclipse.equinox.p2.metadata.repository.IMetadataRepository;
/**
* Operation that adds a metadata repository given its URL.
@@ -30,10 +29,7 @@ public class AddMetadataRepositoryOperation extends RepositoryOperation {
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
for (int i = 0; i < urls.length; i++) {
- IMetadataRepository repo = ProvisioningUtil.addMetadataRepository(urls[i], monitor);
- if (repo == null) {
- return failureStatus();
- }
+ ProvisioningUtil.addMetadataRepository(urls[i]);
}
added = true;
return okStatus();
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProvisioningUtil.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProvisioningUtil.java
index 5414e450f..0e726dc5b 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProvisioningUtil.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProvisioningUtil.java
@@ -37,25 +37,26 @@ import org.eclipse.osgi.util.NLS;
*/
public class ProvisioningUtil {
- public static IMetadataRepository addMetadataRepository(URL location, IProgressMonitor monitor) throws ProvisionException {
+ public static void addMetadataRepository(URL location) throws ProvisionException {
IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(ProvUIActivator.getContext(), IMetadataRepositoryManager.class.getName());
if (manager == null)
throw new ProvisionException(ProvUIMessages.ProvisioningUtil_NoRepositoryManager);
- IMetadataRepository repo = manager.loadRepository(location, monitor);
- if (repo == null) {
- throw new ProvisionException(NLS.bind(ProvUIMessages.ProvisioningUtil_AddRepositoryFailure, location.toExternalForm()));
- }
+ manager.addRepository(location);
EventObject event = new EventObject(IProvisioningListener.REPO_ADDED);
ProvUIActivator.getDefault().notifyListeners(event);
- return repo;
}
- public static IMetadataRepository getRollbackRepository(IProgressMonitor monitor) throws ProvisionException {
- IDirector director = getDirector();
+ public static String getMetadataRepositoryName(URL location) throws ProvisionException {
+ IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(ProvUIActivator.getContext(), IMetadataRepositoryManager.class.getName());
+ if (manager == null)
+ throw new ProvisionException(ProvUIMessages.ProvisioningUtil_NoRepositoryManager);
+ return manager.getRepositoryProperty(location, IMetadataRepositoryManager.PROP_NAME);
+ }
+
+ public static IMetadataRepository loadMetadataRepository(URL location, IProgressMonitor monitor) throws ProvisionException {
IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(ProvUIActivator.getContext(), IMetadataRepositoryManager.class.getName());
if (manager == null)
throw new ProvisionException(ProvUIMessages.ProvisioningUtil_NoRepositoryManager);
- URL location = director.getRollbackRepositoryLocation();
IMetadataRepository repo = manager.loadRepository(location, monitor);
if (repo == null) {
throw new ProvisionException(NLS.bind(ProvUIMessages.ProvisioningUtil_LoadRepositoryFailure, location.toExternalForm()));
@@ -63,6 +64,14 @@ public class ProvisioningUtil {
return repo;
}
+ public static URL getRollbackRepositoryURL() throws ProvisionException {
+ IDirector director = getDirector();
+ IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(ProvUIActivator.getContext(), IMetadataRepositoryManager.class.getName());
+ if (manager == null)
+ throw new ProvisionException(ProvUIMessages.ProvisioningUtil_NoRepositoryManager);
+ return director.getRollbackRepositoryLocation();
+ }
+
public static void removeMetadataRepository(URL location, IProgressMonitor monitor) throws ProvisionException {
IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(ProvUIActivator.getContext(), IMetadataRepositoryManager.class.getName());
if (manager == null) {
@@ -73,18 +82,32 @@ public class ProvisioningUtil {
}
- public static IArtifactRepository addArtifactRepository(URL location, IProgressMonitor monitor) throws ProvisionException {
+ public static void addArtifactRepository(URL location) throws ProvisionException {
IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(ProvUIActivator.getContext(), IArtifactRepositoryManager.class.getName());
if (manager == null) {
throw new ProvisionException(ProvUIMessages.ProvisioningUtil_NoRepositoryManager);
}
- IArtifactRepository repo = manager.loadRepository(location, monitor);
- if (repo == null) {
- throw new ProvisionException(NLS.bind(ProvUIMessages.ProvisioningUtil_AddRepositoryFailure, location));
- }
+ manager.addRepository(location);
EventObject event = new EventObject(IProvisioningListener.REPO_ADDED);
ProvUIActivator.getDefault().notifyListeners(event);
+ }
+
+ public static String getArtifactRepositoryName(URL location) throws ProvisionException {
+ IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(ProvUIActivator.getContext(), IArtifactRepositoryManager.class.getName());
+ if (manager == null) {
+ throw new ProvisionException(ProvUIMessages.ProvisioningUtil_NoRepositoryManager);
+ }
+ return manager.getRepositoryProperty(location, IArtifactRepositoryManager.PROP_NAME);
+ }
+ public static IArtifactRepository loadArtifactRepository(URL location, IProgressMonitor monitor) throws ProvisionException {
+ IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(ProvUIActivator.getContext(), IArtifactRepositoryManager.class.getName());
+ if (manager == null)
+ throw new ProvisionException(ProvUIMessages.ProvisioningUtil_NoRepositoryManager);
+ IArtifactRepository repo = manager.loadRepository(location, monitor);
+ if (repo == null) {
+ throw new ProvisionException(NLS.bind(ProvUIMessages.ProvisioningUtil_LoadRepositoryFailure, location.toExternalForm()));
+ }
return repo;
}
@@ -131,18 +154,12 @@ public class ProvisioningUtil {
return profileRegistry.getProfile(id);
}
- public static IMetadataRepository[] getMetadataRepositories() throws ProvisionException {
+ public static URL[] getMetadataRepositories(int flags) throws ProvisionException {
IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(ProvUIActivator.getContext(), IMetadataRepositoryManager.class.getName());
if (manager == null) {
throw new ProvisionException(ProvUIMessages.ProvisioningUtil_NoRepositoryManager);
}
- URL[] locations = manager.getKnownRepositories();
- //TODO Shouldn't be eagerly loading all repositories here
- IMetadataRepository[] repositories = new IMetadataRepository[locations.length];
- for (int i = 0; i < repositories.length; i++) {
- repositories[i] = manager.loadRepository(locations[i], null);
- }
- return repositories;
+ return manager.getKnownRepositories(flags);
}
/*
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RemoveArtifactRepositoryOperation.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RemoveArtifactRepositoryOperation.java
index 8e216fd5c..14b62f274 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RemoveArtifactRepositoryOperation.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RemoveArtifactRepositoryOperation.java
@@ -12,7 +12,6 @@ package org.eclipse.equinox.p2.ui.operations;
import java.net.URL;
import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.p2.artifact.repository.IArtifactRepository;
import org.eclipse.equinox.p2.core.ProvisionException;
/**
@@ -24,11 +23,8 @@ public class RemoveArtifactRepositoryOperation extends RepositoryOperation {
private boolean removed = false;
- public RemoveArtifactRepositoryOperation(String label, IArtifactRepository[] repos) {
- super(label, new URL[repos.length]);
- for (int i = 0; i < repos.length; i++) {
- urls[i] = repos[i].getLocation();
- }
+ public RemoveArtifactRepositoryOperation(String label, URL[] repoURLs) {
+ super(label, repoURLs);
}
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
@@ -59,10 +55,7 @@ public class RemoveArtifactRepositoryOperation extends RepositoryOperation {
protected IStatus doUndo(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
for (int i = 0; i < urls.length; i++) {
- IArtifactRepository repo = ProvisioningUtil.addArtifactRepository(urls[i], monitor);
- if (repo == null) {
- return failureStatus();
- }
+ ProvisioningUtil.addArtifactRepository(urls[i]);
}
removed = false;
return okStatus();
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RemoveColocatedRepositoryOperation.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RemoveColocatedRepositoryOperation.java
index 9837aa9f1..48dd678ea 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RemoveColocatedRepositoryOperation.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RemoveColocatedRepositoryOperation.java
@@ -13,8 +13,6 @@ package org.eclipse.equinox.p2.ui.operations;
import java.net.URL;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.p2.core.ProvisionException;
-import org.eclipse.equinox.p2.core.repository.IRepository;
-import org.eclipse.equinox.p2.metadata.repository.IMetadataRepository;
/**
* Operation that removes the colocated repositories with the given URLs. *
@@ -25,11 +23,8 @@ public class RemoveColocatedRepositoryOperation extends RepositoryOperation {
private boolean removed = false;
- public RemoveColocatedRepositoryOperation(String label, IMetadataRepository[] repos) {
- super(label, new URL[repos.length]);
- for (int i = 0; i < repos.length; i++) {
- urls[i] = repos[i].getLocation();
- }
+ public RemoveColocatedRepositoryOperation(String label, URL[] repoURLs) {
+ super(label, repoURLs);
}
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
@@ -61,17 +56,8 @@ public class RemoveColocatedRepositoryOperation extends RepositoryOperation {
protected IStatus doUndo(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
for (int i = 0; i < urls.length; i++) {
- IRepository repo = ProvisioningUtil.addMetadataRepository(urls[i], monitor);
- if (repo == null) {
- return failureStatus();
- }
- repo = ProvisioningUtil.addArtifactRepository(urls[i], monitor);
- if (repo == null) {
- // remove the metadata repo we just added
- ProvisioningUtil.removeMetadataRepository(urls[i], monitor);
- return failureStatus();
- }
-
+ ProvisioningUtil.addMetadataRepository(urls[i]);
+ ProvisioningUtil.addArtifactRepository(urls[i]);
}
removed = false;
return okStatus();
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RemoveMetadataRepositoryOperation.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RemoveMetadataRepositoryOperation.java
index 9b9bda0ad..0ee904176 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RemoveMetadataRepositoryOperation.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/RemoveMetadataRepositoryOperation.java
@@ -13,7 +13,6 @@ package org.eclipse.equinox.p2.ui.operations;
import java.net.URL;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.p2.core.ProvisionException;
-import org.eclipse.equinox.p2.metadata.repository.IMetadataRepository;
/**
* Operation that removes the metadata repository with the given URL. *
@@ -24,11 +23,8 @@ public class RemoveMetadataRepositoryOperation extends RepositoryOperation {
private boolean removed = false;
- public RemoveMetadataRepositoryOperation(String label, IMetadataRepository[] repos) {
- super(label, new URL[repos.length]);
- for (int i = 0; i < repos.length; i++) {
- urls[i] = repos[i].getLocation();
- }
+ public RemoveMetadataRepositoryOperation(String label, URL[] repoURLs) {
+ super(label, repoURLs);
}
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
@@ -59,10 +55,7 @@ public class RemoveMetadataRepositoryOperation extends RepositoryOperation {
protected IStatus doUndo(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
for (int i = 0; i < urls.length; i++) {
- IMetadataRepository repo = ProvisioningUtil.addMetadataRepository(urls[i], monitor);
- if (repo == null) {
- return failureStatus();
- }
+ ProvisioningUtil.addMetadataRepository(urls[i]);
}
removed = false;
return okStatus();
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/AvailableIUCollector.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/AvailableIUCollector.java
index 2910896f5..2783e7ce5 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/AvailableIUCollector.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/AvailableIUCollector.java
@@ -10,8 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.p2.ui.query;
-import org.eclipse.equinox.internal.p2.ui.model.AvailableIUElement;
-import org.eclipse.equinox.internal.p2.ui.model.ProvElement;
+import org.eclipse.equinox.internal.p2.ui.model.*;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.equinox.p2.ui.model.CategoryElement;
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/CategoryElementCollector.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/CategoryElementCollector.java
index 76d4692de..ce4cf5ac3 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/CategoryElementCollector.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/CategoryElementCollector.java
@@ -12,6 +12,7 @@ package org.eclipse.equinox.p2.ui.query;
import java.util.*;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
+import org.eclipse.equinox.internal.p2.ui.model.QueriedElementCollector;
import org.eclipse.equinox.p2.core.repository.IRepository;
import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/FilteredRepositoryQuery.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/FilteredRepositoryQuery.java
new file mode 100644
index 000000000..8f2c26adc
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/FilteredRepositoryQuery.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.p2.ui.query;
+
+import org.eclipse.equinox.p2.metadata.repository.IMetadataRepositoryManager;
+import org.eclipse.equinox.p2.query.Query;
+
+/**
+ * A query that provides flags for filtering out which repositories
+ * are of interest. This query is used for optimizations so that only
+ * those repository URLs that meet the filter flags will be iterated
+ * in the query. This can prevent unnecessary loading a repositories when
+ * only a subset of repositories is desired for running a query.
+ * <p>
+ * This query may be used alone, or in conjunction with
+ * other queries that actually load the repository and further refine
+ * the repositories of interest.
+ */
+public class FilteredRepositoryQuery extends Query {
+ private int flags = IMetadataRepositoryManager.REPOSITORIES_ALL;
+
+ /**
+ * Creates a new query which uses the provided flags to filter out
+ * repositories before loading and querying them.
+ */
+ public FilteredRepositoryQuery(int flags) {
+ this.flags = flags;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.equinox.p2.query2.Query#isMatch(java.lang.Object)
+ */
+ public boolean isMatch(Object object) {
+ return true;
+ }
+
+ public int getFlags() {
+ return flags;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/InstalledIUCollector.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/InstalledIUCollector.java
index 97802d5ed..25389dc09 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/InstalledIUCollector.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/InstalledIUCollector.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.p2.ui.query;
+import org.eclipse.equinox.internal.p2.ui.model.QueriedElementCollector;
import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.ui.model.InstalledIUElement;
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/OtherIUVersionsCollector.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/OtherIUVersionsCollector.java
index 6361eb674..73bfecdbf 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/OtherIUVersionsCollector.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/OtherIUVersionsCollector.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.p2.ui.query;
+import org.eclipse.equinox.internal.p2.ui.model.QueriedElementCollector;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.query.IQueryable;
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/ProfileElementCollector.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/ProfileElementCollector.java
index a1eef9e7a..fc5c210b4 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/ProfileElementCollector.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/ProfileElementCollector.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.p2.ui.query;
+import org.eclipse.equinox.internal.p2.ui.model.QueriedElementCollector;
import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.ui.model.ProfileElement;
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/QueriedElement.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/QueriedElement.java
index 568bb5405..823f3808d 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/QueriedElement.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/QueriedElement.java
@@ -23,7 +23,7 @@ import org.eclipse.equinox.p2.query.IQueryable;
public abstract class QueriedElement extends ProvElement {
IProvElementQueryProvider queryProvider;
- IQueryable queryable;
+ protected IQueryable queryable;
public Object[] getChildren(Object o) {
if (queryProvider == null)
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/QueryableArtifactRepositoryManager.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/QueryableArtifactRepositoryManager.java
index 1b9fd177d..3f49870db 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/QueryableArtifactRepositoryManager.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/QueryableArtifactRepositoryManager.java
@@ -15,7 +15,6 @@ import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.internal.p2.ui.model.ArtifactRepositoryElement;
-import org.eclipse.equinox.p2.artifact.repository.IArtifactRepository;
import org.eclipse.equinox.p2.artifact.repository.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.query.*;
import org.eclipse.equinox.p2.ui.ProvUI;
@@ -23,7 +22,9 @@ import org.eclipse.equinox.p2.ui.ProvUIActivator;
/**
* An object that adds queryable support to an artifact repository
- * manager.
+ * manager. The object being queried is the repositry URL, not the
+ * repository instance itself. Callers should load the repository
+ * if necessary to complete the query.
*/
public class QueryableArtifactRepositoryManager implements IQueryable {
@@ -33,14 +34,16 @@ public class QueryableArtifactRepositoryManager implements IQueryable {
ProvUI.reportStatus(new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, ProvUIMessages.ProvisioningUtil_NoRepositoryManager));
return result;
}
- URL[] repos = manager.getKnownRepositories();
+ int flags = IArtifactRepositoryManager.REPOSITORIES_ALL;
+ if (query instanceof FilteredRepositoryQuery)
+ flags = ((FilteredRepositoryQuery) query).getFlags();
+ URL[] repoURLs = manager.getKnownRepositories(flags);
if (monitor == null)
monitor = new NullProgressMonitor();
- monitor.beginTask(ProvUIMessages.QueryableArtifactRepositoryManager_RepositoryQueryProgress, repos.length * 2);
- for (int i = 0; i < repos.length; i++) {
- IArtifactRepository repo = manager.loadRepository(repos[i], new SubProgressMonitor(monitor, 1));
- if (repo != null && query.isMatch(repo))
- result.accept(new ArtifactRepositoryElement(repo));
+ monitor.beginTask(ProvUIMessages.QueryableArtifactRepositoryManager_RepositoryQueryProgress, repoURLs.length * 2);
+ for (int i = 0; i < repoURLs.length; i++) {
+ if (query.isMatch(repoURLs[i]))
+ result.accept(new ArtifactRepositoryElement(repoURLs[i]));
monitor.worked(1);
}
monitor.done();
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/QueryableMetadataRepositoryManager.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/QueryableMetadataRepositoryManager.java
index 0e68f4630..452295756 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/QueryableMetadataRepositoryManager.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/QueryableMetadataRepositoryManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2007, 2008 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,7 +14,7 @@ import java.net.URL;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
-import org.eclipse.equinox.p2.metadata.repository.IMetadataRepository;
+import org.eclipse.equinox.p2.artifact.repository.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.metadata.repository.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.query.*;
import org.eclipse.equinox.p2.ui.ProvUI;
@@ -22,8 +22,10 @@ import org.eclipse.equinox.p2.ui.ProvUIActivator;
import org.eclipse.equinox.p2.ui.model.MetadataRepositoryElement;
/**
- * An object that adds queryable support to a metadata repository
- * manager.
+ * An object that adds queryable support to an artifact repository
+ * manager. The object being queried is the repository URL, not the
+ * repository instance itself. Callers should load the repository
+ * if necessary to complete the query.
*/
public class QueryableMetadataRepositoryManager implements IQueryable {
@@ -33,12 +35,14 @@ public class QueryableMetadataRepositoryManager implements IQueryable {
ProvUI.reportStatus(new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, ProvUIMessages.ProvisioningUtil_NoRepositoryManager));
return result;
}
- URL[] repos = manager.getKnownRepositories();
- SubMonitor sub = SubMonitor.convert(monitor, ProvUIMessages.QueryableMetadataRepositoryManager_RepositoryQueryProgress, repos.length * 2);
- for (int i = 0; i < repos.length; i++) {
- IMetadataRepository repository = manager.loadRepository(repos[i], sub.newChild(1));
- if (repository != null && query.isMatch(repository))
- result.accept(new MetadataRepositoryElement(repository));
+ int flags = IArtifactRepositoryManager.REPOSITORIES_ALL;
+ if (query instanceof FilteredRepositoryQuery)
+ flags = ((FilteredRepositoryQuery) query).getFlags();
+ URL[] repoURLs = manager.getKnownRepositories(flags);
+ SubMonitor sub = SubMonitor.convert(monitor, ProvUIMessages.QueryableMetadataRepositoryManager_RepositoryQueryProgress, repoURLs.length * 2);
+ for (int i = 0; i < repoURLs.length; i++) {
+ if (query.isMatch(repoURLs[i]))
+ result.accept(new MetadataRepositoryElement(repoURLs[i]));
sub.worked(1);
}
sub.done();
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/RepositoryCollector.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/RepositoryCollector.java
new file mode 100644
index 000000000..1ccc2e78f
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/RepositoryCollector.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.p2.ui.query;
+
+import org.eclipse.equinox.internal.p2.ui.model.QueriedElementCollector;
+import org.eclipse.equinox.p2.query.IQueryable;
+import org.eclipse.equinox.p2.ui.model.MetadataRepositoryElement;
+import org.eclipse.equinox.p2.ui.model.RepositoryElement;
+
+/**
+ * Collector that accepts the matched Profiles and
+ * wraps them in a ProfileElement.
+ *
+ * @since 3.4
+ */
+public class RepositoryCollector extends QueriedElementCollector {
+
+ public RepositoryCollector(IProvElementQueryProvider queryProvider, IQueryable queryable) {
+ super(queryProvider, queryable);
+ }
+
+ /**
+ * Accepts a result that matches the query criteria.
+ *
+ * @param match an object matching the query
+ * @return <code>true</code> if the query should continue,
+ * or <code>false</code> to indicate the query should stop.
+ */
+ public boolean accept(Object match) {
+ // Circumvent the code that gets/sets the queryable of this element,
+ // as that will cause loading of the repository.
+ if (match instanceof RepositoryElement) {
+ if (match instanceof MetadataRepositoryElement)
+ ((MetadataRepositoryElement) match).setQueryProvider(queryProvider);
+ getList().add(match);
+ return true;
+ }
+ return super.accept(match);
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/RepositoryPropertyQuery.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/RepositoryPropertyQuery.java
deleted file mode 100644
index 0cce2ab44..000000000
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/query/RepositoryPropertyQuery.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.p2.ui.query;
-
-import org.eclipse.equinox.p2.core.repository.IRepository;
-import org.eclipse.equinox.p2.query.Query;
-
-/**
- * A query that searches for {@link IRepository} instances that have
- * a property whose value matches the provided value.
- */
-public class RepositoryPropertyQuery extends Query {
- private String propertyName;
- private Object propertyValue;
- private boolean mustMatch;
-
- /**
- * Creates a new query on the given property name and value.
- * The boolean indicates whether the property value should match or
- * should not match in order to satisfy the query.
- */
- public RepositoryPropertyQuery(String propertyName, Object propertyValue, boolean match) {
- this.propertyName = propertyName;
- this.propertyValue = propertyValue;
- this.mustMatch = match;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.equinox.p2.query2.Query#isMatch(java.lang.Object)
- */
- public boolean isMatch(Object object) {
- if (!(object instanceof IRepository))
- return false;
- IRepository candidate = (IRepository) object;
- Object value = candidate.getProperties().get(propertyName);
- if (value != null && value.equals(propertyValue))
- return mustMatch;
- return !mustMatch;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/ProvElementComparer.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/ProvElementComparer.java
index 95054a040..d0cf738a1 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/ProvElementComparer.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/ProvElementComparer.java
@@ -10,10 +10,12 @@
*******************************************************************************/
package org.eclipse.equinox.p2.ui.viewers;
-import org.eclipse.equinox.p2.core.repository.IRepository;
+import java.net.URL;
import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.ui.ProvUI;
+import org.eclipse.equinox.p2.ui.model.ProfileElement;
+import org.eclipse.equinox.p2.ui.model.RepositoryElement;
import org.eclipse.jface.viewers.IElementComparer;
public class ProvElementComparer implements IElementComparer {
@@ -27,8 +29,8 @@ public class ProvElementComparer implements IElementComparer {
String p2 = getProfileId(b);
if (p1 != null && p2 != null)
return p1.equals(p2);
- IRepository r1 = getRepository(a);
- IRepository r2 = getRepository(b);
+ URL r1 = getRepositoryLocation(a);
+ URL r2 = getRepositoryLocation(b);
if (r1 != null && r2 != null)
return r1.equals(r2);
return a.equals(b);
@@ -41,9 +43,9 @@ public class ProvElementComparer implements IElementComparer {
String profileId = getProfileId(element);
if (profileId != null)
return profileId.hashCode();
- IRepository repo = getRepository(element);
- if (repo != null)
- return repo.hashCode();
+ URL url = getRepositoryLocation(element);
+ if (url != null)
+ return url.hashCode();
return element.hashCode();
}
@@ -52,14 +54,18 @@ public class ProvElementComparer implements IElementComparer {
}
private String getProfileId(Object obj) {
+ if (obj instanceof ProfileElement)
+ return ((ProfileElement) obj).getLabel(obj);
Profile profile = (Profile) ProvUI.getAdapter(obj, Profile.class);
if (profile == null)
return null;
return profile.getProfileId();
}
- private IRepository getRepository(Object obj) {
- return (IRepository) ProvUI.getAdapter(obj, IRepository.class);
+ private URL getRepositoryLocation(Object obj) {
+ if (obj instanceof RepositoryElement)
+ return ((RepositoryElement) obj).getURL();
+ return null;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/ProvElementLabelProvider.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/ProvElementLabelProvider.java
index bfc0010fe..0b34a43b7 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/ProvElementLabelProvider.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/viewers/ProvElementLabelProvider.java
@@ -105,9 +105,8 @@ public class ProvElementLabelProvider extends LabelProvider implements ITableLab
switch (columnIndex) {
case 0 :
- IRepository repo = (IRepository) ProvUI.getAdapter(element, IRepository.class);
- if (repo != null) {
- return repo.getName();
+ if (element instanceof IRepository) {
+ return ((IRepository) element).getName();
}
return getText(element);
case 1 :
@@ -122,9 +121,8 @@ public class ProvElementLabelProvider extends LabelProvider implements ITableLab
if (iu != null) {
return iu.getVersion().toString();
}
- repo = (IRepository) ProvUI.getAdapter(element, IRepository.class);
- if (repo != null) {
- return repo.getLocation().toExternalForm();
+ if (element instanceof IRepository) {
+ return ((IRepository) element).getLocation().toExternalForm();
}
if (element instanceof IArtifactKey) {
IArtifactKey key = (IArtifactKey) element;

Back to the top