Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDJ Houghton2011-01-28 15:32:20 -0500
committerDJ Houghton2011-01-28 15:32:20 -0500
commit10266fbd3deb1ed757a934590e34349944ee8e70 (patch)
tree31ab18871e32c81a3085e6cf59f3f82c6ab3b674
parentea4c70236c31bec52114376fc0cec7d41efc4881 (diff)
downloadrt.equinox.p2-10266fbd3deb1ed757a934590e34349944ee8e70.tar.gz
rt.equinox.p2-10266fbd3deb1ed757a934590e34349944ee8e70.tar.xz
rt.equinox.p2-10266fbd3deb1ed757a934590e34349944ee8e70.zip
Bug 332314 - [ui] possible over use of ProvUIActivator.getProvisioningUI() and ProvisioningUI.getDefaultUI()v20110201-0200
-rw-r--r--bundles/org.eclipse.equinox.p2.core/.options5
-rw-r--r--bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/Tracing.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/ElementUtilsTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AbstractQueryTest.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProfilesView.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminUIActivator.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvView.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/RepositoriesView.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/OSGI-INF/repositoryTracker_component.xml5
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ColocatedRepositoryTracker.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUI.java26
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIActivator.java23
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIProvisioningListener.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/RepositoryTrackerComponent.java30
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/ProfileModificationAction.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUGroup.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstalledIUGroup.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositorySelectionGroup.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/StructuredIUGroup.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ArtifactRepositoryElement.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ElementUtils.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/MetadataRepositoryElement.java25
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ProfileSnapshots.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/QueriedElement.java21
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/QueriedElementWrapper.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/ArtifactRepositoryElementWrapper.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/MetadataRepositoryElementWrapper.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/StructuredViewerProvisioningListener.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/InstalledSoftwarePage.java31
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUI.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java25
35 files changed, 225 insertions, 191 deletions
diff --git a/bundles/org.eclipse.equinox.p2.core/.options b/bundles/org.eclipse.equinox.p2.core/.options
index a4d705ba4..7024adaa4 100644
--- a/bundles/org.eclipse.equinox.p2.core/.options
+++ b/bundles/org.eclipse.equinox.p2.core/.options
@@ -38,4 +38,7 @@ org.eclipse.equinox.p2.core/reconciler=false
org.eclipse.equinox.p2.core/publisher=false
#Detailed debugging information about event clients
-org.eclipse.equinox.p2.core/events/client = false \ No newline at end of file
+org.eclipse.equinox.p2.core/events/client = false
+
+#Information about the use of the default provisioning UI
+org.eclipse.equinox.p2.core/ui/default = false \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/Tracing.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/Tracing.java
index b7fb78d38..952e425a7 100644
--- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/Tracing.java
+++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/Tracing.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 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
@@ -36,6 +36,7 @@ public class Tracing {
public static boolean DEBUG_REMOVE_REPO = false;
public static boolean DEBUG_UPDATE_CHECK = false;
public static boolean DEBUG_EVENTS_CLIENT = false;
+ public static boolean DEBUG_DEFAULT_UI = false;
static {
DebugOptions options = (DebugOptions) ServiceHelper.getService(Activator.context, DebugOptions.class.getName());
@@ -55,6 +56,7 @@ public class Tracing {
DEBUG_RECONCILER = options.getBooleanOption(Activator.ID + "/reconciler", false); //$NON-NLS-1$
DEBUG_REMOVE_REPO = options.getBooleanOption(Activator.ID + "/core/removeRepo", false); //$NON-NLS-1$
DEBUG_UPDATE_CHECK = options.getBooleanOption(Activator.ID + "/updatechecker", false); //$NON-NLS-1$
+ DEBUG_DEFAULT_UI = options.getBooleanOption(Activator.ID + "/ui/default", false); //$NON-NLS-1$
}
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.tests.ui/META-INF/MANIFEST.MF
index af2a3c342..050c8e001 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.equinox.p2.tests.ui
-Bundle-Version: 1.0.0.qualifier
+Bundle-Version: 1.0.100.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.4.100",
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java
index 738d960ba..3087875bb 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * Copyright (c) 2008, 2011 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
@@ -10,21 +10,20 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui;
-import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest;
-
import java.io.File;
import java.net.URI;
import java.util.Dictionary;
import java.util.Hashtable;
import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.ui.ColocatedRepositoryTracker;
+import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest;
import org.eclipse.equinox.internal.p2.ui.model.ProfileElement;
import org.eclipse.equinox.internal.p2.ui.sdk.SimpleLicenseManager;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.engine.*;
import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
-import org.eclipse.equinox.p2.operations.*;
+import org.eclipse.equinox.p2.operations.ProfileModificationJob;
+import org.eclipse.equinox.p2.operations.ProvisioningSession;
import org.eclipse.equinox.p2.repository.IRepositoryManager;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
@@ -60,7 +59,7 @@ public abstract class AbstractProvisioningUITest extends AbstractProvisioningTes
protected IInstallableUnit uninstalled;
protected IInstallableUnit category;
private ProvisioningUI ui;
- private ServiceRegistration regLicenseManager, regTracker;
+ private ServiceRegistration regLicenseManager;
protected void setUp() throws Exception {
super.setUp();
@@ -75,11 +74,9 @@ public abstract class AbstractProvisioningUITest extends AbstractProvisioningTes
// register alternate services
SimpleLicenseManager manager = new SimpleLicenseManager(TESTPROFILE);
- RepositoryTracker tracker = new ColocatedRepositoryTracker(ui);
Dictionary<String, Object> properties = new Hashtable<String, Object>(5);
properties.put(Constants.SERVICE_RANKING, new Integer(1));
regLicenseManager = TestActivator.getContext().registerService(LicenseManager.class.getName(), manager, properties);
- regTracker = TestActivator.getContext().registerService(RepositoryTracker.class.getName(), tracker, properties);
profileElement = new ProfileElement(null, TESTPROFILE);
install((top1 = createIU(TOPLEVELIU, Version.create("1.0.0"))), true, false);
@@ -106,7 +103,6 @@ public abstract class AbstractProvisioningUITest extends AbstractProvisioningTes
metaManager.removeRepository(testRepoLocation);
artifactManager.removeRepository(testRepoLocation);
regLicenseManager.unregister();
- regTracker.unregister();
}
protected boolean managerContains(IRepositoryManager<?> manager, URI location) {
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/ElementUtilsTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/ElementUtilsTest.java
index b3022ff2d..258c1f5f4 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/ElementUtilsTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/ElementUtilsTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 IBM Corporation and others.
+ * Copyright (c) 2008, 2011 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
@@ -86,7 +86,7 @@ public class ElementUtilsTest extends ProfileModificationActionTest {
// We expect uri3 to get removed (as if it had been removed from a pref page)
// System repos shouldn't be touched
- ElementUtils.updateRepositoryUsingElements(elements, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ ElementUtils.updateRepositoryUsingElements(getProvisioningUI(), elements, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
URI[] enabled = getMetadataRepositoryManager().getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
URI[] disabled = getMetadataRepositoryManager().getKnownRepositories(IRepositoryManager.REPOSITORIES_DISABLED);
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AbstractQueryTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AbstractQueryTest.java
index 0b8edfe2a..ad48e91b7 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AbstractQueryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AbstractQueryTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * Copyright (c) 2008, 2011 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
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.query;
-import org.eclipse.equinox.internal.p2.ui.ProvUI;
+//import org.eclipse.equinox.internal.p2.ui.ProvUI;
import org.eclipse.equinox.p2.operations.RepositoryTracker;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.MatchQuery;
@@ -27,7 +27,7 @@ public abstract class AbstractQueryTest extends AbstractProvisioningTest {
// use test query provider
// This is really not how the default policy should be used in practice,
// but we need to reset it for the tests.
- ProvUI.setQueryProvider(new MockQueryProvider(getMockQuery(), ProvisioningUI.getDefaultUI()));
+ // ProvUI.setQueryProvider(new MockQueryProvider(getMockQuery(), ProvisioningUI.getDefaultUI()));
// some of the test repos are set up as system repos so we need to
// query all repos, not just non-system repos
// TODO consider evolving these tests to distinguish between system
@@ -42,7 +42,7 @@ public abstract class AbstractQueryTest extends AbstractProvisioningTest {
RepositoryTracker manipulator = ProvisioningUI.getDefaultUI().getRepositoryTracker();
manipulator.setArtifactRepositoryFlags(IRepositoryManager.REPOSITORIES_NON_SYSTEM);
manipulator.setMetadataRepositoryFlags(IRepositoryManager.REPOSITORIES_NON_SYSTEM);
- ProvUI.setQueryProvider(null);
+ // ProvUI.setQueryProvider(null);
}
protected IQuery getMockQuery() {
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProfilesView.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProfilesView.java
index fc2865bc7..b9a91fc03 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProfilesView.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProfilesView.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 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
@@ -82,13 +82,13 @@ public class ProfilesView extends ProvView {
protected void addListeners() {
super.addListeners();
- listener = new StructuredViewerProvisioningListener(getClass().getName(), viewer, ProvUIProvisioningListener.PROV_EVENT_IU | ProvUIProvisioningListener.PROV_EVENT_PROFILE);
- ProvUI.addProvisioningListener(listener);
+ listener = new StructuredViewerProvisioningListener(getClass().getName(), viewer, ProvUIProvisioningListener.PROV_EVENT_IU | ProvUIProvisioningListener.PROV_EVENT_PROFILE, ui.getOperationRunner());
+ ProvUI.getProvisioningEventBus(ui.getSession()).addListener(listener);
}
protected void removeListeners() {
super.removeListeners();
- ProvUI.removeProvisioningListener(listener);
+ ProvUI.getProvisioningEventBus(ui.getSession()).removeListener(listener);
}
protected void configureViewer(TreeViewer treeViewer) {
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminUIActivator.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminUIActivator.java
index bc60857b2..e79b334dd 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminUIActivator.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminUIActivator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 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
@@ -11,7 +11,6 @@
package org.eclipse.equinox.internal.p2.ui.admin;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
-import org.eclipse.equinox.internal.p2.ui.ProvUIActivator;
import org.eclipse.equinox.internal.p2.ui.admin.preferences.PreferenceConstants;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.engine.IProfileRegistry;
@@ -127,7 +126,7 @@ public class ProvAdminUIActivator extends AbstractUIPlugin {
}
private RepositoryTracker getRepositoryTracker() {
- return (RepositoryTracker) ServiceHelper.getService(ProvUIActivator.getContext(), RepositoryTracker.class.getName());
+ return ProvisioningUI.getDefaultUI().getRepositoryTracker();
}
void initializePolicy() {
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvView.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvView.java
index ebd8a393e..a58bacff6 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvView.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvView.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 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
@@ -13,8 +13,6 @@ package org.eclipse.equinox.internal.p2.ui.admin;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.equinox.internal.p2.ui.ProvUI;
-import org.eclipse.equinox.internal.p2.ui.QueryProvider;
import org.eclipse.equinox.internal.p2.ui.actions.RefreshAction;
import org.eclipse.equinox.internal.p2.ui.admin.preferences.PreferenceConstants;
import org.eclipse.equinox.internal.p2.ui.viewers.*;
@@ -43,7 +41,7 @@ abstract class ProvView extends ViewPart {
RefreshAction refreshAction;
private IPropertyChangeListener preferenceListener;
protected Display display;
- private ProvisioningUI ui;
+ protected ProvisioningUI ui;
/**
* The constructor.
@@ -251,7 +249,6 @@ abstract class ProvView extends ViewPart {
protected ProvisioningUI getProvisioningUI() {
if (ui == null) {
ui = ProvAdminUIActivator.getDefault().getProvisioningUI(getProfileId());
- ProvUI.setQueryProvider(new QueryProvider(ui));
}
return ui;
}
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 08af6d02e..7d887f2c6 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 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
@@ -96,17 +96,17 @@ abstract class RepositoriesView extends ProvView {
protected void addListeners() {
super.addListeners();
- listener = new StructuredViewerProvisioningListener(getClass().getName(), viewer, getListenerEventTypes()) {
+ listener = new StructuredViewerProvisioningListener(getClass().getName(), viewer, getListenerEventTypes(), ui.getOperationRunner()) {
protected void refreshViewer() {
RepositoriesView.this.refreshAll(false);
}
};
- ProvUI.addProvisioningListener(listener);
+ ProvUI.getProvisioningEventBus(ui.getSession()).addListener(listener);
}
protected void removeListeners() {
super.removeListeners();
- ProvUI.removeProvisioningListener(listener);
+ ProvUI.getProvisioningEventBus(ui.getSession()).removeListener(listener);
}
protected void fillLocalPullDown(IMenuManager manager) {
diff --git a/bundles/org.eclipse.equinox.p2.ui/OSGI-INF/repositoryTracker_component.xml b/bundles/org.eclipse.equinox.p2.ui/OSGI-INF/repositoryTracker_component.xml
index f4c2c7386..89704e4c7 100644
--- a/bundles/org.eclipse.equinox.p2.ui/OSGI-INF/repositoryTracker_component.xml
+++ b/bundles/org.eclipse.equinox.p2.ui/OSGI-INF/repositoryTracker_component.xml
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.equinox.p2.ui.repositoryTracker">
- <implementation class="org.eclipse.equinox.internal.p2.ui.ColocatedRepositoryTracker"/>
+ <implementation class="org.eclipse.equinox.internal.p2.ui.RepositoryTrackerComponent"/>
<service>
- <provide interface="org.eclipse.equinox.p2.operations.RepositoryTracker"/>
+ <provide interface="org.eclipse.equinox.p2.core.spi.IAgentServiceFactory"/>
</service>
+ <property name="p2.agent.servicename" type="String" value="org.eclipse.equinox.p2.operations.RepositoryTracker"/>
</scr:component>
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ColocatedRepositoryTracker.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ColocatedRepositoryTracker.java
index 0c21b3a84..6ae05efbc 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ColocatedRepositoryTracker.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ColocatedRepositoryTracker.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * Copyright (c) 2008, 2011 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
@@ -43,10 +43,6 @@ public class ColocatedRepositoryTracker extends RepositoryTracker {
String parsedNickname;
URI parsedLocation;
- public ColocatedRepositoryTracker() {
- this(ProvisioningUI.getDefaultUI());
- }
-
public ColocatedRepositoryTracker(ProvisioningUI ui) {
this.ui = ui;
setArtifactRepositoryFlags(IRepositoryManager.REPOSITORIES_NON_SYSTEM);
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUI.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUI.java
index 54b6f131b..e37c2ffbe 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUI.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUI.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 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
@@ -68,7 +68,6 @@ public class ProvUI {
public static final long SIZE_UNKNOWN = -1L;
private static IUColumnConfig[] columnConfig;
- private static QueryProvider queryProvider;
// These values rely on the command markup in org.eclipse.ui.ide that defines the update commands
private static final String UPDATE_MANAGER_FIND_AND_INSTALL = "org.eclipse.ui.update.findAndInstallUpdates"; //$NON-NLS-1$
@@ -150,14 +149,6 @@ public class ProvUI {
return PlatformUI.getWorkbench().getModalDialogShellProvider().getShell();
}
- public static void addProvisioningListener(ProvUIProvisioningListener listener) {
- ProvUIActivator.getDefault().addProvisioningListener(listener);
- }
-
- public static void removeProvisioningListener(ProvUIProvisioningListener listener) {
- ProvUIActivator.getDefault().removeProvisioningListener(listener);
- }
-
public static void openUpdateManagerInstaller(Event event) {
runCommand(UPDATE_MANAGER_FIND_AND_INSTALL, ProvUIMessages.UpdateManagerCompatibility_UnableToOpenFindAndInstall, event);
}
@@ -176,12 +167,6 @@ public class ProvUI {
return command.isDefined();
}
- public static QueryProvider getQueryProvider() {
- if (queryProvider == null)
- queryProvider = new QueryProvider(ProvUIActivator.getDefault().getProvisioningUI());
- return queryProvider;
- }
-
private static void runCommand(String commandId, String errorMessage, Event event) {
ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
Command command = commandService.getCommand(commandId);
@@ -212,15 +197,6 @@ public class ProvUI {
}
/**
- * For testing only
- * @noreference
- * @param provider
- */
- public static void setQueryProvider(QueryProvider provider) {
- queryProvider = provider;
- }
-
- /**
* Get sizing information about the specified plan.
*
* @param engine the engine
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIActivator.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIActivator.java
index f51d4dec0..554e2e430 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIActivator.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIActivator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 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.core.runtime.jobs.Job;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
-import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
+import org.eclipse.equinox.internal.p2.core.helpers.Tracing;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.engine.IProfileRegistry;
import org.eclipse.equinox.p2.operations.ProvisioningSession;
@@ -102,18 +102,6 @@ public class ProvUIActivator extends AbstractUIPlugin {
}
}
- public void addProvisioningListener(ProvUIProvisioningListener listener) {
- getProvisioningEventBus().addListener(listener);
- }
-
- public IProvisioningEventBus getProvisioningEventBus() {
- return ProvUI.getProvisioningEventBus(getSession());
- }
-
- public void removeProvisioningListener(ProvUIProvisioningListener listener) {
- getProvisioningEventBus().removeListener(listener);
- }
-
protected void initializeImageRegistry(ImageRegistry reg) {
createImageDescriptor(ProvUIImages.IMG_METADATA_REPOSITORY, reg);
createImageDescriptor(ProvUIImages.IMG_ARTIFACT_REPOSITORY, reg);
@@ -138,6 +126,9 @@ public class ProvUIActivator extends AbstractUIPlugin {
}
public ProvisioningUI getProvisioningUI() {
+ if (Tracing.DEBUG_DEFAULT_UI)
+ Tracing.debug("Falling back to default provisioning UI"); //$NON-NLS-1$
+
if (ui == null) {
IProvisioningAgent agent = (IProvisioningAgent) ServiceHelper.getService(getContext(), IProvisioningAgent.SERVICE_NAME);
session = new ProvisioningSession(agent);
@@ -148,8 +139,4 @@ public class ProvUIActivator extends AbstractUIPlugin {
}
return ui;
}
-
- public ProvisioningSession getSession() {
- return session;
- }
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIProvisioningListener.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIProvisioningListener.java
index 05972f6db..c49028748 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIProvisioningListener.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIProvisioningListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * Copyright (c) 2009, 2011 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
@@ -17,7 +17,6 @@ import org.eclipse.equinox.internal.provisional.p2.core.eventbus.SynchronousProv
import org.eclipse.equinox.internal.provisional.p2.repository.RepositoryEvent;
import org.eclipse.equinox.p2.engine.IProfileEvent;
import org.eclipse.equinox.p2.repository.IRepository;
-import org.eclipse.equinox.p2.ui.ProvisioningUI;
/**
* ProvisioningListener which handles event batching and other
@@ -35,10 +34,12 @@ public abstract class ProvUIProvisioningListener implements SynchronousProvision
int eventTypes = 0;
String name;
+ private ProvisioningOperationRunner runner;
- public ProvUIProvisioningListener(String name, int eventTypes) {
+ public ProvUIProvisioningListener(String name, int eventTypes, ProvisioningOperationRunner runner) {
this.name = name;
this.eventTypes = eventTypes;
+ this.runner = runner;
}
public void notify(EventObject o) {
@@ -51,7 +52,7 @@ public abstract class ProvUIProvisioningListener implements SynchronousProvision
if (Tracing.DEBUG_EVENTS_CLIENT)
Tracing.debug("Batch Eventing: Batch Ended. " + getReceiverString()); //$NON-NLS-1$
// A batch operation completed. Refresh.
- if (ProvisioningUI.getDefaultUI().getOperationRunner().eventBatchCount <= 0) {
+ if (runner.eventBatchCount <= 0) {
if (Tracing.DEBUG_EVENTS_CLIENT)
Tracing.debug("Batch Eventing Complete." + getReceiverString()); //$NON-NLS-1$
if (event.getEvent() == null && event.update()) {
@@ -78,7 +79,7 @@ public abstract class ProvUIProvisioningListener implements SynchronousProvision
handleRepositoryEvent(innerEvent);
}
}
- } else if (ProvisioningUI.getDefaultUI().getOperationRunner().eventBatchCount > 0) {
+ } else if (runner.eventBatchCount > 0) {
// ignore raw events during a batch
if (Tracing.DEBUG_EVENTS_CLIENT)
Tracing.debug(name + " Ignoring: " + o.toString()); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/RepositoryTrackerComponent.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/RepositoryTrackerComponent.java
new file mode 100644
index 000000000..fa416c2d4
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/RepositoryTrackerComponent.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2011 EclipseSource Inc. 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:
+ * EclipseSource Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.ui;
+
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.core.spi.IAgentServiceFactory;
+import org.eclipse.equinox.p2.operations.RepositoryTracker;
+import org.eclipse.equinox.p2.ui.ProvisioningUI;
+
+/**
+ * Component that provides a factory that can create and initialize
+ * {@link RepositoryTracker} instances.
+ */
+public class RepositoryTrackerComponent implements IAgentServiceFactory {
+
+ public Object createService(IProvisioningAgent agent) {
+ ProvisioningUI ui = (ProvisioningUI) agent.getService(ProvisioningUI.class.getName());
+ if (ui == null)
+ return null;
+ return new ColocatedRepositoryTracker(ui);
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/ProfileModificationAction.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/ProfileModificationAction.java
index 7ff6ad328..31d2fa5ca 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/ProfileModificationAction.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/ProfileModificationAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 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
@@ -172,10 +172,6 @@ public abstract class ProfileModificationAction extends ProvisioningAction {
return getProvisioningUI().getLicenseManager();
}
- protected QueryProvider getQueryProvider() {
- return ProvUI.getQueryProvider();
- }
-
protected final void checkEnablement(Object[] selections) {
if (isEnabledFor(selections)) {
setEnabled(!getProvisioningUI().hasScheduledOperations());
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUGroup.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUGroup.java
index aab30eb38..14d4f3300 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUGroup.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUGroup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 IBM Corporation and others.
+ * Copyright (c) 2008, 2011 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
@@ -168,7 +168,7 @@ public class AvailableIUGroup extends StructuredIUGroup {
// after content has been retrieved.
filteredTree.contentProviderSet(contentProvider);
- final StructuredViewerProvisioningListener listener = new StructuredViewerProvisioningListener(getClass().getName(), availableIUViewer, ProvUIProvisioningListener.PROV_EVENT_METADATA_REPOSITORY) {
+ final StructuredViewerProvisioningListener listener = new StructuredViewerProvisioningListener(getClass().getName(), availableIUViewer, ProvUIProvisioningListener.PROV_EVENT_METADATA_REPOSITORY, getProvisioningUI().getOperationRunner()) {
protected void repositoryAdded(final RepositoryEvent event) {
makeRepositoryVisible(event.getRepositoryLocation());
}
@@ -185,11 +185,11 @@ public class AvailableIUGroup extends StructuredIUGroup {
}
};
- ProvUIActivator.getDefault().addProvisioningListener(listener);
+ ProvUI.getProvisioningEventBus(getProvisioningUI().getSession()).addListener(listener);
availableIUViewer.getControl().addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
- ProvUIActivator.getDefault().removeProvisioningListener(listener);
+ ProvUI.getProvisioningEventBus(getProvisioningUI().getSession()).removeListener(listener);
}
});
updateAvailableViewState();
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java
index 65ade48b4..84f5e932c 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 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
@@ -633,7 +633,7 @@ public class AvailableIUsPage extends ProvisioningWizardPage implements ISelecta
// We might need to adjust the content of the available IU group's viewer
// according to installation changes. We want to be very selective about refreshing,
// because the viewer has its own listeners installed.
- profileListener = new StructuredViewerProvisioningListener(getClass().getName(), availableIUGroup.getStructuredViewer(), ProvUIProvisioningListener.PROV_EVENT_PROFILE) {
+ profileListener = new StructuredViewerProvisioningListener(getClass().getName(), availableIUGroup.getStructuredViewer(), ProvUIProvisioningListener.PROV_EVENT_PROFILE, getProvisioningUI().getOperationRunner()) {
protected void profileAdded(String id) {
// do nothing
}
@@ -649,12 +649,12 @@ public class AvailableIUsPage extends ProvisioningWizardPage implements ISelecta
}
};
- ProvUI.addProvisioningListener(profileListener);
+ ProvUI.getProvisioningEventBus(getProvisioningUI().getSession()).addListener(profileListener);
}
void removeProvisioningListeners() {
if (profileListener != null) {
- ProvUI.removeProvisioningListener(profileListener);
+ ProvUI.getProvisioningEventBus(getProvisioningUI().getSession()).removeListener(profileListener);
profileListener = null;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstalledIUGroup.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstalledIUGroup.java
index d944f93b9..fda71560f 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstalledIUGroup.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstalledIUGroup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 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
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.dialogs;
-import org.eclipse.equinox.internal.p2.ui.ProvUIActivator;
+import org.eclipse.equinox.internal.p2.ui.ProvUI;
import org.eclipse.equinox.internal.p2.ui.ProvUIProvisioningListener;
import org.eclipse.equinox.internal.p2.ui.model.ProfileElement;
import org.eclipse.equinox.internal.p2.ui.viewers.*;
@@ -45,7 +45,7 @@ public class InstalledIUGroup extends StructuredIUGroup {
public InstalledIUGroup(ProvisioningUI ui, final Composite parent, Font font, String profileId, IUColumnConfig[] columnConfig) {
super(ui, parent, font, columnConfig);
if (profileId == null)
- this.profileId = ProvisioningUI.getDefaultUI().getProfileId();
+ this.profileId = ui.getProfileId();
else
this.profileId = profileId;
createGroupComposite(parent);
@@ -71,11 +71,11 @@ public class InstalledIUGroup extends StructuredIUGroup {
// Input last.
installedIUViewer.setInput(getInput());
- final StructuredViewerProvisioningListener listener = new StructuredViewerProvisioningListener(getClass().getName(), installedIUViewer, ProvUIProvisioningListener.PROV_EVENT_IU | ProvUIProvisioningListener.PROV_EVENT_PROFILE);
- ProvUIActivator.getDefault().addProvisioningListener(listener);
+ final StructuredViewerProvisioningListener listener = new StructuredViewerProvisioningListener(getClass().getName(), installedIUViewer, ProvUIProvisioningListener.PROV_EVENT_IU | ProvUIProvisioningListener.PROV_EVENT_PROFILE, getProvisioningUI().getOperationRunner());
+ ProvUI.getProvisioningEventBus(getProvisioningUI().getSession()).addListener(listener);
installedIUViewer.getControl().addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
- ProvUIActivator.getDefault().removeProvisioningListener(listener);
+ ProvUI.getProvisioningEventBus(getProvisioningUI().getSession()).removeListener(listener);
}
});
return installedIUViewer;
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositorySelectionGroup.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositorySelectionGroup.java
index 80616b185..d4dffcd5f 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositorySelectionGroup.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositorySelectionGroup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * Copyright (c) 2009, 2011 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
@@ -95,7 +95,7 @@ public class RepositorySelectionGroup {
}
protected void createControl(Composite parent) {
- final RepositoryTracker tracker = ProvisioningUI.getDefaultUI().getRepositoryTracker();
+ final RepositoryTracker tracker = ui.getRepositoryTracker();
// Get the possible field error indicators
info = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage();
warning = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_WARNING).getImage();
@@ -487,7 +487,7 @@ public class RepositorySelectionGroup {
void addComboProvisioningListeners() {
// We need to monitor repository events so that we can adjust the repo combo.
- comboRepoListener = new ProvUIProvisioningListener(getClass().getName(), ProvUIProvisioningListener.PROV_EVENT_METADATA_REPOSITORY) {
+ comboRepoListener = new ProvUIProvisioningListener(getClass().getName(), ProvUIProvisioningListener.PROV_EVENT_METADATA_REPOSITORY, ui.getOperationRunner()) {
protected void repositoryAdded(RepositoryEvent e) {
fillRepoCombo(getSiteString(e.getRepositoryLocation()));
}
@@ -500,12 +500,12 @@ public class RepositorySelectionGroup {
fillRepoCombo(null);
}
};
- ProvUI.addProvisioningListener(comboRepoListener);
+ ProvUI.getProvisioningEventBus(ui.getSession()).addListener(comboRepoListener);
}
void removeProvisioningListeners() {
if (comboRepoListener != null) {
- ProvUI.removeProvisioningListener(comboRepoListener);
+ ProvUI.getProvisioningEventBus(ui.getSession()).removeListener(comboRepoListener);
comboRepoListener = null;
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/StructuredIUGroup.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/StructuredIUGroup.java
index c298a728b..450829d16 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/StructuredIUGroup.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/StructuredIUGroup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * Copyright (c) 2008, 2011 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
@@ -13,7 +13,6 @@ package org.eclipse.equinox.internal.p2.ui.dialogs;
import java.util.List;
import org.eclipse.equinox.internal.p2.ui.ProvUI;
-import org.eclipse.equinox.internal.p2.ui.QueryProvider;
import org.eclipse.equinox.internal.p2.ui.model.ElementUtils;
import org.eclipse.equinox.internal.p2.ui.viewers.IUColumnConfig;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
@@ -42,7 +41,6 @@ public abstract class StructuredIUGroup {
private Composite composite;
private ProvisioningUI ui;
private IUColumnConfig[] columnConfig;
- private QueryProvider queryProvider;
/**
* Create a group that represents the available IU's.
@@ -131,12 +129,6 @@ public abstract class StructuredIUGroup {
return Dialog.convertHeightInCharsToPixels(fm, dlus);
}
- protected QueryProvider getQueryProvider() {
- if (queryProvider == null)
- queryProvider = new QueryProvider(ui);
- return queryProvider;
- }
-
protected Policy getPolicy() {
return ui.getPolicy();
}
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 046657860..db6d0502c 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 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
@@ -19,7 +19,6 @@ import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
-import org.eclipse.equinox.p2.ui.ProvisioningUI;
/**
* Element wrapper class for a artifact repository that gets its
@@ -32,7 +31,6 @@ public class ArtifactRepositoryElement extends RemoteQueriedElement implements I
URI location;
IArtifactRepository repo;
boolean isEnabled;
- ProvisioningUI ui;
public ArtifactRepositoryElement(Object parent, URI location) {
this(parent, location, true);
@@ -42,7 +40,6 @@ public class ArtifactRepositoryElement extends RemoteQueriedElement implements I
super(parent);
this.location = location;
this.isEnabled = isEnabled;
- ui = ProvUIActivator.getDefault().getProvisioningUI();
}
@SuppressWarnings("rawtypes")
@@ -71,7 +68,7 @@ public class ArtifactRepositoryElement extends RemoteQueriedElement implements I
try {
repo = getArtifactRepositoryManager().loadRepository(location, monitor);
} catch (ProvisionException e) {
- ui.getRepositoryTracker().reportLoadFailure(location, e);
+ getProvisioningUI().getRepositoryTracker().reportLoadFailure(location, e);
} catch (OperationCanceledException e) {
// nothing to report
}
@@ -103,7 +100,7 @@ public class ArtifactRepositoryElement extends RemoteQueriedElement implements I
* @see org.eclipse.equinox.internal.provisional.p2.ui.model.RepositoryElement#getDescription()
*/
public String getDescription() {
- if (ui.getRepositoryTracker().hasNotFoundStatusBeenReported(location))
+ if (getProvisioningUI().getRepositoryTracker().hasNotFoundStatusBeenReported(location))
return ProvUIMessages.RepositoryElement_NotFound;
String description = getArtifactRepositoryManager().getRepositoryProperty(location, IRepository.PROP_DESCRIPTION);
if (description == null)
@@ -144,6 +141,6 @@ public class ArtifactRepositoryElement extends RemoteQueriedElement implements I
}
IArtifactRepositoryManager getArtifactRepositoryManager() {
- return ProvUI.getArtifactRepositoryManager(ui.getSession());
+ return ProvUI.getArtifactRepositoryManager(getProvisioningUI().getSession());
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ElementUtils.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ElementUtils.java
index f6a5ab2f8..8fa52a46f 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ElementUtils.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ElementUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * Copyright (c) 2008, 2011 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
@@ -16,7 +16,6 @@ import java.net.URI;
import java.util.*;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.ui.ProvUI;
-import org.eclipse.equinox.internal.p2.ui.ProvUIActivator;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.IRepositoryManager;
@@ -33,8 +32,7 @@ import org.eclipse.swt.widgets.Shell;
*/
public class ElementUtils {
- public static void updateRepositoryUsingElements(final MetadataRepositoryElement[] elements, final Shell shell) {
- final ProvisioningUI ui = ProvUIActivator.getDefault().getProvisioningUI();
+ public static void updateRepositoryUsingElements(final ProvisioningUI ui, final MetadataRepositoryElement[] elements, final Shell shell) {
ui.signalRepositoryOperationStart();
IMetadataRepositoryManager metaManager = ProvUI.getMetadataRepositoryManager(ui.getSession());
IArtifactRepositoryManager artManager = ProvUI.getArtifactRepositoryManager(ui.getSession());
@@ -93,8 +91,8 @@ public class ElementUtils {
}
private static void setColocatedRepositoryEnablement(ProvisioningUI ui, URI location, boolean enable) {
- ProvUI.getArtifactRepositoryManager(ProvUIActivator.getDefault().getSession()).setEnabled(location, enable);
- ProvUI.getMetadataRepositoryManager(ProvUIActivator.getDefault().getSession()).setEnabled(location, enable);
+ ProvUI.getArtifactRepositoryManager(ui.getSession()).setEnabled(location, enable);
+ ProvUI.getMetadataRepositoryManager(ui.getSession()).setEnabled(location, enable);
}
public static IInstallableUnit getIU(Object element) {
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/MetadataRepositoryElement.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/MetadataRepositoryElement.java
index 0892b2829..89b7fcccc 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/MetadataRepositoryElement.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/MetadataRepositoryElement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 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
@@ -39,14 +39,14 @@ public class MetadataRepositoryElement extends RootElement implements IRepositor
String name;
public MetadataRepositoryElement(Object parent, URI location, boolean isEnabled) {
- this(parent, null, ProvisioningUI.getDefaultUI(), location, isEnabled);
+ this(parent, null, null, location, isEnabled);
}
public MetadataRepositoryElement(IUViewQueryContext queryContext, ProvisioningUI ui, URI location, boolean isEnabled) {
this(null, queryContext, ui, location, isEnabled);
}
- private MetadataRepositoryElement(Object parent, IUViewQueryContext queryContext, ProvisioningUI ui, URI location, boolean isEnabled) {
+ public MetadataRepositoryElement(Object parent, IUViewQueryContext queryContext, ProvisioningUI ui, URI location, boolean isEnabled) {
super(parent, queryContext, ui);
this.location = location;
this.isEnabled = isEnabled;
@@ -222,7 +222,7 @@ public class MetadataRepositoryElement extends RootElement implements IRepositor
return super.getPolicy();
if (parent instanceof QueriedElement)
return ((QueriedElement) parent).getPolicy();
- return ProvisioningUI.getDefaultUI().getPolicy();
+ return getProvisioningUI().getPolicy();
}
public String toString() {
@@ -239,4 +239,21 @@ public class MetadataRepositoryElement extends RootElement implements IRepositor
IMetadataRepositoryManager getMetadataRepositoryManager() {
return ProvUI.getMetadataRepositoryManager(getProvisioningUI().getSession());
}
+
+ /**
+ * MetadataRepositoryElements can sometimes be roots and sometimes children.
+ * When they are roots the should have a ui set directly. As children they should
+ * defer to the parent to get the ui.
+ */
+ public ProvisioningUI getProvisioningUI() {
+ ProvisioningUI ui = super.getProvisioningUI();
+ if (ui != null)
+ return ui;
+ Object parent = getParent(this);
+ if (parent != null && parent instanceof QueriedElement)
+ return ((QueriedElement) parent).getProvisioningUI();
+ // if all else fails get the global UI. This should not really happen but
+ // we need to account for some possible historical cases.
+ return ProvisioningUI.getDefaultUI();
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ProfileSnapshots.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ProfileSnapshots.java
index f58d67e4e..effaf6b96 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ProfileSnapshots.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ProfileSnapshots.java
@@ -13,7 +13,9 @@ package org.eclipse.equinox.internal.p2.ui.model;
import java.util.*;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.equinox.internal.p2.ui.*;
+import org.eclipse.equinox.internal.p2.ui.ProvUI;
+import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
+import org.eclipse.equinox.p2.operations.ProvisioningSession;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.IProfileRegistry;
import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
@@ -27,10 +29,12 @@ import org.eclipse.ui.progress.IElementCollector;
public class ProfileSnapshots extends ProvElement implements IDeferredWorkbenchAdapter {
String profileId;
+ ProvisioningSession session;
- public ProfileSnapshots(String profileId) {
+ public ProfileSnapshots(String profileId, ProvisioningSession session) {
super(null);
this.profileId = profileId;
+ this.session = session;
}
public String getProfileId() {
@@ -41,7 +45,7 @@ public class ProfileSnapshots extends ProvElement implements IDeferredWorkbenchA
* @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
*/
public Object[] getChildren(Object o) {
- IProfileRegistry registry = ProvUI.getProfileRegistry(ProvUIActivator.getDefault().getSession());
+ IProfileRegistry registry = ProvUI.getProfileRegistry(session);
long[] timestamps = registry.listProfileTimestamps(profileId);
// find out which profile states we should hide
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/QueriedElement.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/QueriedElement.java
index f4bb6a83e..a478e683f 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/QueriedElement.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/QueriedElement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 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,8 @@ import java.util.*;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
-import org.eclipse.equinox.internal.p2.ui.*;
+import org.eclipse.equinox.internal.p2.ui.ElementQueryDescriptor;
+import org.eclipse.equinox.internal.p2.ui.QueryProvider;
import org.eclipse.equinox.internal.p2.ui.query.IUViewQueryContext;
import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.equinox.p2.ui.Policy;
@@ -43,14 +44,17 @@ public abstract class QueriedElement extends ProvElement {
Object parent = getParent(this);
if (parent instanceof QueriedElement)
return ((QueriedElement) parent).getPolicy();
- return ProvUIActivator.getDefault().getProvisioningUI().getPolicy();
+ return getProvisioningUI().getPolicy();
}
public ProvisioningUI getProvisioningUI() {
Object parent = getParent(this);
if (parent instanceof QueriedElement)
return ((QueriedElement) parent).getProvisioningUI();
- return ProvUIActivator.getDefault().getProvisioningUI();
+ // if we really can't find a UI then get the default. In general this should
+ // not happen though. Turn on tracing in getDefaultUI() to see places where
+ // it is happening.
+ return ProvisioningUI.getDefaultUI();
}
@@ -65,10 +69,6 @@ public abstract class QueriedElement extends ProvElement {
return fetchChildren(o, new NullProgressMonitor());
}
- public QueryProvider getQueryProvider() {
- return ProvUI.getQueryProvider();
- }
-
/*
* (non-Javadoc)
* @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
@@ -97,9 +97,8 @@ public abstract class QueriedElement extends ProvElement {
protected Object[] fetchChildren(Object o, IProgressMonitor monitor) {
cachedChildren = CollectionUtils.emptyList();
- if (getQueryProvider() == null)
- return new Object[0];
- ElementQueryDescriptor queryDescriptor = getQueryProvider().getQueryDescriptor(this);
+ QueryProvider provider = new QueryProvider(getProvisioningUI());
+ ElementQueryDescriptor queryDescriptor = provider.getQueryDescriptor(this);
if (queryDescriptor == null)
return new Object[0];
Collection<?> results = queryDescriptor.performQuery(monitor);
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/QueriedElementWrapper.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/QueriedElementWrapper.java
index e5085ab66..f3a43e045 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/QueriedElementWrapper.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/QueriedElementWrapper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 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
@@ -19,7 +19,6 @@ import org.eclipse.equinox.internal.p2.ui.query.IUViewQueryContext;
import org.eclipse.equinox.p2.operations.RepositoryTracker;
import org.eclipse.equinox.p2.query.Collector;
import org.eclipse.equinox.p2.query.IQueryable;
-import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.osgi.util.NLS;
/**
@@ -66,8 +65,8 @@ public abstract class QueriedElementWrapper extends ElementWrapper {
// is empty and the parent is an IU, then being empty is not a big deal, it means
// we are in drilldown.
if (parent instanceof MetadataRepositoryElement) {
- RepositoryTracker manipulator = ProvisioningUI.getDefaultUI().getRepositoryTracker();
MetadataRepositoryElement repo = (MetadataRepositoryElement) parent;
+ RepositoryTracker manipulator = repo.getProvisioningUI().getRepositoryTracker();
if (manipulator.hasNotFoundStatusBeenReported(repo.getLocation())) {
return emptyExplanation(IStatus.ERROR, NLS.bind(ProvUIMessages.QueriedElementWrapper_SiteNotFound, URIUtil.toUnencodedString(repo.getLocation())), ""); //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/ArtifactRepositoryElementWrapper.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/ArtifactRepositoryElementWrapper.java
index a81b6bc9d..bd6ea58a6 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/ArtifactRepositoryElementWrapper.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/ArtifactRepositoryElementWrapper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 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
@@ -13,10 +13,9 @@ package org.eclipse.equinox.internal.p2.ui.query;
import java.net.URI;
import org.eclipse.equinox.internal.p2.ui.ProvUI;
-import org.eclipse.equinox.internal.p2.ui.model.ArtifactRepositoryElement;
-import org.eclipse.equinox.internal.p2.ui.model.QueriedElementWrapper;
+import org.eclipse.equinox.internal.p2.ui.model.*;
+import org.eclipse.equinox.p2.operations.ProvisioningSession;
import org.eclipse.equinox.p2.query.IQueryable;
-import org.eclipse.equinox.p2.ui.ProvisioningUI;
/**
* ElementWrapper that wraps a URI with an ArtifactRepositoryElement.
@@ -46,6 +45,13 @@ public class ArtifactRepositoryElementWrapper extends QueriedElementWrapper {
* Transforms the item to a UI element
*/
protected Object wrap(Object item) {
- return super.wrap(new ArtifactRepositoryElement(parent, (URI) item, ProvUI.getArtifactRepositoryManager(ProvisioningUI.getDefaultUI().getSession()).isEnabled((URI) item)));
+ // Assume the item is enabled
+ boolean enabled = true;
+ // if the parent is a queried element then use its provisioning UI to find out about enablement
+ if (parent instanceof QueriedElement) {
+ ProvisioningSession session = ((QueriedElement) parent).getProvisioningUI().getSession();
+ enabled = ProvUI.getArtifactRepositoryManager(session).isEnabled((URI) item);
+ }
+ return super.wrap(new ArtifactRepositoryElement(parent, (URI) item, enabled));
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/MetadataRepositoryElementWrapper.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/MetadataRepositoryElementWrapper.java
index 3718ba120..70487fcf8 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/MetadataRepositoryElementWrapper.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/MetadataRepositoryElementWrapper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 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
@@ -13,10 +13,9 @@ package org.eclipse.equinox.internal.p2.ui.query;
import java.net.URI;
import org.eclipse.equinox.internal.p2.ui.ProvUI;
-import org.eclipse.equinox.internal.p2.ui.model.MetadataRepositoryElement;
-import org.eclipse.equinox.internal.p2.ui.model.QueriedElementWrapper;
+import org.eclipse.equinox.internal.p2.ui.model.*;
+import org.eclipse.equinox.p2.operations.ProvisioningSession;
import org.eclipse.equinox.p2.query.IQueryable;
-import org.eclipse.equinox.p2.ui.ProvisioningUI;
/**
* ElementWrapper that accepts the matched repo URLs and
@@ -47,6 +46,14 @@ public class MetadataRepositoryElementWrapper extends QueriedElementWrapper {
* Transforms the item to a UI element
*/
protected Object wrap(Object item) {
- return super.wrap(new MetadataRepositoryElement(parent, (URI) item, ProvUI.getMetadataRepositoryManager(ProvisioningUI.getDefaultUI().getSession()).isEnabled((URI) item)));
+ // Assume the item is enabled
+ boolean enabled = true;
+ // if the parent is a queried element then use its provisioning UI to find out about enablement
+ if (parent instanceof QueriedElement) {
+ ProvisioningSession session = ((QueriedElement) parent).getProvisioningUI().getSession();
+ enabled = ProvUI.getMetadataRepositoryManager(session).isEnabled((URI) item);
+ }
+ return super.wrap(new MetadataRepositoryElement(parent, (URI) item, enabled));
}
+
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/StructuredViewerProvisioningListener.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/StructuredViewerProvisioningListener.java
index 733fd9e52..ea51d5bd8 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/StructuredViewerProvisioningListener.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/StructuredViewerProvisioningListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 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
@@ -12,6 +12,7 @@
package org.eclipse.equinox.internal.p2.ui.viewers;
import org.eclipse.equinox.internal.p2.ui.ProvUIProvisioningListener;
+import org.eclipse.equinox.internal.p2.ui.ProvisioningOperationRunner;
import org.eclipse.equinox.internal.p2.ui.model.ProfileElement;
import org.eclipse.equinox.internal.provisional.p2.repository.RepositoryEvent;
import org.eclipse.jface.viewers.StructuredViewer;
@@ -33,8 +34,8 @@ public class StructuredViewerProvisioningListener extends ProvUIProvisioningList
StructuredViewer viewer;
Display display;
- public StructuredViewerProvisioningListener(String name, StructuredViewer viewer, int eventTypes) {
- super(name, eventTypes);
+ public StructuredViewerProvisioningListener(String name, StructuredViewer viewer, int eventTypes, ProvisioningOperationRunner runner) {
+ super(name, eventTypes, runner);
this.viewer = viewer;
this.display = viewer.getControl().getDisplay();
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/InstalledSoftwarePage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/InstalledSoftwarePage.java
index 906213ecc..4b9e8bca5 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/InstalledSoftwarePage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/InstalledSoftwarePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * Copyright (c) 2008, 2011 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
@@ -68,10 +68,9 @@ public class InstalledSoftwarePage extends InstallationPage implements ICopyable
initializeDialogUnits(parent);
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IProvHelpContextIds.INSTALLED_SOFTWARE);
- ui = ProvisioningUI.getDefaultUI();
- profileId = ui.getProfileId();
+ profileId = getProvisioningUI().getProfileId();
if (profileId == null) {
- IStatus status = ui.getPolicy().getNoProfileChosenStatus();
+ IStatus status = getProvisioningUI().getPolicy().getNoProfileChosenStatus();
if (status != null)
ProvUI.reportStatus(status, StatusManager.LOG);
Text text = new Text(parent, SWT.WRAP | SWT.READ_ONLY);
@@ -92,7 +91,7 @@ public class InstalledSoftwarePage extends InstallationPage implements ICopyable
composite.setLayout(layout);
// Table of installed IU's
- installedIUGroup = new InstalledIUGroup(ui, composite, JFaceResources.getDialogFont(), profileId, getColumnConfig());
+ installedIUGroup = new InstalledIUGroup(getProvisioningUI(), composite, JFaceResources.getDialogFont(), profileId, getColumnConfig());
// we hook selection listeners on the viewer in createPageButtons because we
// rely on the actions we create there getting selection events before we use
// them to update button enablement.
@@ -123,7 +122,7 @@ public class InstalledSoftwarePage extends InstallationPage implements ICopyable
// if we successfully try to resolve. This is done to ensure that progress
// is shown properly.
// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=236495
- UpdateAction updateAction = new UpdateAction(ui, new ISelectionProvider() {
+ UpdateAction updateAction = new UpdateAction(getProvisioningUI(), new ISelectionProvider() {
public void addSelectionChangedListener(ISelectionChangedListener listener) {
installedIUGroup.getStructuredViewer().addSelectionChangedListener(listener);
}
@@ -156,7 +155,7 @@ public class InstalledSoftwarePage extends InstallationPage implements ICopyable
updateButton = createButton(parent, UPDATE_ID, updateAction.getText());
updateButton.setData(BUTTON_ACTION, updateAction);
// Uninstall action
- Action uninstallAction = new UninstallAction(ui, installedIUGroup.getStructuredViewer(), profileId) {
+ Action uninstallAction = new UninstallAction(getProvisioningUI(), installedIUGroup.getStructuredViewer(), profileId) {
public void run() {
super.run();
if (getReturnCode() == Window.OK)
@@ -253,4 +252,22 @@ public class InstalledSoftwarePage extends InstallationPage implements ICopyable
break;
}
}
+
+ ProvisioningUI getProvisioningUI() {
+ // if a UI has not been set then assume that the current default UI is the right thing
+ if (ui == null)
+ return ui = ProvisioningUI.getDefaultUI();
+ return ui;
+ }
+
+ /**
+ * Set the provisioning UI to use with this page
+ *
+ * @param value the provisioning ui to use
+ * @since 2.1
+ */
+ public void setProvisioningUI(ProvisioningUI value) {
+ ui = value;
+ }
+
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUI.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUI.java
index 89e6c3748..adf22fb54 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUI.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUI.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * Copyright (c) 2009, 2011 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
@@ -76,6 +76,8 @@ public class ProvisioningUI {
this.profileId = IProfileRegistry.SELF;
this.session = session;
this.runner = new ProvisioningOperationRunner(this);
+ // register this UI with the agent so other UI related agent services can find it
+ session.getProvisioningAgent().registerService(ProvisioningUI.class.getName(), this);
}
/**
@@ -114,7 +116,7 @@ public class ProvisioningUI {
* @return the repository tracker, must not be <code>null</code>
*/
public RepositoryTracker getRepositoryTracker() {
- return (RepositoryTracker) ServiceHelper.getService(ProvUIActivator.getContext(), RepositoryTracker.class.getName());
+ return (RepositoryTracker) session.getProvisioningAgent().getService(RepositoryTracker.class.getName());
}
/**
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java
index e1f2935b4..843cfc5cd 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 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
@@ -374,10 +374,10 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
verticalButtonBar.setLayoutData(data);
listener = getViewerProvisioningListener();
- ProvUI.addProvisioningListener(listener);
+ ProvUI.getProvisioningEventBus(ui.getSession()).addListener(listener);
composite.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) {
- ProvUI.removeProvisioningListener(listener);
+ ProvUI.getProvisioningEventBus(ui.getSession()).removeListener(listener);
}
});
@@ -540,12 +540,12 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
*/
public boolean performOk() {
if (changed)
- ElementUtils.updateRepositoryUsingElements(getElements(), getShell());
+ ElementUtils.updateRepositoryUsingElements(ui, getElements(), getShell());
return super.performOk();
}
private StructuredViewerProvisioningListener getViewerProvisioningListener() {
- return new StructuredViewerProvisioningListener(RepositoryManipulationPage.this.getClass().getName(), repositoryViewer, ProvUIProvisioningListener.PROV_EVENT_METADATA_REPOSITORY) {
+ return new StructuredViewerProvisioningListener(RepositoryManipulationPage.this.getClass().getName(), repositoryViewer, ProvUIProvisioningListener.PROV_EVENT_METADATA_REPOSITORY, ui.getOperationRunner()) {
protected void repositoryDiscovered(RepositoryEvent e) {
RepositoryManipulationPage.this.safeRefresh(null);
}
@@ -868,7 +868,7 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
public void addRepository(URI location, String nickname, ProvisioningSession session) {
MetadataRepositoryElement element = getInput().get(location);
if (element == null) {
- element = new MetadataRepositoryElement(getInput(), location, true);
+ element = new MetadataRepositoryElement(getInput(), null, ui, location, true);
getInput().put(element);
}
if (nickname != null)
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java
index 1456612ca..06c0a48a9 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 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
@@ -86,10 +86,9 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
- ui = ProvisioningUI.getDefaultUI();
- profileId = ui.getProfileId();
+ profileId = getProvisioningUI().getProfileId();
if (profileId == null) {
- IStatus status = ui.getPolicy().getNoProfileChosenStatus();
+ IStatus status = getProvisioningUI().getPolicy().getNoProfileChosenStatus();
if (status != null)
ProvUI.reportStatus(status, StatusManager.LOG);
Text text = new Text(parent, SWT.WRAP | SWT.READ_ONLY);
@@ -213,7 +212,7 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
}
private Object getInput() {
- ProfileSnapshots element = new ProfileSnapshots(profileId);
+ ProfileSnapshots element = new ProfileSnapshots(profileId, getProvisioningUI().getSession());
return element;
}
@@ -335,7 +334,7 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
ProfileModificationJob op = new ProfileModificationJob(ProvUIMessages.RevertDialog_RevertOperationLabel, getSession(), profileId, plan[0], new ProvisioningContext(getSession().getProvisioningAgent()));
// we want to force a restart (not allow apply changes)
op.setRestartPolicy(ProvisioningJob.RESTART_ONLY);
- ui.schedule(op, StatusManager.SHOW | StatusManager.LOG);
+ getProvisioningUI().schedule(op, StatusManager.SHOW | StatusManager.LOG);
reverted = true;
} else if (plan[0].getStatus().getSeverity() != IStatus.CANCEL) {
ProvUI.reportStatus(plan[0].getStatus(), StatusManager.LOG | StatusManager.SHOW);
@@ -406,11 +405,23 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
}
ProvisioningUI getProvisioningUI() {
- return ProvisioningUI.getDefaultUI();
+ // if a UI has not been set then assume that the current default UI is the right thing
+ if (ui == null)
+ return ui = ProvisioningUI.getDefaultUI();
+ return ui;
}
protected IStructuredSelection getSelection() {
return (IStructuredSelection) configsViewer.getSelection();
}
+ /**
+ * Set the provisioning UI to use with this page
+ *
+ * @param value the provisioning ui to use
+ * @since 2.1
+ */
+ public void setProvisioningUI(ProvisioningUI value) {
+ ui = value;
+ }
}

Back to the top