X

Geertjan's Blog

  • March 15, 2006

Adding Additional Frameworks to NetBeans IDE

Geertjan Wielenga
Product Manager
In NetBeans IDE 5.0 (yes, that's right, I said 5.0, and I don't mean a post 5.0 development build), when you go to my update center (there's a link to it in the left sidebar of this blog), you will find two new plug-in modules:

When you install these two plug-in modules, you will need to restart the IDE. Then, you will see a new library in the Library Manager:

Next, when you go to the NetBeans Plug-in Modules sample category, you'll see a new sample:

When you select the sample, and click Next, you'll get this in the Projects window:

This is everything you need for creating a plug-in module that sets up your own framework support (i.e., everything that I blogged about yesterday) in NetBeans IDE. What the project sample does is it creates a new entry in the "Frameworks" panel for Web Applications in the New Project wizard. It lets you type in a few values and then creates files that are useful at the starting stage of working with the Wicket framework. It also changes the web.xml file and the index.jsp file. So, Claudio, for example, you could use this project sample as the basis of your WebWork plug-in module. From this project sample you can learn (1) how to create your own new files programatically, (2) how to write to existing files programatically, (3) how to let the names of files and the content of files be dependent on values provided by the user in the New Project wizard. Here's a little bit of information on the most important files that you see in the illustration above:

  • WicketConfigurationPanelVisual.java. Provides the lower panel in the Frameworks panel. This is where the user specifies values such as the name of the package for storing the files and the URL pattern used by the web.xml deployment descriptor.
  • WicketFrameworkProvider.java. This is the magical class that does all the work creating files and writing to existing files. It extends the NetBeans API class WebFrameworkProvider and is based on StrutsFrameworkProvider.java (which you can get from the NetBeans sources). Note that the inner method changeProjectProp doesn't work yet, but changeIndexJSP works perfectly. It writes a message in the defailt index.jsp, to tell the user that this file is NOT used in Wicket. Have a look at the inner class CreateWicketConfig if you want to know how to write to the web.xml file. In the resources folder, you see the templates that are used as the basis for the files created by the plug-in module. There are a few strings in there that are replaced by this class, using the values specified by the user. Also note that the layer.xml file registers these templates (apparently there's a better way of registering them than I have done in this plug-in module, but I don't know the better way yet). The isInWebModule method is used by the Project Properties dialog box, to check whether the application supports Wicket or not (which is determined by whether or not the Wicket servlet is registered in web.xml, as discussed in a few blog entries in this blog some months ago).
  • WicketConfigurationPanel.java. A class that works with the configuration panel, for listening, storing, retrieving, and so on.
  • WicketConfigUtilities.java. Utility class containing two methods, for getting information from the web.xml file.

I cannot promise that the code is perfect. Actually, I can promise that it is imperfect because error handling is not covered. For example, the code assumes that there is a library called "Wicket" in the Library Manager (that's why you had to install both plug-in modules, because one of them is for providing the JARs that make up the Wicket library). If the Wicket library isn't in the Library Manager, then when you click Finish in the Frameworks panel for Wicket, the plug-in module fails silently. No files are created and you aren't told about it or why. So, this is one example of an area of the plug-in module that is incomplete. There are also various other imperfections, but the general idea of how to add your own framework is pretty clear and well isolated in this plug-in module.

Join the discussion

Comments ( 1 )
  • Geertjan Wednesday, March 15, 2006
    PS: Looking at the screenshot, I don't think all those libraries are needed, like for example the CVS one.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.