Download size: 0.05 MB
Last Update: 2008-03-30
What's new in this version
FreeMarker templating language used.
Verifications for NetBeans versions
Plugin is not subject to any verification
New sample, in the New Project wizard's Samples > NetBeans Modules category. It is called "Extended Java Project":
Finish the wizard and you will have this module. The two highlighted classes below constitute the new "Specify Words" panel that you will see later, the highlighted file with the FTL extension is the FreeMarker template that will be used to generate the WordLibrary.java file based on the entries in the "Specify Words" panel.
This is the relevant part of the WordLibrary template, showing FreeMarker iterator tags that will be replaced by the words that are set in the "Specify Words" panel:
Install the above module. Then go to the New Project wizard. In the Java category, you will find "Extended Anagram Application":
That's a Java application with the extra "Specify Words" panel'. Choose that wizard and click Next. You will see the standard first panel, for specifying the application's name and location.
But there's more! Click Next again and you will see your new panel, which you can fill in, as shown below:
When you complete the wizard, you'll have the Anagram Game sample:
But... the WordLibrary.java file will have the words you specified in the "Specify Words" panel:
In summary, the Extended Java Project sample illustrates that you can change the wizard that creates a Java application.
How to do this yourself:
- Create a Java application that contains the files that you want the user to have when they complete the wizard that you will create for them.
- Remove the files that the user should be able to influence from the wizard. Don't worry if removing one of these files causes error marks and compilation problems.
- Create a new module project.
- Use the Project Template wizard to put the Java application from step 1 above into the module as a template.
- When you complete the wizard above, you will have several files, including a wizard class and its visual JPanel class. Make a copy of each of the latter two. Change the iterator to create them. See the Extended Java Project's iterator if you need help here.
- Create a new empty file with a unique extension such as ".template" or ".javax". Copy the content of the class(es) that you want the user to influence via the wizard and paste the content into the file (as many files as you want to have templates for). Replace the parts of the file that should be changed by the wizard with FreeMarker tags, as shown above. Register the file as a FreeMarker file in the layer.xml file.
- How to use the second panel to let the user create additional files for their project? Look in the sources of the "Select Words" visual panel, the wizard panel, and the iterator. Especially look at insertSpecifiedWords() in the iterator.