diff options
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/WizardWithLicenses.java')
-rw-r--r-- | bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/WizardWithLicenses.java | 85 |
1 files changed, 35 insertions, 50 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/WizardWithLicenses.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/WizardWithLicenses.java index 221786295..a8b7e0646 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/WizardWithLicenses.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/WizardWithLicenses.java @@ -12,15 +12,10 @@ package org.eclipse.equinox.internal.p2.ui.dialogs; import org.eclipse.equinox.internal.p2.ui.model.ElementUtils; -import org.eclipse.equinox.internal.provisional.p2.director.ProvisioningPlan; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; -import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.AcceptLicensesWizardPage; -import org.eclipse.equinox.internal.provisional.p2.ui.model.IUElementListRoot; -import org.eclipse.equinox.internal.provisional.p2.ui.operations.PlannerResolutionOperation; -import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy; -import org.eclipse.jface.wizard.IWizardContainer; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.operations.ProfileChangeOperation; +import org.eclipse.equinox.p2.ui.*; import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.swt.widgets.Display; /** * Common superclass for wizards that need to show licenses. @@ -30,62 +25,52 @@ public abstract class WizardWithLicenses extends ProvisioningOperationWizard { AcceptLicensesWizardPage licensePage; - public WizardWithLicenses(Policy policy, String profileId, IUElementListRoot root, Object[] initialSelections, PlannerResolutionOperation initialResolution) { - super(policy, profileId, root, initialSelections, initialResolution); + /* + * (non-Javadoc) + * @see org.eclipse.jface.wizard.Wizard#addPages() + */ + public void addPages() { + super.addPages(); + licensePage = createLicensesPage(); + addPage(licensePage); } - protected AcceptLicensesWizardPage createLicensesPage(IInstallableUnit[] ius, ProvisioningPlan plan) { - return new AcceptLicensesWizardPage(policy, ius, plan); + public WizardWithLicenses(ProvisioningUI ui, ProfileChangeOperation operation, Object[] initialSelections, LoadMetadataRepositoryJob job) { + super(ui, operation, initialSelections, job); } - public void addPages() { - super.addPages(); + protected AcceptLicensesWizardPage createLicensesPage() { + IInstallableUnit[] ius = new IInstallableUnit[0]; + if (planSelections != null) + ius = ElementUtils.elementsToIUs(planSelections); + return new AcceptLicensesWizardPage(ui.getLicenseManager(), ius, operation); } + /* + * Overridden to determine whether the license page should be shown. + * (non-Javadoc) + * @see org.eclipse.equinox.internal.p2.ui.dialogs.ProvisioningOperationWizard#getNextPage(org.eclipse.jface.wizard.IWizardPage) + */ public IWizardPage getNextPage(IWizardPage page) { - if (page == resolutionPage) { - if (licensePage == null) { - licensePage = createLicensesPage(ElementUtils.elementsToIUs(mainPage.getCheckedIUElements()), resolutionPage.getCurrentPlan()); - addPage(licensePage); - Display.getDefault().asyncExec(new Runnable() { - public void run() { - IWizardContainer container = getContainer(); - if (container != null) - container.updateButtons(); - } - }); - - } - if (licensePage.hasLicensesToAccept()) { - return licensePage; - } - return null; - } else if (page == licensePage) { - // we are done. We explicitly code this because it's possible - // that the license page is added to the wizard before a dynamic page that - // gets added afterward, but should appear before. + // If the license page is supposed to be the next page, + // ensure there are actually licenses that need acceptance. + IWizardPage proposedPage = super.getNextPage(page); + if (proposedPage != licensePage) + return proposedPage; + if (!licensePage.hasLicensesToAccept()) return null; - } - return super.getNextPage(page); + return licensePage; } protected void planChanged() { super.planChanged(); - if (resolutionOperation == null) - return; - if (licensePage == null) { - licensePage = createLicensesPage(ElementUtils.elementsToIUs(mainPage.getCheckedIUElements()), resolutionOperation.getProvisioningPlan()); - addPage(licensePage); - } else - licensePage.update(ElementUtils.elementsToIUs(mainPage.getCheckedIUElements()), resolutionOperation.getProvisioningPlan()); - // Status of license page could change status of wizard next button - // If no current page has been set yet (ie, we are still being created) - // then the updateButtons() method will NPE. This check is needed in - // order to run the automated test cases. - if (getContainer().getCurrentPage() != null) - getContainer().updateButtons(); + licensePage.update(ElementUtils.elementsToIUs(planSelections), operation); } + /* + * (non-Javadoc) + * @see org.eclipse.equinox.internal.p2.ui.dialogs.ProvisioningOperationWizard#performFinish() + */ public boolean performFinish() { licensePage.performFinish(); return super.performFinish(); |