blob: c2347c3a4fb4208d9eefbbb0ec347a933d5a6e68 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.dialogs;
import org.eclipse.equinox.internal.p2.ui.model.ElementUtils;
import org.eclipse.equinox.internal.p2.ui.model.IUElementListRoot;
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.operations.PlannerResolutionOperation;
import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
import org.eclipse.jface.wizard.IWizardPage;
/**
* Common superclass for wizards that need to show licenses.
* @since 3.5
*/
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);
}
protected AcceptLicensesWizardPage createLicensesPage(IInstallableUnit[] ius, ProvisioningPlan plan) {
return new AcceptLicensesWizardPage(policy, ius, plan);
}
public void addPages() {
super.addPages();
}
public IWizardPage getNextPage(IWizardPage page) {
if (page == resolutionPage) {
if (licensePage == null) {
licensePage = createLicensesPage(ElementUtils.elementsToIUs(mainPage.getCheckedIUElements()), resolutionPage.getCurrentPlan());
addPage(licensePage);
}
if (licensePage.hasLicensesToAccept()) {
return licensePage;
}
}
return super.getNextPage(page);
}
protected void planChanged() {
if (licensePage == null) {
licensePage = createLicensesPage(ElementUtils.elementsToIUs(mainPage.getCheckedIUElements()), resolutionPage.getCurrentPlan());
addPage(licensePage);
} else
licensePage.update(ElementUtils.elementsToIUs(mainPage.getCheckedIUElements()), resolutionPage.getCurrentPlan());
// 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();
}
public boolean performFinish() {
licensePage.performFinish();
return super.performFinish();
}
}