Community
Participate
Working Groups
There is a big push to get rid of usage of internal classes. In the PDE we use three internal classes to get access to the API classes. The three classes are: >>> PDECore.getDefault().getModelManager().getFragments() We use the model manager to get all of the fragment models. Actually we are looking only for the fragments for a specific plugin, but I don't see an API for that. We're interested in all of the fragments, whether they are projects with code, projects with binary, or referenced through the target platform. From the fragment model we can see if it is a project or not (using getUnderlyingResource) and get the imports and libraries of the fragment. >>> PDECore.getDefault().getWorkspaceModelManager().getWorkspacePluginModel(IProject) We use the workspace modelmanager to ask for the plugin model for a project. From that we can get its IPlugin and from that we can get its IPluginImports. >>> PDECore.getDefault().findPlugin(id, version, match); We use this to find the plugin model. We use the API for the other requests. The problem is there is no API to get down to the actual API. Thanks, Rich
There are a lot of methods on PluginModelManager and PDECore that would be useful to those who care about plugins. We need to revisit these two classes and come up with a good set of APIs. Unfortunately, it's too late for this work in the 3.1 cycle.
Especially on these classes as they may very well change based on bundles etc.
absolutely. I will clean up the internal implementation to be as close to 100% state-based as possible for 3.1, and kick back during the summer months and come up with APIs.
resolving to later.
reopening. Please consider for 3.4.
The request for the 3 functions below can actually already be satisfied by the PluginRegistry API class. There might not be a specific function in our API, but I will explain how to satisfy each. >>> PDECore.getDefault().getModelManager().getFragments() "Actually we are looking only for the fragments for a specific plugin, but I don't see an API for that." There is a better way that interating through fragments :) IPluginModelBase base = PluginRegistry.findModel(String id); BundleDescription desc = base.getBundleDescription() BundleDescription[] frags = desc.getFragments(); ArrayList fragmentModels = new ArrayList(frags.length); for (int i = 0; i < frags.length; i++) { IPluginModelBase fragment = PluginRegistry.findModel(frags[i]); if (fragment != null) fragmentModels.add(fragmentModels); } // Now all the fragments for your specific plug-in are in the ArrayList 'fragmentModels' >>> PDECore.getDefault().getWorkspaceModelManager().getWorkspacePluginModel(IProject) Use PluginRegistry.findModel(IProject) >>> PDECore.getDefault().findPlugin(id, version, match); This one you are going to have to work for a little bit. Let's say you have a String id and a String version. ModelEntry entry = PluginRegistry.findEntry(id); IPluginModelBase[] models = entry.getWorkspaceModels(); for (int i = 0; i < models.length(); i++) { if (isMatch(models[i], version, match)) return models[i]; } IPluginModelBase[] models = entry.getExternalModels(); for (int i = 0; i < models.length(); i++) { if (isMatch(models[i], version, match)) return models[i]; } This algorithm is a little more thorough than you may need. You can try calling ModelEntry.getActiveModels() also. The way listed above will search not only the active but inactive models also. Also, you will have to write the isMatch(...) function yourself. But this should not be very hard, esp. if you are looking for a perfect match. If you have any questions about any of the functions, please let me know. Otherwise, I think you should be good to go.
Also, there's PackageAdmin which may supply you with another way of getting at OSGi related things: http://www2.osgi.org/javadoc/r4/org/osgi/service/packageadmin/PackageAdmin.html
Chris and Brian can this be closed then?
Sounds sufficient to me. Marking as fixed in 3.3 since that is when we added the PluginRegistry API.