This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 58530

Summary: Background wizard validation
Product: platform Reporter: _ pkuzel <pkuzel>
Component: Dialogs&WizardsAssignee: Jiri Rechtacek <jrechtacek>
Status: RESOLVED FIXED    
Severity: blocker CC: jrechtacek
Priority: P3 Keywords: API, API_REVIEW_FAST, THREAD
Version: 5.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:
Bug Depends on: 33467    
Bug Blocks: 54150    
Attachments: Proposed WizardDesriptor API change
a test which covers handling of new interface

Description _ pkuzel 2005-05-03 14:48:21 UTC
Wizard framework contains basic support for lazy validation - ValidatingPanel.
Unfortunately it's called synchronously from AWT.

I need to do heavy validation that takes several seconds (network connection).
This means that it can not block AWT. My code idea is:

  public validate() throws WizardValidationException() {
      if (heavyDone) return;
      new Thread(this).start();
      throw new ValidationException("", )
  }

  public void run() {
     <heavy validation>
     fireValid();  // enables next button
     heavydone = true;
     wizardDescriptor.doNextClick();
     heavydone = false;
  }

However I miss public wizardDescriptor.doNextClick() method.


Another option is to introduce 

  /** 
   * Marker interface, actual validation is done in non AWT thread. 
   * Cancel button signals background validation by thread.interrupt()
   * and closes wizard.
   */
  public static interface AsynchronousValidation extends ValidatingPanel {
      
  }
Comment 1 _ pkuzel 2005-05-03 14:52:50 UTC
I prefer the second style.
Comment 2 _ pkuzel 2005-05-09 13:49:13 UTC
I'll sketch impl and Jirka'll provide test.
Comment 3 _ pkuzel 2005-05-09 14:48:14 UTC
Created attachment 22043 [details]
Proposed WizardDesriptor API change
Comment 4 _ pkuzel 2005-05-09 14:53:34 UTC
Proposed contact and it's prototype implementation attached. It suits CVS use case. 

Jirka could you review, polish, provide unit tests and integrate into trunk, please?
Comment 5 _ pkuzel 2005-05-09 14:55:18 UTC
FYI, doClick() appoach has not worked reliably in CVS use case.
Comment 6 Jiri Rechtacek 2005-05-11 13:17:06 UTC
Created attachment 22092 [details]
a test which covers handling of new interface
Comment 7 Jiri Rechtacek 2005-05-11 13:33:20 UTC
Petr, the prototype looks fine. I propose only minor changes:
- remove the parameter 'origin' in lazyValidation, it's unused in that method
- correct spelling perfomar -> performer
- don't invokeLater WD.setValid(true), can be fired directly I think

Don't forget describe API change in apichanges.xml. Thanks
Comment 8 _ pkuzel 2005-05-11 13:48:46 UTC
OK i'll improve before integration.

BTW I miss test for background validation interruption. Something like

validate() throws ... {
   try {
      forever.wait();
   } (InterruptedEx e) {
      passed = true;
   }
}
Comment 9 _ pkuzel 2005-05-11 13:50:32 UTC
Interuption test is crucial as it avoids regression possibly caused by
leveraging issue #33467.
Comment 10 _ pkuzel 2005-05-16 14:19:47 UTC
Implementation was integrated:

Checking in apichanges.xml;
/cvs/openide/dialogs/apichanges.xml,v  <--  apichanges.xml
new revision: 1.2; previous revision: 1.1
done
Checking in src/org/openide/WizardDescriptor.java;
/cvs/openide/dialogs/src/org/openide/WizardDescriptor.java,v  <-- 
WizardDescriptor.java
new revision: 1.3; previous revision: 1.2
done

Jirka could you integrate tests and close the issue, please?


Comment 11 Jiri Rechtacek 2005-05-17 15:33:21 UTC
Added covered test AsynchronousValidatingPanelTest and fixed WizardDescriptor to
make all wizard tests passing.


Checking in dialogs/src/org/openide/WizardDescriptor.java;
/cvs/openide/dialogs/src/org/openide/WizardDescriptor.java,v  <-- 
WizardDescriptor.java
new revision: 1.5; previous revision: 1.4
done
RCS file:
/cvs/openide/test/unit/src/org/openide/AsynchronousValidatingPanelTest.java,v
done
Checking in test/unit/src/org/openide/AsynchronousValidatingPanelTest.java;
/cvs/openide/test/unit/src/org/openide/AsynchronousValidatingPanelTest.java,v 
<--  AsynchronousValidatingPanelTest.java
initial revision: 1.1
done