Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » [resolved] Using Equinox P2 - Getting information about installed features and plugins
[resolved] Using Equinox P2 - Getting information about installed features and plugins [message #716107] Tue, 16 August 2011 09:20 Go to next message
Jose Renato is currently offline Jose Renato
Messages: 11
Registered: February 2011
Junior Member
I'm using Eclipse 3.7 to develop a project and I need to do some things, using the information of installed plugins and features:

I'm using the P2 provisioning feature to allow software updates.

1: I need to get the list of plugins and features that are installed and currently running. I need something like what is displayed on the "Installed Software", which can be viewed through "Help> About> Installation Details".

Note: I will use this information to obtain data about features installed, such as version number and description.

2: I need to get a list of recent installed softwares. I need something like what is displayed on the "Installation History", which can be viewed through "Help> About> Installation Details".

Note: I will use this information to add functionality to clear older installations. Something like "Keep only the last five installations."

[Updated on: Thu, 18 August 2011 08:16]

Report message to a moderator

Re: Using Equinox P2 - Getting information about installed features and plugins [message #716152 is a reply to message #716107] Tue, 16 August 2011 11:11 Go to previous messageGo to next message
Martin Skorsky is currently offline Martin Skorsky
Messages: 112
Registered: July 2009
Senior Member
I would use code like this:
for (IBundleGroupProvider provider : Platform.getBundleGroupProviders()) {
for (IBundleGroup feature : provider.getBundleGroups()) {
final String providerName = feature.getProviderName();
final String featureId = feature.getIdentifier();
for (Bundle bundle : feature.getBundles()) {

HTH

Re: Using Equinox P2 - Getting information about installed features and plugins [message #716454 is a reply to message #716152] Wed, 17 August 2011 09:02 Go to previous message
Jose Renato is currently offline Jose Renato
Messages: 11
Registered: February 2011
Junior Member
Hi Martin,

thanks for the answer.

I tried to do that, but it did not returned what I needed.

I have the following features and plugins structure:

feature.1
- feature.1.1
-- plugin.1.1.1
-- plugin.1.1.2
- feature.1.2
-- plugin.1.2.1

So, what I wanted to do is to get the version of the feature.1, but, with the code above, only the features feature.1.1 and feature.1.2 were returned.

Then, with this code, I got what I needed:

import org.eclipse.core.runtime.Platform;
import org.eclipse.equinox.p2.engine.IProfileRegistry;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.operations.ProvisioningSession;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.ui.ProvisioningUI;

...


try {
	ProvisioningUI provisioningUI = ProvisioningUI.getDefaultUI();

	if ( null == provisioningUI ) {
		return;
	}

	String profileId = provisioningUI.getProfileId();

	ProvisioningSession provisioningSession = provisioningUI.getSession();

	if ( null == provisioningSession ) {
		return;
	}

	IQueryable<IInstallableUnit> queryable = ((IProfileRegistry) provisioningSession.getProvisioningAgent().getService(IProfileRegistry.SERVICE_NAME))
			.getProfile( profileId );


	if ( null == queryable ) {
		return;
	}

	// to get the product ID
	//String pId = Platform.getProduct().getId();
	
	String pId = "feature.1";

	if ( null != queryable ) {
		IQueryResult<IInstallableUnit> iqr = queryable.query( QueryUtil.createIUQuery( pId ), null );

		if ( null != iqr ) {
			Iterator<IInstallableUnit> ius = iqr.iterator();
			if( ius.hasNext() ) {
				IInstallableUnit iu = ius.next();
				Version v = iu.getVersion();

				if ( null != v ) {
					System.out.println( "ID: " + iu.getId() + " | IU: " + iu.toString() + " | Version: " + v.toString() );
				}
			}
		}
	}
} catch ( Exception e ) {
	System.out.println( e.getStackTrace() );
	return;
}
Previous Topic:Developing a content Assist plugin
Next Topic:Using Equinox P2 - Cleanup feature
Goto Forum:
  


Current Time: Tue Jul 22 11:31:45 EDT 2014

Powered by FUDForum. Page generated in 0.02900 seconds