I'm building an Eclipse Feature that has a requirement that amounts to this... The Feature must be able to be uninstalled automatically if the user has his license revoked.
If you want more background information about that, Here is another question that I've asked on this topic.
Thanks to the answers on that question, I've been trying to learn the Eclipse p2 director api. I've found some classes that look useful here
I've been trying to instantiate one of these classes in my code, but with no luck yet. I've been reading the help documentation, and I'm getting kind of lost in it all.
I'm stuck because I have a need to supply the OperationFactory with a collection of IInstallableUnit objects.
private void scheduleUninstallOperationJob(
Collection<? extends IVersionedId> toUninstall)
{
OperationFactory oFactory = new OperationFactory();
Collection<URI> repos = null;
UninstallOperation op = null;
try {
op = oFactory.createUninstallOperation(toUninstall, repos, null);
} catch (ProvisionException e) {
e.printStackTrace();
}
IStatus result = op.resolveModal(null);
if (result.isOK()) {
op.getProvisioningJob(null).schedule();
}
}
I don't see any way to easily ask the running instance of Eclipse to give me the collection of currently installed InstallableUnits so that I can easily pass the one I want to uninstall to the OperationFactory.createUninstallOperation() method.
I've tried using Eclipse source code as an example, but the code that I have found is the org.eclipse.equinox.p2.ui.ProvisioningUI, and it's tightly coupled to the UI that is used when manually uninstalling InstallableUnits. This code also uses code that is in the dreaded Eclipse internal packages which I would like to avoid using if possible.
Thank you for your consideration, Trace