POJO Wizard

The "type" componente can be used to select some Java class or interface.

This is very useful to generate some Business class, DAO, HTML form, or other stuff using the selected POJO.

The following image shows the Output file (left) and the Wizard (right):

In the above example, I selected this POJO using the "browse" button:


public class Pessoa {
	private int id;
	private String nome;
	private String email;
	private double salario;
	private boolean casado;
	private Date data;
//get and sets here...

How to create this Wizard

You just have to create two files: pojo.xml (wizard configuration file), pojo.vm (Velocity template)

Create the pojo.xml file:


<?xml version="1.0" encoding="UTF-8"?>
<EclipseWork>
    <wizard>
        <title>POJO EclipseWork</title>

		<!-- First Page -->
        <component-page >
        	<description>Some description here</description>

		<!-- the type can be package or folder -->
		<container name="folder" label="Folder Output: " type="folder" />
		<textfield name="name" label="Name: " />

		<type name="pojo" label="Choose some Class: " />

	 </component-page>

	<!-- Templates -->
        <output>
        	<template component="name" velocity="pojo.vm" extension="txt" container="folder" />
	</output>
    </wizard>
</EclipseWork>

The pojo.vm Template just prints the POJO name and all its attributes:


$pojo
$pojo.name
$pojo.fullyName
-----------------------
#foreach($f in $pojo.fields)
	$f.name $f.type 
#end
-----------------------
#foreach($f in $pojo.methods)
	$f.name $f.return $f.parametersNames $f.parametersTypes $f.parameters $f.exceptions
#end
-----------------------
There are more properties that you can use, 
but this is just a helloworld.



Note that you can easily create some HTML form with that, or other stuff.

You can also use it to create complete CRUD applications.



Running the Wizard

To run the wizard just right click in the pojo.xml file, and select "EclipseWork -> OpenWizard".