Geertjan's Blog

  • August 8, 2005

New File Type Template in NetBeans IDE Dev

Geertjan Wielenga
Product Manager
If you want to manipulate files that aren't recognized in NetBeans IDE, you need to create a file object. When you read Tim Boudreau's POV-Ray Tutorial, you'll find out all about this. Also, in Where's the Cursor in the NetBeans IDE Source Editor?, where I created tokens for Manifest files, the assumption is that you already have a file object for Manifest files. (For the difference between files and file objects, go here.) Anyway, if you use the latest daily dev builds (i.e., post-4.1 dev build), you need do no coding yourself in order to have the IDE recognize a new file object.

A case in point: the helpset file (with an .hs extension), which is one of the files required by a JavaHelp-based helpset, isn't recognized by default by the IDE, so is treated as a text file. However, I want it to be treated differently to text files, so I need to create a file object for this. I want it to have its own actions (right-click contextual menu), its own syntax highlighting, its own code completion, etc. In effect, I want it to be a first-class citizen. An easy way to see whether a file object is a first-class citizen is to see whether it has its own icon. For example, take a look at my helpset file here, with its own special little icon:

Now, here's the thing about the illustration above: I didn't do any coding at all. I used this cool new template in the New File wizard (click to enlarge):

And what exactly did that template do for me? Well, you saw the result above, but now take a look behind the scenes. These are the files that are generated straight out of the box (everything starting with "hs" below comes from the New File Type wizard, the icon was selected in the New File Type wizard, and the layer.xml is also magically updated):

Now that your file type is recognized by the IDE so painlessly, you can focus your work on what you want the file object to do for you -- instead of wasting time at the start thinking about what you should do for the IDE to recognize your file type. And that's the way it should be.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.