Saturday 24 September 2011

Maven-ise your Eclipse (Indigo)

With the transition of the Maven2Eclipse plugin project from the Sonatype boys to the Eclipse umbrella, support for running Maven from within Eclipse has become smoother and definitely easier. To get started, install the Maven2Eclipse plugin from within Eclipse using the Help->Install new software menu option. The link to the plugin download is http://download.eclipse.org/technology/m2e/releases but verify the same from the  plugin site.
After successfully installing Maven, you will have access to several Maven project wizards that will help you get started with a Maven project with a few clicks as shown in the example below as I did for Eclipse Indigo.

  • Select a New project and choose Maven project. Click through the next few steps. You will get an option to choose the Maven archetype and specify the GroupId, Artifact Id, Version and Package






















  • After you select the required options, the wizard will generate a project file structure and populate it with some skeleton code including a Junit test.











  • That's it. You have created a Maven based project which is now awaiting functionality. Adding new dependencies, plugins to the project and the POM is made easy using the Maven project menu, available by right clicking on the project folder and selecting the required option.























  • A Maven Build can be set-up and initiated from the Run- As menu option. 













  • Selecting the Maven build option for the first time which will bring up a set-up configuration dialog that will enable you to specify the goals, profiles and set up any required parameters.

















  • Once the Run configuration is ready, you can build your Maven project and deploy your snapshot.

Friday 16 September 2011

Generating Entity Relationship diagrams from a database schema

Consider the situation where you have been given a database schema to work with but there is no E-R diagram documentation available and you need to re-design the database schema. The first step would be to try and understand the existing schema by generating an Entity-Relationship (ER) diagram from the existing database schema.To get an E-R diagram where none is provided, use SchemaSpy.

SchemaSpy produces a rich set of diagrams and tables which gives the users and developers a detailed description of the schema tables, constraints, anomalies ( to investigate what might be wrong with the schema) and most importantly, it displays the relationships between the entities as an E-R diagram. The following steps should help you get started with SchemaSpy. 
  • The tool is Java based open source software tool that it has been developed using Java, runs on Windows as well as UNIX and requires the Java Runtime Environment (JRE) so install the JRE if you don't have it,
  • For generating Graphical views of the schema, the tool is dependent upon the Graphviz library, so download and install it before installing Schema Spy. You'll have to make sure that your Windows PATH Enviroment variable points to the bin directory of the Graphviz install. If it doesn't, you can still run SchemaSpy but you'll need to specify an additional parameter along with the start up parameters of SchemaSpy.
  • Download the jdbc driver for the database SchemaSpy will connect to. For example, for PostGresql, you can download the jdbc driver from this page. For MySql, you'll find the driver here and for Oracle, here.
  • Download and install SchemaSpy. Have a read of the start up instructions and see which parameters are mandatory and which are optional.  Open a DOS command prompt and run SchemaSpy using the following command : 
  • java -jar schemaSpy_5.0.0.jar -dp    -t databaseType  -host -db -s  -u  -p   -o
  • You may also need the -gv pathToGraphviz parameter 
Depending upon the size of the database schema, SchemaSpy will take a few minutes to generate the ER diagram which can be viewed by clicking on the index.htm in the 


Saturday 10 September 2011

Designing Model Driven Architectures using the Eclipse Modelling Framework

The Eclipse Modelling Framework (EMF) is another useful tool within the Eclipse suite that offers an open source framework for the designing model driven applications. In terms of technology, EMF unifies Java, XML and UML. Given a 'model' described in either of the three technologies i.e Java, UML or XML schema, it is possible to generate the other two. To get an idea of what type of applications can be designed using the EMF, check out this list

The major advantage of using EMF is that it connects a model to its Java based implementation and this simplifies the process of designing and implementing a model. EMF generates Java code separating interfaces from their implementation. In addition, it also generates Factory classes for managing objects. EMF also supports standard CRUD operations, specification of cardinality constraints and the enforcement of referential integrity. Database persistence is available via Teneo.

Designing models in EMF is done using the Eclipse Java Development Tools.Third party options such as Topcase's Ecore editor and Ormondo's EclipseUML editors can also get the job done.
While the Ecore model can realised from Java (using Annotations) , XML Schema orUML, persisting the serializable version requires another form : XML Metadata Interchange (XMI).

Lars Vogel's tutorial is a good starting point for learning and implementing an EMF based application. While the learning curve for EMF is not very steep, debugging problems in the generated code can be a little painful. To get started with the development of EMF based applications, download the Eclipse Modelling Tools IDE and create a new EMF project using File -> New -> Project

Saturday 3 September 2011

Designing Swing / SWT GUIs using WindowsBuilder in Eclipse Indigo

The latest release of Eclipse code named Indigo includes the WindowsBuilder project as an open source project within the Eclipse umbrella of projects. WindowsBuilder which is a significant GUI designing tool in its own right provides a WYSIWYG editor for desgining Swing and SWT interfaces from within Eclipse.

WindowsBuilder comes bundled with the standard download 'Eclipse IDE for Java Developers' but if you choose to download another version of Eclipse and you need to manually add the plugin, , goto Help->Install New Software -> and in the 'worh with' box enter the site : site http://dl.google.com/eclipse/inst/d2wbpro/latest/3.7  and then follow the usual steps for adding the plugin. After successfully installing it, you will be able to view the plug-in in the 'Installation History' and the'Plugins' tab of Eclipse Installation Details.


Now that you have WindowsBuilder installed, creating Swing / SWT based GUIs is just a matter of clicking through a few wizards. To create a screen using the wizard, create a Java project and then select New-> Other->WindowsBuilder and open up the wizard.

Other->WindowsBuilder and open up the wizard. Select the required option. In this case, I selected 'ApplicationWindow' and the wizard generates the ApplicationWindow for me as shown in the screenshot.
At the bottom of the editor view, there will be two options, 'Source' and 'Design'. Click on the Design option. This will open the design page and load up the pallet and give you the WYSIWYG option.You can now see your 'frame' object on the right hand side and the pallet with different Swing and SWT controls that you can use. I added a JPanel and set its layout to 'JGoodiesFormLayout' and then added a couple of labels, textboxes and a 'Send' button.
Add the required controls you need. You can also select any of the controls and add any EventHandlers that you might need by right clicking on the controls.


The wizard will create skeleton code for you which you can customize as required. Once you are done, just run the application.




Finally, if you want a different 'Look and Feel', especially a 'Native Platform' look, the WindowsBuilder has an option in the top menu, that allows you to change the Look and Feel as shown in the screenshot below.


Thus, within a few minutes, you can design a fully functional Java application with a few bells and whistles. This is very useful, if you need a prototype and some sample screenshots to show the user. Instead of wasting time,drawing the screens in a prototyping tool, create the same using the WindowsBuilder plugin and when the client gives you the green light, come back to your prototype, clean up the code and add the required functionality. Finally, there are a couple of good tutorials on YouTube that describe using WindowsBuilder with Eclipse.