Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Equinox/p2/Adding Self-Update to an RCP Application
This page consolidates information about how to add p2 self-updating support to your RCP application.
Contents
Adding p2 to your application
Until we can document this better on this page, see http://toedter.com/blog/?p=27 for a comprehensive example.
Configuring the p2 UI
There are several different levels of integration with the p2 UI, depending on what kind of support you want to surface to your users.
Reusing the Eclipse SDK UI in its entirety
If your goal is to use the same UI used in the SDK inside your RCP app, you'll want to include the following bundles in your application:
- org.eclipse.equinox.p2.ui
- org.eclipse.equinox.p2.ui.sdk
- org.eclipse.equinox.p2.ui.sdk.scheduler
Reusing the Eclipse SDK UI without automatic updating
If you want the user to be able to install new software and manually update the application, you'll want to include only these ui bundles:
- org.eclipse.equinox.p2.ui
- org.eclipse.equinox.p2.ui.sdk
Modifying the UI contributions
If you want to include the install/update/uninstall capabilities, but you don't these items to appear in the Help menu of your application, you can change the UI contributions. This will allow you to do things such as permit updating without installing new software, permitting install without update, or simply rearrange the way users encounter the install/update functionality.
You'll need the p2 UI class library bundle.
- org.eclipse.equinox.p2.ui
If you want the user to be able to use automatic updating, using the same UI used in the SDK (pref page, popup, etc.), then you can include this bundle:
- org.eclipse.equinox.p2.ui.sdk.scheduler
Now, you need to replace 'org.eclipse.equinox.p2.ui.sdk' with a bundle of your own that contributes whatever functionality is needed. Use the sdk bundle as a model. Things you need to think about:
- Your bundle will need to configure a default instance of org.eclipse.equinox.p2.ui.policy.Policy. This can be done by simply setting the policy as appropriate for your application, or by exposing some of the policy decisions to the user in a preference page. See ProvSDKUIActivator.initializePolicy() for an example of how this is done.
- If you are exposing user preferences, and you are including the SDK's automatic update support (and pref page), then you might want the automatic update preferences to appear underneath your RCP update preferences. If so, then you'll want to use the same preference page ID as used by org.eclipse.equinox.p2.ui.sdk so that automatic update pref page contribution falls underneath it.
- The IHandler classes in 'org.eclipse.equinox.p2.ui.sdk' invoke the update and install function. If you are simply rearranging the menus in your application, you can copy these handler classes and command contributions to your new bundle and simply revise the menu contributions as you wish. Or you can invoke the UI in a completely different way.
- The 'org.eclipse.ui.installationPages' contribution currently shows the installed content and provides buttons for update, uninstall, and revert. Consider replacing or modifying the contribution if some of the actions are not relevant.
Restricting Repository Support
The p2 UI Policy class can be configured with a 'RepositoryManipulator' that restricts access to repositories, or none at all. If the Policy has a null manipulator, then the user will be unable to add and remove repositories or otherwise manage sites. (Note this is not implemented yet, although the API is in place.)
Helpful Links
- http://toedter.com/blog/?p=27 Kai Toedter's blog post about adding p2 support to an RCP app