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 143719

Summary: Enhance WizardAction to be easily cancelable from the execute() method
Product: installer Reporter: dlipin <dlipin>
Component: NBIAssignee: Libor Fischmeistr <lfischmeistr>
Status: NEW ---    
Severity: blocker    
Priority: P3    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:
Bug Depends on:    
Bug Blocks: 242141    

Description dlipin 2008-08-13 08:55:49 UTC
This issue raised upon the discussion with Jeff Lin during work on OpenESB Installer.

The task was to get back to the previous panel from the execute() method in the action.
The trivial thing - getWizard().previous() didn`t work since the execute() method continue to happen and invoked 
getWizard().next() in WizardAction.executeForward() method.

The other thing - "getWizard().previous(); return;" doesn`t work either since canceled flag was not set and .next() is 
executed again.

The third possible thing "getWizard().previous(); cancel(); return;" does not work for another reason - cancel() method 
hangs - it is waiting for the "finished" flag to be set to true.
So the option here is to execute cancel() method in a separate thread but it sounds like a hacking.
First variant:
final WizardAction action = this;
new NbiThread() {
           @Override
           public void run() {
               action.cancel();
               action.getWizard().previous();
           }
       }.start();
return;
(this one likely leads to race conditions, maybe fixed by having Thread.sleep(50) before return;)

Another variant:
getWizard().previous();
final WizardAction action = this;
new NbiThread() {
           @Override
           public void run() {
               action.cancel();                        }
       }.start();
return;
(likely RC as well)

Third one:
final WizardAction action = this;
new NbiThread() {
           @Override
           public void run() {
               action.cancel();                        }
       }.start();
getWizard().previous();
return;



The best variant was to dup the WizardAction class to WizardActionMod which is the almost the same but with different 
cancel() method:
public void cancel() {
       canceled = true;
}
With such a action, the following things result in the go back in the wizard sequence:
getWizard().previous();
cancel();
return; 


The current WizardAction should be enhanced to be capable of such functionality and without duplicating the code.
Comment 1 Jiri Rechtacek 2012-10-07 12:58:47 UTC
Assigned to new owner.