I have a wizard panel which "implements WizardDescriptor.AsynchronousValidatingPanel<WizardDescriptor>" and as a result I have two validation methods:
Javadoc should clarify relationship of these two methods. I for example assumed that isValid() can do quick panel checks and validate() should be used for time consuming check which needs to run on background. Based on that I would also expect that if isValid returns false then validate would never be called. But that's not the case.
Btw. it would be nice to have an ability to show a progress bar when async check is running and autotically disable whole panel.
I can also see following strange behaviour: if my valid() throws WizardValidationException then isValid seems to be called immediatelly after that. Why? In my scenario this results into error message being hidden because isValid passes. If I decide to fix this by storing error from validate() then another question raises: when should my wizard panel start paying attention to isValid results instead of validate()??
Yes, I can confirm that AsynchronousValidatingPanel is nearly impossible to use.
Please, could you look at it? So clients do not need to do horrible work arounds... Thanks a lot in advance.
Integrated into 'main-golden', will be available in build *201209190001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
User: Tomas Mysik <email@example.com>
Log: #217759 cont'd - failed download should prevent wizard's Next/Finish button
AsynchronousValidatingPanel issues work arounded - see #202796.
Here are my suggestions/complains:
(1) if one throws WizardValidationException from the validate() method, do not call isValid() method (so clients do not need to have any property whether an error in a background validation occured or not)
(2) add method finishValidation() (or similar) that would be called in the UI thread after background validation finishes - here one could "unfreeze" the panel (it would be similar as method prepareValidation() and it completes the workflow); now, every client must "unfreeze" his panel in the validate() method using EventQueue.invokeLater()
(3) If one clicks the Back button, it seems to me that the background thread is not interrupted (but it should be, it is the same case as for the Cancel button). Moreover, the error message should not be displayed I guess.
I fixed the problem with disappearing error messages. So now there's no need to hack isValid() method. It is still being called right after background validation but the actual and correct error message will be set later on.
I will create a new enhancement issue to introduce some sort of "finishValidation()" method.
Thanks a lot Stando! This is perfect!
I somehow changed the TM? Sorry.