Add Property module on NetBeans Plugin Portal

I have uploaded the Add Property module to the NetBeans Plugin Portal. It installs the action Source:Add Property. Invoking the action shows the following dialog.

Add Property Dialog


You can configure the property settings. The preview window shows what code will be inserted in Java editor. Select OK to insert the code at current caret position.


You can customize the template by editing it using the Tools:Templates action.

Template Manager Dialog

The template uses the freemarker template engine.



  • validation of name and type
  • validation of duplicate property name
  • browse to select type
  • nicer positioning of the field, getters and setters
  • insertion of required import statements instead of using FQNs


DISCLAIMER: This module is experimental. So no guarantees. Use the module at your own risk.


Very nice, it took me 3 years of Java programming before realizing there was this bound (pseudo) property thing in place. This plugin would've made me aware of that earlier.

Posted by Casper on November 04, 2007 at 07:55 PM PST #

If little features like this were included standard with nb's, then you would surely see more eclipse converts! I have been a long time fan of you plugins, keep up the great work.

Posted by Adam on November 04, 2007 at 10:14 PM PST #

Hi sandip,
I hope you are woking for something to solve issue! Maybe you can work together with someone else to fix this regression! :)

BTW, I found a problem on your first image. The PROP_AGE value, IMHO, should be "AGE" instead "PROP_AGE".

Thanks and great work.

Posted by Michel Graciano on November 04, 2007 at 10:28 PM PST #

Thanks for all the comments.


I agree. Sometime the other priorities take the better of a release :(

I am continuously lobbying for programmer productivity additions to NetBeans. In fact I would like to see it be one of the core design principles of NetBeans. You will observe that incorporated in all my modules.


The issue 90907 addresses the full issue of Bean related functionality. This module is only a stopgap to provide the most used function of the original Beans module. I am hoping that Beans module or it's equivalent is brought back to the fullest extent in next release.

Posted by guest on November 04, 2007 at 11:24 PM PST #

Would'n it make sense to make the setter parameter final?
Thus "public void setAge(final int newage)".
I think this would make the setter a bit more robust.

Moreover for non-modifiable property types the getter, and setter are okay.
But for modifiable property types like Collections, and bean classes the generated getter and setters are a bit naive. Are there any plans to support more advanced property types.

Anyway great plugin

Posted by guest on November 05, 2007 at 05:43 AM PST #

Thanks for your comments. I am OK with making arg final in case you want to use it inside some innner class. But final does not mean it is read-only (or const of c/c++).

I am open to suggestions. Send me your suggestion. Moreover like I have shown in the screen shot you can change the template yourself using the Tools:Templates action, selecting the template and then clicking on Open in editor, making changes and saving it.

Posted by Sandip on November 05, 2007 at 06:51 AM PST #

When I tried to install this plugin in to NB 6.0 Beta 2 (Build 200710212201) I got the messade:
Missing required modules for Plugin Add Property:
module org.openide.util > 7.10

Posted by Dmitry on November 05, 2007 at 04:49 PM PST #

Hi Dmitry,

I developed the module last weekend. The automated mechanism picked up the latest version of the org.openide.util module when I added the dependency to it. I don't think I need that. Some older version should work. I will adjust the dependency and then upload my module soon.

Thanks for pointing it out.

Posted by Sandip on November 05, 2007 at 10:20 PM PST #

I have uploaded the version (1.5) of Add Property module to the plugin center that should work with 6.0 Beta2.

Posted by Sandip on November 05, 2007 at 10:50 PM PST #

It would be great if you could add another text field on the dialog for a javadoc comment. The template currently generates boilerplate that does not add any value to the code. But with one additional (optional) text field you could capture the meaning of the property and use that in the javadoc in place of (or in addition to) the variable name.

Posted by Steve on December 05, 2007 at 12:52 AM PST #


Did you know that you can customize the template as described in the blog entry? You have to go to the Templates manager in Tools menu, select the template , select Open in Editor, make changes and save it. It is true that that does not allow per property customization. But then how many text areas would you like to see? One for each method that is generated? For example for an indexed property 2 getters and 2 setters are generated. Can you please give an exact example of what you want that can be achieved using a single text field as you suggest and I will look into it.

Thanks for your interest in this module.

Posted by Sandip on December 05, 2007 at 05:53 AM PST #

I am not too sure if I can talk about explore from here plugin for netbeans here.

Would it be possible to have an option to visit the classes directory from a node?

that would be very useful as I would have some resources there which need some attention.

Posted by SURENDRANATH REDDY B on February 14, 2008 at 04:14 PM PST #

FYI everyone this is in Netbeans 6.1 - press Alt+Insert .. and select "add Property"

Posted by AJ on September 13, 2008 at 02:06 PM PDT #

I'm looking for the new location to put a custom AddProperty.freemarker template. It's no longer in nor in org.netbeans.modules.beans.

Where did it go?

The default template is nowhere to be found in the Template manager neither.

Posted by Jan Vansteenkiste on February 08, 2009 at 10:01 PM PST #

Post a Comment:
Comments are closed for this entry.



« July 2016