Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2010-01-13 17:29:41 +0000
committerPascal Rapicault2010-01-13 17:29:41 +0000
commit18189f0d42f7375660762dc6c885cf31683ae562 (patch)
tree17775d847bed9a33f3c68b74db2df75a2139c0bc /examples
parentc363f2984a09b73c422e38f4556fd3b23eafe958 (diff)
downloadrt.equinox.p2-18189f0d42f7375660762dc6c885cf31683ae562.tar.gz
rt.equinox.p2-18189f0d42f7375660762dc6c885cf31683ae562.tar.xz
rt.equinox.p2-18189f0d42f7375660762dc6c885cf31683ae562.zip
Merging api branch back to HEADv20100113
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.cloud/.settings/org.eclipse.jdt.core.prefs2
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.cloud/META-INF/MANIFEST.MF3
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/Activator.java3
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/CloudPolicy.java13
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/InstallNewSoftwareHandler.java53
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/Messages.java25
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/PreloadingRepositoryHandler.java82
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/UpdateHandler.java72
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/messages.properties15
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/.settings/org.eclipse.jdt.core.prefs2
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/META-INF/MANIFEST.MF12
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/ApplicationWorkbenchAdvisor.java57
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/P2Util.java197
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/.settings/org.eclipse.jdt.core.prefs2
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/META-INF/MANIFEST.MF3
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/AllIUsAreVisiblePolicy.java16
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/InstallNewSoftwareHandler.java53
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/Messages.java1
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/PreloadingRepositoryHandler.java82
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/ProvisioningPreferencePage.java9
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/UpdateHandler.java75
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/messages.properties1
22 files changed, 237 insertions, 541 deletions
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/.settings/org.eclipse.jdt.core.prefs b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/.settings/org.eclipse.jdt.core.prefs
index 88da5d43a..8f8669add 100644
--- a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/.settings/org.eclipse.jdt.core.prefs
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/.settings/org.eclipse.jdt.core.prefs
@@ -1,7 +1,7 @@
#Thu Mar 12 11:04:59 PDT 2009
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=jsr14
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/META-INF/MANIFEST.MF b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/META-INF/MANIFEST.MF
index 5c908b502..5796e7571 100644
--- a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/META-INF/MANIFEST.MF
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/META-INF/MANIFEST.MF
@@ -7,7 +7,8 @@ Bundle-Activator: org.eclipse.equinox.p2.examples.rcp.cloud.Activator
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.eclipse.equinox.p2.ui;bundle-version="1.0.100",
+ org.eclipse.equinox.p2.operations;bundle-version="2.0.0",
+ org.eclipse.equinox.p2.ui;bundle-version="2.0.0",
org.eclipse.equinox.p2.metadata;bundle-version="1.0.0",
org.eclipse.equinox.p2.metadata.repository;bundle-version="1.0.0",
org.eclipse.equinox.p2.artifact.repository;bundle-version="1.0.0",
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/Activator.java b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/Activator.java
index c12d07d85..c0589471a 100644
--- a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/Activator.java
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/Activator.java
@@ -1,8 +1,7 @@
package org.eclipse.equinox.p2.examples.rcp.cloud;
-import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
import org.eclipse.equinox.p2.examples.rcp.cloud.p2.CloudPolicy;
+import org.eclipse.equinox.p2.ui.Policy;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/CloudPolicy.java b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/CloudPolicy.java
index bc962fb16..c5b754f93 100644
--- a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/CloudPolicy.java
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/CloudPolicy.java
@@ -10,8 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.p2.examples.rcp.cloud.p2;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.IUViewQueryContext;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
+import org.eclipse.equinox.p2.ui.Policy;
/**
* CloudPolicy defines the RCP Cloud Example policies for the p2 UI. The policy
@@ -21,12 +20,10 @@ import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
*/
public class CloudPolicy extends Policy {
public CloudPolicy() {
- // XXX User has no access to manipulate repositories
- setRepositoryManipulator(null);
-
+ // XXX User has no visibility for repos
+ setRepositoriesVisible(false);
+
// XXX Default view is by category
- IUViewQueryContext queryContext = new IUViewQueryContext(
- IUViewQueryContext.AVAILABLE_VIEW_BY_CATEGORY);
- setQueryContext(queryContext);
+ setGroupByCategory(true);
}
}
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/InstallNewSoftwareHandler.java b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/InstallNewSoftwareHandler.java
index 9e08c2e2b..a7e9b7921 100644
--- a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/InstallNewSoftwareHandler.java
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/InstallNewSoftwareHandler.java
@@ -1,22 +1,17 @@
/*******************************************************************************
- * Copyright (c) 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:
+ * Copyright (c) 2008, 2009 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.examples.rcp.cloud.p2;
-import org.eclipse.equinox.internal.provisional.p2.ui.IProvHelpContextIds;
-import org.eclipse.equinox.internal.provisional.p2.ui.QueryableMetadataRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.InstallWizard;
-import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.ProvisioningWizardDialog;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.PlatformUI;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob;
/**
* InstallNewSoftwareHandler invokes the install wizard
@@ -32,21 +27,25 @@ public class InstallNewSoftwareHandler extends PreloadingRepositoryHandler {
super();
}
- protected void doExecute(String profileId, QueryableMetadataRepositoryManager manager) {
- InstallWizard wizard = new InstallWizard(Policy.getDefault(), profileId, null, null, manager);
- WizardDialog dialog = new ProvisioningWizardDialog(getShell(), wizard);
- dialog.create();
- PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), IProvHelpContextIds.INSTALL_WIZARD);
-
- dialog.open();
+ protected void doExecute(LoadMetadataRepositoryJob job) {
+ getProvisioningUI().openInstallWizard(getShell(), null, null, job);
}
protected boolean waitForPreload() {
- // If there is no way for the user to manipulate repositories,
- // then we may as well wait for existing repos to load so that
- // content is available. If the user can manipulate the
- // repositories, then we don't wait, because we don't know which
- // ones they want to work with.
- return Policy.getDefault().getRepositoryManipulator() == null;
+ // If the user cannot see repositories, then we may as well wait
+ // for existing repos to load so that content is available.
+ // If the user can manipulate the repositories, then we don't wait,
+ // because we don't know which ones they want to work with.
+ return !getProvisioningUI().getPolicy().getRepositoriesVisible();
+ }
+
+ protected void setLoadJobProperties(Job loadJob) {
+ super.setLoadJobProperties(loadJob);
+ // If we are doing a background load, we do not wish to authenticate, as the
+ // user is unaware that loading was needed
+ if (!waitForPreload()) {
+ loadJob.setProperty(LoadMetadataRepositoryJob.SUPPRESS_AUTHENTICATION_JOB_MARKER, Boolean.toString(true));
+ loadJob.setProperty(LoadMetadataRepositoryJob.SUPPRESS_REPOSITORY_EVENTS, Boolean.toString(true));
+ }
}
}
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/Messages.java b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/Messages.java
deleted file mode 100644
index 2e228a737..000000000
--- a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/Messages.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.examples.rcp.cloud.p2;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.equinox.p2.examples.rcp.cloud.p2.messages"; //$NON-NLS-1$
- static {
- // load message values from bundle file
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
- public static String InstallNewSoftwareHandler_LoadRepositoryJobLabel;
- public static String UpdateHandler_NoSitesMessage;
- public static String UpdateHandler_NoSitesTitle;
-}
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/PreloadingRepositoryHandler.java b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/PreloadingRepositoryHandler.java
index 8b2213a0c..66aa00c4a 100644
--- a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/PreloadingRepositoryHandler.java
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/PreloadingRepositoryHandler.java
@@ -12,28 +12,22 @@ package org.eclipse.equinox.p2.examples.rcp.cloud.p2;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.jobs.*;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry;
-import org.eclipse.equinox.internal.provisional.p2.ui.ProvUI;
-import org.eclipse.equinox.internal.provisional.p2.ui.QueryableMetadataRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob;
+import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
/**
- * PreloadingRepositoryHandler provides background loading of repositories
- * before executing the provisioning handler.
+ * PreloadingRepositoryHandler provides background loading of
+ * repositories before executing the provisioning handler.
*
* @since 3.5
*/
abstract class PreloadingRepositoryHandler extends AbstractHandler {
- Object LOAD_FAMILY = new Object();
-
/**
* The constructor.
*/
@@ -45,46 +39,26 @@ abstract class PreloadingRepositoryHandler extends AbstractHandler {
* Execute the command.
*/
public Object execute(ExecutionEvent event) {
- final String profileId = IProfileRegistry.SELF;
- BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
- public void run() {
- doExecuteAndLoad(profileId, preloadRepositories());
- }
- });
+ doExecuteAndLoad();
return null;
}
- void doExecuteAndLoad(final String profileId, boolean preloadRepositories) {
- // cancel any load that is already running
- Job.getJobManager().cancel(LOAD_FAMILY);
- final QueryableMetadataRepositoryManager queryableManager = new QueryableMetadataRepositoryManager(
- Policy.getDefault().getQueryContext(), false);
- if (preloadRepositories) {
- Job loadJob = new Job(
- Messages.InstallNewSoftwareHandler_LoadRepositoryJobLabel) {
-
- protected IStatus run(IProgressMonitor monitor) {
- queryableManager.loadAll(monitor);
- return Status.OK_STATUS;
- }
-
- public boolean belongsTo(Object family) {
- return family == LOAD_FAMILY;
- }
-
- };
+ void doExecuteAndLoad() {
+ if (preloadRepositories()) {
+ //cancel any load that is already running
+ Job.getJobManager().cancel(LoadMetadataRepositoryJob.LOAD_FAMILY);
+ final LoadMetadataRepositoryJob loadJob = new LoadMetadataRepositoryJob(getProvisioningUI());
+ setLoadJobProperties(loadJob);
if (waitForPreload()) {
loadJob.addJobChangeListener(new JobChangeAdapter() {
public void done(IJobChangeEvent event) {
if (PlatformUI.isWorkbenchRunning())
if (event.getResult().isOK()) {
- PlatformUI.getWorkbench().getDisplay()
- .asyncExec(new Runnable() {
- public void run() {
- doExecute(profileId,
- queryableManager);
- }
- });
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ doExecute(loadJob);
+ }
+ });
}
}
});
@@ -95,15 +69,14 @@ abstract class PreloadingRepositoryHandler extends AbstractHandler {
loadJob.setSystem(true);
loadJob.setUser(false);
loadJob.schedule();
- doExecute(profileId, queryableManager);
+ doExecute(null);
}
} else {
- doExecute(profileId, queryableManager);
+ doExecute(null);
}
}
- protected abstract void doExecute(String profileId,
- QueryableMetadataRepositoryManager manager);
+ protected abstract void doExecute(LoadMetadataRepositoryJob job);
protected boolean preloadRepositories() {
return true;
@@ -113,12 +86,19 @@ abstract class PreloadingRepositoryHandler extends AbstractHandler {
return true;
}
+ protected void setLoadJobProperties(Job loadJob) {
+ loadJob.setProperty(LoadMetadataRepositoryJob.ACCUMULATE_LOAD_ERRORS, Boolean.toString(true));
+ }
+
+ protected ProvisioningUI getProvisioningUI() {
+ return ProvisioningUI.getDefaultUI();
+ }
+
/**
* Return a shell appropriate for parenting dialogs of this handler.
- *
* @return a Shell
*/
protected Shell getShell() {
- return ProvUI.getDefaultParentShell();
+ return getProvisioningUI().getDefaultParentShell();
}
}
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/UpdateHandler.java b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/UpdateHandler.java
index 1668b09b3..77db223a1 100644
--- a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/UpdateHandler.java
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/UpdateHandler.java
@@ -10,22 +10,9 @@
*******************************************************************************/
package org.eclipse.equinox.p2.examples.rcp.cloud.p2;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.ui.ElementQueryDescriptor;
-import org.eclipse.equinox.internal.provisional.p2.ui.ProvUI;
-import org.eclipse.equinox.internal.provisional.p2.ui.QueryableMetadataRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.ui.actions.UpdateAction;
-import org.eclipse.equinox.internal.provisional.p2.ui.model.ProfileElement;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.RepositoryManipulator;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.equinox.p2.operations.RepositoryTracker;
+import org.eclipse.equinox.p2.operations.UpdateOperation;
+import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob;
/**
* UpdateHandler invokes the check for updates UI
@@ -36,59 +23,22 @@ public class UpdateHandler extends PreloadingRepositoryHandler {
boolean hasNoRepos = false;
- /**
- * The constructor.
- */
- public UpdateHandler() {
- // constructor
- }
-
- protected void doExecute(String profileId, QueryableMetadataRepositoryManager manager) {
+ protected void doExecute(LoadMetadataRepositoryJob job) {
if (hasNoRepos) {
- boolean goToSites = MessageDialog.openQuestion(getShell(), Messages.UpdateHandler_NoSitesTitle, Messages.UpdateHandler_NoSitesMessage);
- if (goToSites) {
- Policy.getDefault().getRepositoryManipulator().manipulateRepositories(getShell());
- }
return;
}
- // get the profile roots
- ElementQueryDescriptor queryDescriptor = Policy.getDefault().getQueryProvider().getQueryDescriptor(new ProfileElement(null, profileId));
- Collection collection = queryDescriptor.performQuery(null);
- final IInstallableUnit[] roots = new IInstallableUnit[collection.size()];
- Iterator iter = collection.iterator();
- int i = 0;
- while (iter.hasNext()) {
- roots[i] = (IInstallableUnit) ProvUI.getAdapter(iter.next(), IInstallableUnit.class);
- i++;
+ UpdateOperation operation = getProvisioningUI().getUpdateOperation(null, null);
+ // check for updates
+ operation.resolveModal(null);
+ if (getProvisioningUI().getPolicy().continueWorkingWithOperation(operation, getShell())) {
+ getProvisioningUI().openUpdateWizard(getShell(), true, operation, job);
}
- // now create an update action whose selection is all the roots
- UpdateAction action = new UpdateAction(Policy.getDefault(), new ISelectionProvider() {
-
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- // not dynamic
- }
-
- public ISelection getSelection() {
- return new StructuredSelection(roots);
- }
-
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {
- // not dynamic
- }
-
- public void setSelection(ISelection selection) {
- // not mutable
-
- }
- }, profileId, false);
- action.setRepositoryManager(manager);
- action.run();
}
protected boolean preloadRepositories() {
hasNoRepos = false;
- RepositoryManipulator repoMan = Policy.getDefault().getRepositoryManipulator();
- if (repoMan != null && repoMan.getKnownRepositories().length == 0) {
+ RepositoryTracker repoMan = getProvisioningUI().getRepositoryTracker();
+ if (repoMan.getKnownRepositories(getProvisioningUI().getSession()).length == 0) {
hasNoRepos = true;
return false;
}
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/messages.properties b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/messages.properties
deleted file mode 100644
index e16c86732..000000000
--- a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/messages.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-###############################################################################
-# Copyright (c) 2009 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
-###############################################################################
-
-
-InstallNewSoftwareHandler_LoadRepositoryJobLabel=Contacting Software Sites
-UpdateHandler_NoSitesMessage=There are no update sites to search. Do you wish to open the "Available Software Sites" preferences?
-UpdateHandler_NoSitesTitle=No Updates Found
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/.settings/org.eclipse.jdt.core.prefs b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/.settings/org.eclipse.jdt.core.prefs
index 337c4649f..92bb3f369 100644
--- a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/.settings/org.eclipse.jdt.core.prefs
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/.settings/org.eclipse.jdt.core.prefs
@@ -1,7 +1,7 @@
#Mon Mar 16 12:12:08 PDT 2009
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=jsr14
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/META-INF/MANIFEST.MF b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/META-INF/MANIFEST.MF
index 8f4e5b0d1..6ee61c3c6 100644
--- a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/META-INF/MANIFEST.MF
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/META-INF/MANIFEST.MF
@@ -6,15 +6,9 @@ Bundle-Version: 1.0.0.qualifier
Bundle-Activator: org.eclipse.equinox.p2.examples.rcp.prestartupdate.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.eclipse.equinox.p2.metadata;bundle-version="1.0.0",
- org.eclipse.equinox.p2.metadata.repository;bundle-version="1.0.0",
- org.eclipse.equinox.p2.artifact.repository;bundle-version="1.0.0",
- org.eclipse.equinox.p2.repository;bundle-version="1.0.0",
- org.eclipse.equinox.p2.extensionlocation;bundle-version="1.0.100",
- org.eclipse.equinox.p2.updatesite;bundle-version="1.0.0",
- org.eclipse.equinox.p2.director;bundle-version="1.0.100",
- org.eclipse.equinox.p2.engine;bundle-version="1.0.100",
- org.eclipse.equinox.p2.core;bundle-version="1.0.100",
+ org.eclipse.equinox.p2.core,
+ org.eclipse.equinox.p2.metadata,
+ org.eclipse.equinox.p2.operations,
org.eclipse.ecf;bundle-version="3.0.0",
org.eclipse.ecf.filetransfer;bundle-version="3.0.0",
org.eclipse.ecf.identity;bundle-version="3.0.0",
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/ApplicationWorkbenchAdvisor.java b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/ApplicationWorkbenchAdvisor.java
index c5f04b9b9..2ebb4ff39 100644
--- a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/ApplicationWorkbenchAdvisor.java
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/ApplicationWorkbenchAdvisor.java
@@ -1,33 +1,52 @@
package org.eclipse.equinox.p2.examples.rcp.prestartupdate;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchAdvisor;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
/**
- * This workbench advisor creates the window advisor, and specifies
- * the perspective id for the initial window.
+ * This workbench advisor creates the window advisor, and specifies the
+ * perspective id for the initial window.
*/
public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {
- public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
- return new ApplicationWorkbenchWindowAdvisor(configurer);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.application.WorkbenchAdvisor#preStartup()
- */
- public void preStartup() {
- // XXX check for updates before starting up.
- // If an update is performed, restart.
- if (P2Util.checkForUpdates())
- PlatformUI.getWorkbench().restart();
- }
-
+ public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
+ IWorkbenchWindowConfigurer configurer) {
+ return new ApplicationWorkbenchWindowAdvisor(configurer);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.application.WorkbenchAdvisor#preStartup()
+ */
+ public void preStartup() {
+ // XXX check for updates before starting up.
+ // If an update is performed, restart.
+
+ IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ if (P2Util.checkForUpdates(monitor))
+ PlatformUI.getWorkbench().restart();
+ }
+ };
+ try {
+ new ProgressMonitorDialog(null).run(true, true, runnable);
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ }
+ }
+
public String getInitialWindowPerspectiveId() {
return Perspective.ID;
- }
-
+ }
+
}
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/P2Util.java b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/P2Util.java
index 7ba13903b..404e33eb8 100644
--- a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/P2Util.java
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/P2Util.java
@@ -11,183 +11,46 @@
package org.eclipse.equinox.p2.examples.rcp.prestartupdate;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Iterator;
-
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.director.IPlanner;
-import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
-import org.eclipse.equinox.internal.provisional.p2.director.ProvisioningPlan;
-import org.eclipse.equinox.internal.provisional.p2.engine.DefaultPhaseSet;
-import org.eclipse.equinox.internal.provisional.p2.engine.IEngine;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.operations.ProvisioningJob;
+import org.eclipse.equinox.p2.operations.ProvisioningSession;
+import org.eclipse.equinox.p2.operations.UpdateOperation;
public class P2Util {
// XXX Check for updates to this application and return true if
// we have installed updates and need a restart.
- // This method is intentionally long and ugly in order to provide
- // "one-stop-shopping" for how to check for and perform an update.
- static boolean checkForUpdates() {
- // Before we show a progress dialog, at least find out that we have
- // installed content and repos to check.
- final IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper
- .getService(Activator.bundleContext, IProfileRegistry.class
- .getName());
- if (profileRegistry == null)
- return false;
- final IProfile profile = profileRegistry
- .getProfile(IProfileRegistry.SELF);
- if (profile == null)
- return false;
-
- // We are going to look for updates to all IU's in the profile. A
- // different query could be used if we are looking for updates to
- // a subset. For example, the p2 UI only looks for updates to those
- // IU's marked with a special property.
- final org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector collector = profile.query(InstallableUnitQuery.ANY,
- new Collector(), null);
- if (collector.isEmpty())
- return false;
- final IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper
+ static boolean checkForUpdates(IProgressMonitor monitor) {
+ IProvisioningAgent agent = (IProvisioningAgent) ServiceHelper
.getService(Activator.bundleContext,
- IMetadataRepositoryManager.class.getName());
- if (manager == null)
- return false;
- final URI[] reposToSearch = manager
- .getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
- if (reposToSearch.length == 0)
- return false;
- final IPlanner planner = (IPlanner) ServiceHelper.getService(
- Activator.bundleContext, IPlanner.class.getName());
- if (planner == null)
- return false;
- // Looking in all known repositories for updates for each IU in the profile
- final boolean[] didWeUpdate = new boolean[1];
- didWeUpdate[0] = false;
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
- // We'll break progress up into 4 steps.
- // 1. Load repos - it is not strictly necessary to do this.
- // The planner will do it for us. However, burying this
- // in the planner's progress reporting will not
- // show enough progress initially, so we do it manually.
- // 2. Get update list
- // 3. Build a profile change request and get a provisioning plan
- // 4. Perform the provisioning plan.
- SubMonitor sub = SubMonitor.convert(monitor,
- "Checking for application updates...", 400);
- // 1. Load repos
- SubMonitor loadMonitor = sub.newChild(100, SubMonitor.SUPPRESS_ALL_LABELS);
- for (int i=0; i<reposToSearch.length; i++)
- try {
- if (loadMonitor.isCanceled())
- throw new InterruptedException();
- manager.loadRepository(reposToSearch[i], loadMonitor.newChild(100/reposToSearch.length));
- } catch (ProvisionException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- loadMonitor.done();
-
- // 2. Get update list.
- // First we look for replacement IU's for each IU
- ArrayList iusWithUpdates = new ArrayList();
- ArrayList replacementIUs = new ArrayList();
- Iterator iter = collector.iterator();
- ProvisioningContext pc = new ProvisioningContext(reposToSearch);
- SubMonitor updateSearchMonitor = sub.newChild(100, SubMonitor.SUPPRESS_ALL_LABELS);
- while (iter.hasNext()) {
- if (updateSearchMonitor.isCanceled())
- throw new InterruptedException();
- IInstallableUnit iu = (IInstallableUnit) iter.next();
- IInstallableUnit[] replacements = planner.updatesFor(iu,
- pc, updateSearchMonitor.newChild(100/collector.size()));
- if (replacements.length > 0) {
- iusWithUpdates.add(iu);
- if (replacements.length == 1)
- replacementIUs.add(replacements[0]);
- else {
- IInstallableUnit repl = replacements[0];
- for (int i = 1; i < replacements.length; i++)
- if (replacements[i].getVersion().compareTo(
- repl.getVersion()) > 0)
- repl = replacements[i];
- replacementIUs.add(repl);
- }
- }
- }
- // Did we find any updates?
- if (iusWithUpdates.size() == 0) {
- sub.done();
- } else {
- if (sub.isCanceled())
- throw new InterruptedException();
- // 3. Build a profile change request and get a provisioning plan
- ProfileChangeRequest changeRequest = new ProfileChangeRequest(
- profile);
- changeRequest
- .removeInstallableUnits((IInstallableUnit[]) iusWithUpdates
- .toArray(new IInstallableUnit[iusWithUpdates
- .size()]));
- changeRequest
- .addInstallableUnits((IInstallableUnit[]) replacementIUs
- .toArray(new IInstallableUnit[replacementIUs
- .size()]));
- ProvisioningPlan plan = planner.getProvisioningPlan(
- changeRequest, pc, sub.newChild(100, SubMonitor.SUPPRESS_ALL_LABELS));
- if (plan.getStatus().getSeverity() == IStatus.CANCEL)
- throw new InterruptedException();
- if (plan.getStatus().getSeverity() != IStatus.ERROR) {
- IEngine engine = (IEngine) ServiceHelper.getService(
- Activator.bundleContext, IEngine.class
- .getName());
- IArtifactRepositoryManager artifactMgr = (IArtifactRepositoryManager) ServiceHelper
- .getService(Activator.bundleContext,
- IArtifactRepositoryManager.class
- .getName());
- if (engine != null && artifactMgr != null) {
- // 4. Perform the provisioning plan
- pc
- .setArtifactRepositories(artifactMgr
- .getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL));
- IStatus status = engine.perform(profile,
- new DefaultPhaseSet(), plan.getOperands(),
- pc, sub.newChild(100, SubMonitor.SUPPRESS_ALL_LABELS));
- if (status.getSeverity() == IStatus.CANCEL)
- throw new InterruptedException();
- if (status.getSeverity() != IStatus.ERROR) {
- didWeUpdate[0] = true;
- }
- }
- }
- }
+ IProvisioningAgent.SERVICE_NAME);
+ if (agent == null)
+ return false;
+ ProvisioningSession session = new ProvisioningSession(agent);
+ // the default update operation looks for updates to the currently
+ // running profile, using the default profile root marker. To change
+ // which installable units are being updated, use the more detailed
+ // constructors.
+ UpdateOperation operation = new UpdateOperation(session);
+
+ SubMonitor sub = SubMonitor.convert(monitor,
+ "Checking for application updates...", 200);
+ IStatus status = operation.resolveModal(sub.newChild(100));
+ if (status.getSeverity() == IStatus.CANCEL)
+ throw new OperationCanceledException();
+ if (status.getSeverity() != IStatus.ERROR) {
+ ProvisioningJob job = operation.getProvisioningJob(null);
+ status = job.runModal(sub.newChild(100));
+ if (status.getSeverity() == IStatus.CANCEL)
+ throw new OperationCanceledException();
+ if (status.getSeverity() != IStatus.ERROR) {
+ return true;
}
- };
- try {
- new ProgressMonitorDialog(null).run(true, true, runnable);
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- return false;
- } catch (InterruptedException e) {
- return false;
}
- return didWeUpdate[0];
+ return false;
}
}
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/.settings/org.eclipse.jdt.core.prefs b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/.settings/org.eclipse.jdt.core.prefs
index 6f414e032..1be1d28ec 100644
--- a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/.settings/org.eclipse.jdt.core.prefs
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/.settings/org.eclipse.jdt.core.prefs
@@ -1,7 +1,7 @@
#Mon Mar 16 12:11:08 PDT 2009
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=jsr14
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/META-INF/MANIFEST.MF b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/META-INF/MANIFEST.MF
index e0ee6e8b3..8f48754d0 100644
--- a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/META-INF/MANIFEST.MF
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/META-INF/MANIFEST.MF
@@ -8,7 +8,8 @@ Bundle-Activator: org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.Activa
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.equinox.ds,
- org.eclipse.equinox.p2.ui;bundle-version="1.0.100",
+ org.eclipse.equinox.p2.operations;bundle-version="2.0.0",
+ org.eclipse.equinox.p2.ui;bundle-version="2.0.0",
org.eclipse.equinox.p2.metadata;bundle-version="1.0.0",
org.eclipse.equinox.p2.metadata.repository;bundle-version="1.0.0",
org.eclipse.equinox.p2.artifact.repository;bundle-version="1.0.0",
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/AllIUsAreVisiblePolicy.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/AllIUsAreVisiblePolicy.java
index 752421038..e722f2ddf 100644
--- a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/AllIUsAreVisiblePolicy.java
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/AllIUsAreVisiblePolicy.java
@@ -10,9 +10,8 @@
*******************************************************************************/
package org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.p2;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.ColocatedRepositoryManipulator;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.IUViewQueryContext;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.ui.Policy;
/**
* AllIUsAreVisiblePolicy redefines the IU visibility. In this
@@ -24,16 +23,11 @@ import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
public class AllIUsAreVisiblePolicy extends Policy {
public AllIUsAreVisiblePolicy() {
// XXX Use the pref-based repository manipulator
- setRepositoryManipulator(new ColocatedRepositoryManipulator(this, PreferenceConstants.PREF_PAGE_SITES));
+ setRepositoryPreferencePageId(PreferenceConstants.PREF_PAGE_SITES);
- // XXX Create an IUViewQueryContext to change the visibility of the IUs shown in the UI.
- // XXX Show the flat (non-categorized) view by default.
- IUViewQueryContext context = new IUViewQueryContext(IUViewQueryContext.AVAILABLE_VIEW_FLAT);
// XXX All available IU's should be shown, not just groups/features
- context.setVisibleAvailableIUProperty(null);
+ setVisibleAvailableIUQuery(InstallableUnitQuery.ANY);
// XXX All installed IU's should be shown, not just the user-installed.
- context.setVisibleInstalledIUProperty(null);
-
- setQueryContext(context);
+ setVisibleInstalledIUQuery(InstallableUnitQuery.ANY);
}
}
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/InstallNewSoftwareHandler.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/InstallNewSoftwareHandler.java
index 4dca71781..96e3758b9 100644
--- a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/InstallNewSoftwareHandler.java
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/InstallNewSoftwareHandler.java
@@ -1,22 +1,17 @@
/*******************************************************************************
- * Copyright (c) 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:
+ * Copyright (c) 2008, 2009 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.examples.rcp.sdkbundlevisibility.p2;
-import org.eclipse.equinox.internal.provisional.p2.ui.IProvHelpContextIds;
-import org.eclipse.equinox.internal.provisional.p2.ui.QueryableMetadataRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.InstallWizard;
-import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.ProvisioningWizardDialog;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.PlatformUI;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob;
/**
* InstallNewSoftwareHandler invokes the install wizard
@@ -32,21 +27,25 @@ public class InstallNewSoftwareHandler extends PreloadingRepositoryHandler {
super();
}
- protected void doExecute(String profileId, QueryableMetadataRepositoryManager manager) {
- InstallWizard wizard = new InstallWizard(Policy.getDefault(), profileId, null, null, manager);
- WizardDialog dialog = new ProvisioningWizardDialog(getShell(), wizard);
- dialog.create();
- PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), IProvHelpContextIds.INSTALL_WIZARD);
-
- dialog.open();
+ protected void doExecute(LoadMetadataRepositoryJob job) {
+ getProvisioningUI().openInstallWizard(getShell(), null, null, job);
}
protected boolean waitForPreload() {
- // If there is no way for the user to manipulate repositories,
- // then we may as well wait for existing repos to load so that
- // content is available. If the user can manipulate the
- // repositories, then we don't wait, because we don't know which
- // ones they want to work with.
- return Policy.getDefault().getRepositoryManipulator() == null;
+ // If the user cannot see repositories, then we may as well wait
+ // for existing repos to load so that content is available.
+ // If the user can manipulate the repositories, then we don't wait,
+ // because we don't know which ones they want to work with.
+ return !getProvisioningUI().getPolicy().getRepositoriesVisible();
+ }
+
+ protected void setLoadJobProperties(Job loadJob) {
+ super.setLoadJobProperties(loadJob);
+ // If we are doing a background load, we do not wish to authenticate, as the
+ // user is unaware that loading was needed
+ if (!waitForPreload()) {
+ loadJob.setProperty(LoadMetadataRepositoryJob.SUPPRESS_AUTHENTICATION_JOB_MARKER, Boolean.toString(true));
+ loadJob.setProperty(LoadMetadataRepositoryJob.SUPPRESS_REPOSITORY_EVENTS, Boolean.toString(true));
+ }
}
}
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/Messages.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/Messages.java
index 8713ba269..5a480f75d 100644
--- a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/Messages.java
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/Messages.java
@@ -19,7 +19,6 @@ public class Messages extends NLS {
// load message values from bundle file
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
- public static String InstallNewSoftwareHandler_LoadRepositoryJobLabel;
public static String UpdateHandler_NoSitesMessage;
public static String UpdateHandler_NoSitesTitle;
public static String ProvisioningPreferencePage_AlwaysOpenWizard;
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/PreloadingRepositoryHandler.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/PreloadingRepositoryHandler.java
index dec8d9bd7..552bc3b6c 100644
--- a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/PreloadingRepositoryHandler.java
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/PreloadingRepositoryHandler.java
@@ -12,28 +12,22 @@ package org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.p2;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.jobs.*;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry;
-import org.eclipse.equinox.internal.provisional.p2.ui.ProvUI;
-import org.eclipse.equinox.internal.provisional.p2.ui.QueryableMetadataRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob;
+import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
/**
- * PreloadingRepositoryHandler provides background loading of repositories
- * before executing the provisioning handler.
+ * PreloadingRepositoryHandler provides background loading of
+ * repositories before executing the provisioning handler.
*
* @since 3.5
*/
abstract class PreloadingRepositoryHandler extends AbstractHandler {
- Object LOAD_FAMILY = new Object();
-
/**
* The constructor.
*/
@@ -45,46 +39,26 @@ abstract class PreloadingRepositoryHandler extends AbstractHandler {
* Execute the command.
*/
public Object execute(ExecutionEvent event) {
- final String profileId = IProfileRegistry.SELF;
- BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
- public void run() {
- doExecuteAndLoad(profileId, preloadRepositories());
- }
- });
+ doExecuteAndLoad();
return null;
}
- void doExecuteAndLoad(final String profileId, boolean preloadRepositories) {
- // cancel any load that is already running
- Job.getJobManager().cancel(LOAD_FAMILY);
- final QueryableMetadataRepositoryManager queryableManager = new QueryableMetadataRepositoryManager(
- Policy.getDefault().getQueryContext(), false);
- if (preloadRepositories) {
- Job loadJob = new Job(
- Messages.InstallNewSoftwareHandler_LoadRepositoryJobLabel) {
-
- protected IStatus run(IProgressMonitor monitor) {
- queryableManager.loadAll(monitor);
- return Status.OK_STATUS;
- }
-
- public boolean belongsTo(Object family) {
- return family == LOAD_FAMILY;
- }
-
- };
+ void doExecuteAndLoad() {
+ if (preloadRepositories()) {
+ //cancel any load that is already running
+ Job.getJobManager().cancel(LoadMetadataRepositoryJob.LOAD_FAMILY);
+ final LoadMetadataRepositoryJob loadJob = new LoadMetadataRepositoryJob(getProvisioningUI());
+ setLoadJobProperties(loadJob);
if (waitForPreload()) {
loadJob.addJobChangeListener(new JobChangeAdapter() {
public void done(IJobChangeEvent event) {
if (PlatformUI.isWorkbenchRunning())
if (event.getResult().isOK()) {
- PlatformUI.getWorkbench().getDisplay()
- .asyncExec(new Runnable() {
- public void run() {
- doExecute(profileId,
- queryableManager);
- }
- });
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ doExecute(loadJob);
+ }
+ });
}
}
});
@@ -95,15 +69,14 @@ abstract class PreloadingRepositoryHandler extends AbstractHandler {
loadJob.setSystem(true);
loadJob.setUser(false);
loadJob.schedule();
- doExecute(profileId, queryableManager);
+ doExecute(null);
}
} else {
- doExecute(profileId, queryableManager);
+ doExecute(null);
}
}
- protected abstract void doExecute(String profileId,
- QueryableMetadataRepositoryManager manager);
+ protected abstract void doExecute(LoadMetadataRepositoryJob job);
protected boolean preloadRepositories() {
return true;
@@ -113,12 +86,19 @@ abstract class PreloadingRepositoryHandler extends AbstractHandler {
return true;
}
+ protected void setLoadJobProperties(Job loadJob) {
+ loadJob.setProperty(LoadMetadataRepositoryJob.ACCUMULATE_LOAD_ERRORS, Boolean.toString(true));
+ }
+
+ protected ProvisioningUI getProvisioningUI() {
+ return ProvisioningUI.getDefaultUI();
+ }
+
/**
* Return a shell appropriate for parenting dialogs of this handler.
- *
* @return a Shell
*/
protected Shell getShell() {
- return ProvUI.getDefaultParentShell();
+ return getProvisioningUI().getDefaultParentShell();
}
}
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/ProvisioningPreferencePage.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/ProvisioningPreferencePage.java
index 9a049f939..b6cd2b8c4 100644
--- a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/ProvisioningPreferencePage.java
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/ProvisioningPreferencePage.java
@@ -18,8 +18,13 @@ import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.*;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.PlatformUI;
/**
* Preference page for general provisioning preferences.
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/UpdateHandler.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/UpdateHandler.java
index 891be7e10..b9e2fcdec 100644
--- a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/UpdateHandler.java
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/UpdateHandler.java
@@ -10,22 +10,10 @@
*******************************************************************************/
package org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.p2;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.ui.ElementQueryDescriptor;
-import org.eclipse.equinox.internal.provisional.p2.ui.ProvUI;
-import org.eclipse.equinox.internal.provisional.p2.ui.QueryableMetadataRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.ui.actions.UpdateAction;
-import org.eclipse.equinox.internal.provisional.p2.ui.model.ProfileElement;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
-import org.eclipse.equinox.internal.provisional.p2.ui.policy.RepositoryManipulator;
+import org.eclipse.equinox.p2.operations.RepositoryTracker;
+import org.eclipse.equinox.p2.operations.UpdateOperation;
+import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
/**
* UpdateHandler invokes the check for updates UI
@@ -36,59 +24,28 @@ public class UpdateHandler extends PreloadingRepositoryHandler {
boolean hasNoRepos = false;
- /**
- * The constructor.
- */
- public UpdateHandler() {
- // constructor
- }
-
- protected void doExecute(String profileId, QueryableMetadataRepositoryManager manager) {
+ protected void doExecute(LoadMetadataRepositoryJob job) {
if (hasNoRepos) {
- boolean goToSites = MessageDialog.openQuestion(getShell(), Messages.UpdateHandler_NoSitesTitle, Messages.UpdateHandler_NoSitesMessage);
- if (goToSites) {
- Policy.getDefault().getRepositoryManipulator().manipulateRepositories(getShell());
+ if (getProvisioningUI().getPolicy().getRepositoriesVisible()) {
+ boolean goToSites = MessageDialog.openQuestion(getShell(), Messages.UpdateHandler_NoSitesTitle, Messages.UpdateHandler_NoSitesMessage);
+ if (goToSites) {
+ getProvisioningUI().manipulateRepositories(getShell());
+ }
}
return;
}
- // get the profile roots
- ElementQueryDescriptor queryDescriptor = Policy.getDefault().getQueryProvider().getQueryDescriptor(new ProfileElement(null, profileId));
- Collection collection = queryDescriptor.performQuery(null);
- final IInstallableUnit[] roots = new IInstallableUnit[collection.size()];
- Iterator iter = collection.iterator();
- int i = 0;
- while (iter.hasNext()) {
- roots[i] = (IInstallableUnit) ProvUI.getAdapter(iter.next(), IInstallableUnit.class);
- i++;
+ UpdateOperation operation = getProvisioningUI().getUpdateOperation(null, null);
+ // check for updates
+ operation.resolveModal(null);
+ if (getProvisioningUI().getPolicy().continueWorkingWithOperation(operation, getShell())) {
+ getProvisioningUI().openUpdateWizard(getShell(), true, operation, job);
}
- // now create an update action whose selection is all the roots
- UpdateAction action = new UpdateAction(Policy.getDefault(), new ISelectionProvider() {
-
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- // not dynamic
- }
-
- public ISelection getSelection() {
- return new StructuredSelection(roots);
- }
-
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {
- // not dynamic
- }
-
- public void setSelection(ISelection selection) {
- // not mutable
-
- }
- }, profileId, false);
- action.setRepositoryManager(manager);
- action.run();
}
protected boolean preloadRepositories() {
hasNoRepos = false;
- RepositoryManipulator repoMan = Policy.getDefault().getRepositoryManipulator();
- if (repoMan != null && repoMan.getKnownRepositories().length == 0) {
+ RepositoryTracker repoMan = getProvisioningUI().getRepositoryTracker();
+ if (repoMan.getKnownRepositories(getProvisioningUI().getSession()).length == 0) {
hasNoRepos = true;
return false;
}
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/messages.properties b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/messages.properties
index 21475c188..3da5a90c0 100644
--- a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/messages.properties
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/messages.properties
@@ -10,7 +10,6 @@
###############################################################################
-InstallNewSoftwareHandler_LoadRepositoryJobLabel=Contacting Software Sites
UpdateHandler_NoSitesMessage=There are no update sites to search. Do you wish to open the "Available Software Sites" preferences?
UpdateHandler_NoSitesTitle=No Updates Found
ProvisioningPreferencePage_AlwaysOpenWizard=&Open the wizard anyway to review or change selections

Back to the top