NetBeans IDE 8.1 Plugin: Entity Expander

A very handy plugin, in my humble opinion since I created it myself, is the Entity Expander. (Earlier blog entries are available on this, e.g., here.) 

Take a look at this plugin if you're doing POJO-based development, i.e., plain old Java objects are the starting point of something larger, via some kind of framework or other technology. Right-click on any Java class and apply a template to it:

For example, if you have a POJO named "Person", with two String fields, named "name" and "city", and then choose "Vaadin Form" above, all of the below will be generated:

package personmanager1;

import com.vaadin.ui.Component;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.TextField;
import org.vaadin.maddon.fields.MTextField;
import org.vaadin.maddon.form.AbstractForm;
import org.vaadin.maddon.layouts.MVerticalLayout;

public class PersonForm extends AbstractForm {
    
    private TextField name = new MTextField("name");
    private TextField city = new MTextField("city");
    
    @Override
    protected Component createContent() {
        return new MVerticalLayout(
                new FormLayout(
                        name,
                        city
                ),
                getToolbar()
        );
    }
    
}

Either use an existing template or one that you create yourself. (Feel free to add more templates to the sources on GitHub.) You'll see placeholders are available so that you can create your own extender template. If you click Create above, you'll need to specify a name, and then you'll get a template in the editor like this, which you can tune:

package ${package};

import javax.swing.JFrame;

public class ${object}Frame extends JFrame {
    
  <#list fieldsAndModifiers as field>
     ${field};
  </#list>

    public ${object}Frame() {
    }
    
}

Also, when you go to Tools | Templates, you're able to edit the templates defined by the plugin, as well as those you create yourself:

The plugin is ready to be used in NetBeans IDE 8.1:

http://plugins.netbeans.org/plugin/53874/entityexpander

Its sources are available on GitHub, you are welcome to fork and extend however you like:

https://github.com/GeertjanWielenga/EntityExpander

It has been approved by the NetBeans verification community and can therefore be installed via the Plugin Manager, which you can get to via Tools | Plugins:


Indeed, the display name and description could be a lot better, will work on that for the next release of the plugin. 

Your feedback is more than welcome! 

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search


Archives
« February 2017
SunMonTueWedThuFriSat
   
1
2
3
4
5
6
7
9
10
11
12
13
15
17
18
19
20
21
22
23
24
25
26
27
28
    
       
Today