diff options
author | Hamdan Msheik | 2013-01-16 20:47:16 +0000 |
---|---|---|
committer | Pascal Rapicault | 2013-01-22 14:44:37 +0000 |
commit | b3f8ef311e27dc903d146ad6b89661a5fbcdaee8 (patch) | |
tree | 848a55bdf885d98869c2fa48a969d488b47bcf62 | |
parent | 33ca260a9e8a71cbbeda3bb311903e5c15d94332 (diff) | |
download | rt.equinox.p2-b3f8ef311e27dc903d146ad6b89661a5fbcdaee8.tar.gz rt.equinox.p2-b3f8ef311e27dc903d146ad6b89661a5fbcdaee8.tar.xz rt.equinox.p2-b3f8ef311e27dc903d146ad6b89661a5fbcdaee8.zip |
Bypass install license wizard page via plugin_customizationv20130122-144437
3 files changed, 125 insertions, 19 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWizardTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWizardTest.java index 2722523ee..936705c4c 100644 --- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWizardTest.java +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/InstallWizardTest.java @@ -1,12 +1,13 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 IBM Corporation and others. + * Copyright (c) 2008, 2013 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 + * Ericsson AB (Hamdan Msheik) - Bypass install license wizard page via plugin_customization *******************************************************************************/ package org.eclipse.equinox.p2.tests.ui.dialogs; @@ -21,6 +22,7 @@ import org.eclipse.equinox.internal.p2.ui.viewers.DeferredQueryContentProvider; import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription; import org.eclipse.equinox.p2.operations.*; +import org.eclipse.equinox.p2.ui.AcceptLicensesWizardPage; import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.wizard.IWizardPage; @@ -127,6 +129,66 @@ public class InstallWizardTest extends WizardTest { } } + public void testInstallWizardWithoutLicenceBypass() throws Exception { + ArrayList<IInstallableUnit> iusInvolved = new ArrayList<IInstallableUnit>(); + iusInvolved.add(toInstall); + InstallOperation op = new MyNewInstallOperation(getSession(), iusInvolved); + op.setProfileId(TESTPROFILE); + PreselectedIUInstallWizard wizard = new PreselectedIUInstallWizard(getProvisioningUI(), op, iusInvolved, null); + wizard.setBypassLicencePage(false); + ProvisioningWizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard); + dialog.setBlockOnOpen(false); + dialog.open(); + ProfileModificationJob longOp = null; + + try { + SelectableIUsPage selectableIUsPage = (SelectableIUsPage) wizard.getPage(SELECTION_PAGE); + // should already have a plan + assertTrue("1.0", selectableIUsPage.isPageComplete()); + // simulate the next button by getting next page and showing + InstallWizardPage installWizardPage = (InstallWizardPage) selectableIUsPage.getNextPage(); + + assertFalse("Licence page bypass flag must be false", wizard.isBypassLicencePage()); + IWizardPage licensePage = installWizardPage.getNextPage(); + assertTrue("Expected instance of AcceptLicensesWizardPage", licensePage instanceof AcceptLicensesWizardPage); + + } finally { + dialog.getShell().close(); + if (longOp != null) + longOp.cancel(); + } + } + + public void testInstallWizardWithLicenceBypass() throws Exception { + ArrayList<IInstallableUnit> iusInvolved = new ArrayList<IInstallableUnit>(); + iusInvolved.add(toInstall); + InstallOperation op = new MyNewInstallOperation(getSession(), iusInvolved); + op.setProfileId(TESTPROFILE); + PreselectedIUInstallWizard wizard = new PreselectedIUInstallWizard(getProvisioningUI(), op, iusInvolved, null); + wizard.setBypassLicencePage(true); + ProvisioningWizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard); + dialog.setBlockOnOpen(false); + dialog.open(); + ProfileModificationJob longOp = null; + + try { + SelectableIUsPage selectableIUsPage = (SelectableIUsPage) wizard.getPage(SELECTION_PAGE); + // should already have a plan + assertTrue("1.0", selectableIUsPage.isPageComplete()); + // simulate the next button by getting next page and showing + InstallWizardPage installWizardPage = (InstallWizardPage) selectableIUsPage.getNextPage(); + + assertTrue("Licence page bypass flag must be true", wizard.isBypassLicencePage()); + IWizardPage licensePage = installWizardPage.getNextPage(); + assertNull("Expected instance of AcceptLicensesWizardPage must be null", licensePage); + + } finally { + dialog.getShell().close(); + if (longOp != null) + longOp.cancel(); + } + } + private static class MyNewInstallOperation extends InstallOperation { public MyNewInstallOperation(ProvisioningSession session, Collection<IInstallableUnit> toInstall) { super(session, toInstall); diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/UpdateSingleIUWizard.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/UpdateSingleIUWizard.java index dd4dd2eea..0f57d7384 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/UpdateSingleIUWizard.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/UpdateSingleIUWizard.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 IBM Corporation and others. + * Copyright (c) 2013 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Ericsson AB (Hamdan Msheik) - Bypass install license wizard page via plugin_customization *******************************************************************************/ package org.eclipse.equinox.internal.p2.ui.dialogs; @@ -20,7 +21,7 @@ import org.eclipse.jface.wizard.Wizard; /** * An update wizard that is invoked when there is only one thing to update, only * one update to choose, and the resolution is known to be successful. - * + * * @since 3.6 */ public class UpdateSingleIUWizard extends Wizard { @@ -53,10 +54,13 @@ public class UpdateSingleIUWizard extends Wizard { public void addPages() { mainPage = createMainPage(); addPage(mainPage); - AcceptLicensesWizardPage page = createLicensesPage(); - page.update(null, operation); - if (page.hasLicensesToAccept()) - addPage(page); + + if (!WizardWithLicenses.canBypassLicencePage()) { + AcceptLicensesWizardPage page = createLicensesPage(); + page.update(null, operation); + if (page.hasLicensesToAccept()) + addPage(page); + } } protected AcceptLicensesWizardPage createLicensesPage() { 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 f8d42d98e..6b2c09960 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 @@ -1,17 +1,21 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 IBM Corporation and others. + * Copyright (c) 2008, 2013 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 * David Dubrow <david.dubrow@nokia.com> - Bug 276356 [ui] check the wizard and page completion logic for AcceptLicensesWizardPage * Sonatype, Inc. - ongoing development + * Ericsson AB (Hamdan Msheik) - Bypass install license wizard page via plugin_customization *******************************************************************************/ package org.eclipse.equinox.internal.p2.ui.dialogs; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.preferences.*; +import org.eclipse.equinox.internal.p2.ui.ProvUIActivator; import org.eclipse.equinox.internal.p2.ui.model.ElementUtils; import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.operations.ProfileChangeOperation; @@ -24,20 +28,36 @@ import org.eclipse.jface.wizard.IWizardPage; */ public abstract class WizardWithLicenses extends ProvisioningOperationWizard { + public static final String BYPASS_LICENSE_PAGE = "bypassLicensePage"; //$NON-NLS-<n>$ + AcceptLicensesWizardPage licensePage; + boolean bypassLicencePage; /* * (non-Javadoc) * @see org.eclipse.jface.wizard.Wizard#addPages() */ + + public boolean isBypassLicencePage() { + return bypassLicencePage; + } + + public void setBypassLicencePage(boolean bypassLicencePage) { + this.bypassLicencePage = bypassLicencePage; + } + public void addPages() { super.addPages(); - licensePage = createLicensesPage(); - addPage(licensePage); + + if (!bypassLicencePage) { + licensePage = createLicensesPage(); + addPage(licensePage); + } } public WizardWithLicenses(ProvisioningUI ui, ProfileChangeOperation operation, Object[] initialSelections, LoadMetadataRepositoryJob job) { super(ui, operation, initialSelections, job); + this.bypassLicencePage = canBypassLicencePage(); } protected AcceptLicensesWizardPage createLicensesPage() { @@ -56,16 +76,25 @@ public abstract class WizardWithLicenses extends ProvisioningOperationWizard { // 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 licensePage; + + if (!bypassLicencePage) { + if (proposedPage == licensePage && licensePage != null) { + if (!licensePage.hasLicensesToAccept()) { + proposedPage = null; + } else { + proposedPage = licensePage; + } + } + } + + return proposedPage; } protected void planChanged() { super.planChanged(); - licensePage.update(ElementUtils.elementsToIUs(planSelections).toArray(new IInstallableUnit[0]), operation); + if (!bypassLicencePage) { + licensePage.update(ElementUtils.elementsToIUs(planSelections).toArray(new IInstallableUnit[0]), operation); + } } /* @@ -73,7 +102,18 @@ public abstract class WizardWithLicenses extends ProvisioningOperationWizard { * @see org.eclipse.equinox.internal.p2.ui.dialogs.ProvisioningOperationWizard#performFinish() */ public boolean performFinish() { - licensePage.performFinish(); + + if (!bypassLicencePage) { + licensePage.performFinish(); + } + return super.performFinish(); } + + public static boolean canBypassLicencePage() { + IScopeContext[] contexts = new IScopeContext[] {InstanceScope.INSTANCE, DefaultScope.INSTANCE, BundleDefaultsScope.INSTANCE, ConfigurationScope.INSTANCE}; + boolean bypass = Platform.getPreferencesService().getBoolean(ProvUIActivator.PLUGIN_ID, BYPASS_LICENSE_PAGE, false, contexts); + return bypass; + } + } |