Netbeans Platform: Incorrect Numbering in project wizard
===

I am starting with Netbeans development. I want to create a new project type. So, I created a module for that by the name `CZSaw Project` and then created a wizard from the **New > Wizard** context menu on the module (several files were generated).

To add this project and wizard as part of the `New Project` dialog, I added the following XML Layer file.


    <!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
    <filesystem>
        <folder name="Templates">
            <folder name="Project">
                <folder name="CZSaw Project">
                    <attr name="displayName" bundlevalue="czsaw.project.ui.wizards.Bundle#Templates/Project/CZSaw Project"/>
                    <attr name="iconBase" stringvalue="czaw/project/resources/yED_16.png"/>
                    <file name="CZSaw Project">
                        <attr name="displayName" bundlevalue="czsaw.project.ui.wizards.Bundle#Templates/Project/CZSaw Project/CZSaw Project"/>
                        <attr name="iconBase" stringvalue="czaw/project/resources/yED_16.png"/>
                        <attr name="position" intvalue="100"/>
                        <attr name="template" boolvalue="true"/>
                        <attr name="instantiatingIterator" newvalue="czsaw.project.ui.wizard.NewCZSawProjectWizardIterator"/>
                        <attr name="instantiatingWizardURL" urlvalue="nbresloc:/czsaw/project/resources/NewCZSawProject.html"/>
                    </file>
                </folder>
            </folder>
        </folder>
    </filesystem>

This resulted in the new "New Project" menu:

![enter image description here][1]

However, when I click next, I get incorrect numbering and labeling in the steps menu of the wizard, I get the following

![enter image description here][2]

I was expecting the steps menu to be

 1. Choose Project
 2. **Step#1**

Instead, I got "Choose Label" repeated. with the coherence between the VisualPanel and the steps. In case, the following is the auto-generated code for the Wizard iterator

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package czsaw.project.ui.wizard;

    import java.awt.Component;
    import java.io.IOException;
    import java.util.*;
    import javax.swing.JComponent;
    import javax.swing.event.ChangeListener;
    import org.openide.WizardDescriptor;
    
    // TODO define position attribute
    
    public final class NewCZSawProjectWizardIterator implements WizardDescriptor.InstantiatingIterator<WizardDescriptor> {
    
        private int index;
    
        private WizardDescriptor wizard;
        private List<WizardDescriptor.Panel<WizardDescriptor>> panels;
    
        private List<WizardDescriptor.Panel<WizardDescriptor>> getPanels() {
            if (panels == null) {
                panels = new ArrayList<WizardDescriptor.Panel<WizardDescriptor>>();
                panels.add(new NewCZSawProjectWizardPanel1());
                String[] steps = createSteps();
                for (int i = 0; i < panels.size(); i++) {
                    Component c = panels.get(i).getComponent();
                    if (steps[i] == null) {
                        // Default step name to component name of panel. Mainly
                        // useful for getting the name of the target chooser to
                        // appear in the list of steps.
                        steps[i] = c.getName();
                    }
                    if (c instanceof JComponent) { // assume Swing components
                        JComponent jc = (JComponent) c;
                        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
                        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
                        jc.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, true);
                        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, true);
                        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, true);
                    }
                }
            }
            return panels;
        }
    
        @Override public Set<?> instantiate() throws IOException {
            // TODO return set of FileObject (or DataObject) you have created
            return Collections.emptySet();
        }
    
        @Override public void initialize(WizardDescriptor wizard) {
            this.wizard = wizard;
        }
    
        @Override public void uninitialize(WizardDescriptor wizard) {
            panels = null;
        }
    
        @Override public WizardDescriptor.Panel<WizardDescriptor> current() {
            return getPanels().get(index);
        }
    
        @Override public String name() {
            return index + 1 + ". from " + getPanels().size();
        }
    
        @Override public boolean hasNext() {
            return index < getPanels().size() - 1;
        }
    
        @Override public boolean hasPrevious() {
            return index > 0;
        }
    
        @Override public void nextPanel() {
            if (!hasNext()) {
                throw new NoSuchElementException();
            }
            index++;
        }
    
        @Override public void previousPanel() {
            if (!hasPrevious()) {
                throw new NoSuchElementException();
            }
            index--;
        }
    
        // If nothing unusual changes in the middle of the wizard, simply:
        @Override public void addChangeListener(ChangeListener l) {}
        @Override public void removeChangeListener(ChangeListener l) {}
        private String[] createSteps() {
            String[] beforeSteps = (String[]) wizard.getProperty("WizardPanel_contentData");
            assert beforeSteps != null : "This wizard may only be used embedded in the template wizard";
            String[] res = new String[(beforeSteps.length - 1) + panels.size()];
            for (int i = 0; i < res.length; i++) {
                if (i < (beforeSteps.length - 1)) {
                    res[i] = beforeSteps[i];
                } else {
                    res[i] = panels.get(i - beforeSteps.length + 1).getComponent().getName();
                }
            }
            return res;
        }
    
    }

  [1]: http://i.stack.imgur.com/Hr2Tr.png
  [2]: http://i.stack.imgur.com/0cx4l.png
