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 57698 - "NewFile" wizard requires two clicks of next button to go to next panel
Summary: "NewFile" wizard requires two clicks of next button to go to next panel
Status: RESOLVED WORKSFORME
Alias: None
Product: platform
Classification: Unclassified
Component: Dialogs&Wizards (show other bugs)
Version: 4.x
Hardware: All All
: P3 blocker (vote)
Assignee: Stanislav Aubrecht
URL:
Keywords: UI
Depends on:
Blocks:
 
Reported: 2005-04-09 12:20 UTC by santhosh
Modified: 2013-04-23 09:45 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
nbm file to reproduce this bug (14.80 KB, application/octet-stream)
2005-04-09 12:21 UTC, santhosh
Details
source code of the module used to reproduce the bug (4.03 KB, application/octet-stream)
2005-04-09 12:25 UTC, santhosh
Details
possible workaround (3.46 KB, application/octet-stream)
2005-04-15 12:46 UTC, Jiri Rechtacek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description santhosh 2005-04-09 12:20:18 UTC
In New File Wizard,
   if the second panel is a ValidatingPanel and throws ValidationException 
   in the beginning then wizard dialog requires two clicks of nextButton
   to switch to 3rdPanel
Comment 1 santhosh 2005-04-09 12:21:07 UTC
Created attachment 21511 [details]
nbm file to reproduce this bug
Comment 2 santhosh 2005-04-09 12:23:23 UTC
I have attached a module using which you can reproduce the bug.

o install the module in Netbeans IDE 4.0 Beta1
o open any j2se project. 
o open new file wizard.
o in Other category,
   you will find "bug.xml"
   select it and press "next";
o now comes panel named "step1"
  it requires some value to be entered in textfield
  enter some text in textfield and press Next;
  wizard doesn't go to switch nextstep ----> bug
  press Next again, now it goes to nextstep;
  
analysis: step1 panel of "bugs.xml" is a validating panel
          which throws validation exception if value in textfiled is empy.
          
now the work around is:
o open new file wizard.
o in Other category,
   you will find "workarounForBug.xml"
   select it and press "next";
o now comes panel named "step1"
  here the textfield is filled by some value by default.
  now press Next. wizard goes to nextstep;

Analysis: workaround is to ensue that step1 doesn't throw validation exception
          in the beginning by filling values in initialize method of 
          InstantiatingIterator
                    
thus, the final conclusion is:

In New File Wizard,
   if the second panel is a ValidatingPanel and throws ValidationException 
   in the beginning then wizard dialog requires two clicks of nextButton
   to switch to 3rdPanel
                    
Comment 3 santhosh 2005-04-09 12:25:21 UTC
Created attachment 21512 [details]
source code of the module used to reproduce the bug
Comment 4 santhosh 2005-04-09 12:29:47 UTC
sorry mistyped the netbeans version in 3rd comment.

use netbeans 4.1 beta1 (mistyped as 4.0 beta1 in 3rd comment)

can I hope that fix will be available in netbeans 4.1.
Comment 5 Jesse Glick 2005-04-11 20:46:49 UTC
Jirka can you investigate?

BTW it is probably too late for a fix in 4.1, but TBD - depends on actual
severity of bug, availability of workarounds, complexity of fix.
Comment 6 Jiri Rechtacek 2005-04-12 15:29:54 UTC
Santhosh, it looks as faulty usage of validate() method in
WizardDescriptor.ValidatingPanel. The validate() methos has been designed as
offline panel validation invoked only when Next/Finish button click. For
'online' validation use the method isValid() which is called on every panel
state change. This method also control state of Next/Finish buttons.
The validate() can be useful for time consuming check i.e. for possibility to an
new object deploy or something like this. Check WizardDescriptor javadoc.
If you use isValid() for check of name of new object then it should avoid
useless two clicks to go to next panel. For example NewJavaFileWizardIterator
works after this manner. Hope it helps to you achieve it.
Comment 7 santhosh 2005-04-12 18:36:29 UTC
i know the usage of ValidatingPanel....
to reproduce the issue, i made the code simple.
BTW, wizard has nothing to do with whether a Panel does time consuming job or
not. it should work whatever be the implementation of validate() method is.

let me clearly tell you where the bug is:

when you press [next] button the validate() method 
of current panel is supposed to be called. but here what happening is
  "when you press [next] button next panel's validate() method
   is being called" ---> bug.

o put a System.out.println("validate called") in Step.validate() method
o lauch the wizard. it shows "Choose FileType" panel.
o press next. you will see "validate called" on console.
  this is clearly bug.

to be more clear, the NewFileWizard's iterator returns 
wrong panel in current() method.
Comment 8 Jiri Rechtacek 2005-04-14 20:08:16 UTC
Probably really bug in wizard framework, wrong method invoking. Workaround
exists, will be delivered.
Comment 9 Jiri Rechtacek 2005-04-15 12:46:48 UTC
Created attachment 21671 [details]
possible workaround
Comment 10 Jiri Rechtacek 2005-04-15 12:57:43 UTC
I attached an workaround which makes your example working w/o wasted clicks.
What I did:
- validate() should pass on init values (validate() must get over first wrong
invocation! it's the matter of this bug)
- so, move name checking from validate() to isValid()
- added a support Change Listeners, don't forget that wizard framework registers
own change listener in each panel which helps to update state of
Back/Next/Finish buttons
- added document listener of the text field which fires the state changes on
every document change.
Hope it helps you to achieve your goal.
Thanks for feedback. The defact should be fixed in NB4.2.
Comment 11 santhosh 2005-04-15 20:02:41 UTC
this is best workaround.
 org.netbeans.modules.xml.core.wizard.XMLWizardIterator already uses
 this workaround. 

better to create a class named "WorkAroundIterator" so that it can be used
at many places ....

I really appreciate if current wizard framework is 
replaced by https://wizard.dev.java.net (lot cleaner API)
Comment 12 Jiri Rechtacek 2005-11-04 09:57:28 UTC
> better to create a class named "WorkAroundIterator" so that it can be used
> at many places ....
> 
> I really appreciate if current wizard framework is 
> replaced by https://wizard.dev.java.net (lot cleaner API)

Yes, new Wizard API is needed, it's in consideration for next release.
Comment 13 Stanislav Aubrecht 2013-04-23 09:45:31 UTC
Cannot reproduce in 

Product Version: NetBeans IDE 7.3 (Build 201302132200)
Java: 1.7.0_15; Java HotSpot(TM) 64-Bit Server VM 23.7-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_15-b03
System: Windows 7 version 6.1 running on amd64; Cp1250; en (nb)


If the issue is still valid please provide new steps to reproduce and reopen, thanks.