Here is the starting point (this applies to Eclipse 3.4 and later, when the P2 repository was introduced, earlier versions save their configuration in different ways. IIRC you can see all the plugins and functions in platform.xml).
Create a new plug-in project (New-> Other-> Plug-in Development-> Plug-in Project) with the "Hello World" template, then drop this code into the SampleAction launch method.
Launch the plugin as an Eclipse test application and select Sample Menu-> Sample Action, plugins that do not belong to any function will be displayed on the console of the parent workspace. When I ran this, it was pretty much more than I expected, I had a few looks and I can not detect a logical error.
Change, find a logical error, used the wrong index of the array used in the innermost loop. However, not quite right.
Change 2. (Moment of Facepalm). Found a problem. Be sure to run the target workspace with all workspaces and enable the target plugins, or this will distort your results. If you install the plugin and dress it up a bit, you will not have this problem.
//get all the plugins that belong to features IBundleGroupProvider[] providers = Platform.getBundleGroupProviders(); Map<Long, IBundleGroup> bundlesMap = new HashMap<Long, IBundleGroup>(); if (providers != null) { for (int i = 0; i < providers.length; i++) { IBundleGroup[] bundleGroups = providers[i].getBundleGroups(); System.out.println("Bundle groups:"); for (int j = 0; j < bundleGroups.length; j++) { Bundle[] bundles = bundleGroups[j] == null ? new Bundle[0] : bundleGroups[j] .getBundles(); System.out.println(bundleGroups[j].getIdentifier()); for (int k = 0; k < bundles.length; k++) { bundlesMap.put(bundles[k].getBundleId(), bundleGroups[j]); } } } } BundleContext bundleContext = Activator.getDefault().getBundle().getBundleContext(); if(bundleContext instanceof BundleContextImpl) { Bundle[] bundles = ((BundleContextImpl)bundleContext).getBundles(); System.out.println("Orphan Bundles:"); for (int i = 0; i < bundles.length; i++) { if(!bundlesMap.containsKey(bundles[i].getBundleId())) { System.out.println(bundles[i].getSymbolicName()); } } }
Rich seller
source share