[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [p2-dev] WizardWithLicenses enables finish before accepting license

Title: Re: [p2-dev] WizardWithLicenses enables finish before accepting license
Here’s a patch of my proposed solution.

TIA :)

### Eclipse Workspace Patch 1.0
#P org.eclipse.equinox.p2.ui
Index: src/org/eclipse/equinox/internal/p2/ui/dialogs/WizardWithLicenses.java
RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/WizardWithLicenses.java,v
retrieving revision 1.6
diff -u -r1.6 WizardWithLicenses.java
--- src/org/eclipse/equinox/internal/p2/ui/dialogs/WizardWithLicenses.java    23 Apr 2009 21:07:25 -0000    1.6
+++ src/org/eclipse/equinox/internal/p2/ui/dialogs/WizardWithLicenses.java    14 May 2009 17:44:04 -0000
@@ -17,7 +17,9 @@
 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.jface.wizard.IWizardPage;
+import org.eclipse.swt.widgets.Display;
  * Common superclass for wizards that need to show licenses.
@@ -44,6 +46,13 @@
             if (licensePage == null) {
                 licensePage = createLicensesPage(ElementUtils.elementsToIUs(mainPage.getCheckedIUElements()), resolutionPage.getCurrentPlan());
+                Display.getDefault().asyncExec(new Runnable() {
+                    public void run() {
+                        IWizardContainer container = getContainer();
+                        if (container != null)
+                            container.updateButtons();
+                    }
+                });
             if (licensePage.hasLicensesToAccept()) {
                 return licensePage;

On 5/14/09 11:53 AM, "David Dubrow" <david.dubrow@xxxxxxxxx> wrote:

Hi Susan,

My use of p2 is very limited to IUs with only native touchpoints and it would be difficult for me to setup a test case to use the standard p2 UIs since our IUs are not recognized by them. In any case, I don’t think we’re calling the PreselectedIUInstallWizard in any way that is causing this problem. In fact, the problem seems like it’s in there lurking even if not visible in all types of WizardWithLicenses given when the license page is added (i.e., as a side effect of getNextPage()).

I was able to fix it by just adding an asyncExec calling getContainer().updateButtons() just after the license page is added. It seems that adding a wizard page that can potentially change the enablement of the finish button as a side effect of Wizard.getNextPage() which can be called during the enablement of buttons seems like a very brittle coding pattern and bound to cause problems in the long run. The reason that adding the asyncExec call to update the buttons again fixes it is that it causes the enablement to be reevaluated after the current operation during which it’s too late to get the state correct. Since the page is only added once, it is guaranteed not to cause an endless loop. It’s not the best solution but is in the same spirit as adding a page as a side effect of returning state information. ;)

On 5/14/09 9:39 AM, "ext Susan Franklin McCourt" <susan_franklin@xxxxxxxxxx> wrote:

can you reproduce the behavior in the SDK UI or in the admin agent?  If yes, then please open a bug with specific steps (ie, a site to connect to, what to install, etc.).  

Note that PreselectedIUInstallWizard is only used in the SDK as the error page of the install wizard, so it's possible that we don't have the same scenario you do in the SDK.  

The admin agent uses PreselectedIUInstallWizard when you select items in the metadata repository viewer and choose install.  Since this code is not exercised as much, it's possible that there's something missing in PreselectedIUInstallWizard.

If you can't reproduce in either the SDK or agent, then you could still open a bug including a code snippet that shows how you are launching the wizard...



To: <p2-dev@xxxxxxxxxxx>
Subject: [p2-dev] WizardWithLicenses enables finish before accepting license

I couldn’t find an existing bugzilla addressing this but wanted to check here first.

I am currently calling PreselectedIUInstallWizard and I don’t know whether this is an issue with the other wizards as well but it may be. In any case, the problem is that due to the ordering of calls between when the license page is added by WizardWithLicenses.getNextPage() and when canFInish() is called causes the finish button to be enabled prior to the user accepting licenses even though a license is provided by selected IUs. Of course, this allows users to install Ius without accepting the license. If next is pressed rather than finish, then the finish button is correctly disabled until the user accepts the license.

If you want me to log this bugzilla, please let me know.


--David Dubrow

p2-dev mailing list