Welcome topic
[Previous] [Main] [Next]

JGuiGen - GUI Generation Code

This web site documents the GPL JGuiGen program. This document also contains a sample application with many Swing features described and annotated with code. Swing Demo

The ReadMe.HTML file can also be accessed from this web site. This contains most of the information about setting up JGuiGen for different backend SQL tables. The README.HTML file also contains sections on how JGuiGen handles Internationalization (I18N), notes on issues with differnt backend
database, how JGuiGen runs from Eclipse or the command line, etc. This is an extensive file and is designed as a supplementary manual - View Readme file

The Specification document for the JGuiGen Replication System is available here. This document
give an extensive overview of the Replication System that is being built into JGuiGen. This is a
general purpose data replication system and could be used by sites that don't otherwise use JGuiGen.
- JGuiGen Replication

Another interesting document is a partial list of tasks that Swing desktop application needs to be
able to handle. This document also references how JGuiGen deals with these tasks - Swing Task List

JGuiGen is written in Java and is designed to help generate GUI front-ends to access tables in a SQL database. JGuiGen can currently generate an application that accesses PostgreSQL, MySql, HSQL, SQL-SERVER, Oracle or MS Access tables. With minor changes it can be modified to access tables in other SQL backends as long as they have a JDBC driver.

There are several Open Source projects available that generate Java Code. This one differs in a couple of ways. First, it is database driven. There is an XML file used to contain setup information, but the vast majority of the descriptive information used by the generator is contained in a database table. Second, this applciation does not try to create a finished product. It is designed to assist a developer with the grunt work of hand writing code that is essentially duplicated over and over for each column in a table you want to edit. It does not try to take into account all of the unqiue situations that programs need to handle. Last, but not least, JGuiGen tries to create code that I18N, A11y, documented, and tested with JUnit.

The JGuiGen Project has seven major objectives.

I. GENERATE CRUD APPLICATIONS - Second, JGuiGen uses the data_dict information to create a JPanel class for each table in your database with the standard edit/add/delete/search/view functions. These classes are designed to be merged into a larger project. JGuiGen is NOT a WYSIWYG GUI generator. The modern acronum is CRUD (Create, Review, Update, and Delete). JGuiGen adds FIND and REPORT to this list. Virtually every database project ends up needing to an edit screen for every table in the database. These might be standalone application or they may be part of a larger application. JGuiGen can help automate the creation of these applications. The generated applications address many issues such as internationalization, accessibity, multi-user, saving user preferences, and on and on.  
II. ACCESS DATABASES - Real world applications almost always need to talk to SQL databases. A lot of the JGuiGen code addresses accurately reading and writing to SQL table, reporting, notifying users and logging error messages, handling multi-user conflicts and more. JGuiGen code has been written to accommodate different SQL backends.. It can be modified easily. to handle new databases. As of February 2006, it is known to work with PostgreSQL, MySQL, Hypersonic SQL, SQL-Server, Oracle and MS Access. It comes with notes about how these backends differnt and how to manage data for each type of database.  
III. DATA DICTIONARY - Developers need to document tables in their SQL database. JGuiGen does this automatically by placing a record for each column in your tables into a special data_dict table and letting you annotate each field. A listing of fields, notes about the fields and when fields were added or changed can be generated at any time. Since JGuiGen queries the actual tables and updates the data-dictionary, the listing (except for the notes and usage comments) is guaranteed to be up-to-date. This code has many features. These features are described in detail in the Swing demo and are summarized below..  
IV. USEFUL CLASSES - The third part of JGuiGen is a library of Java Classes to help in creating GUI front ends to your database tables. The project includes a number of classes gathered from various places that will help in creating GUIs. For example there is A) a simple rowlayout manager, B) a JTable where each column is sortable and resizable, C) a JTextField that will not allow more characters to be entered than exist in your table and D) JTextField classes for entering Integers or Floating Point numbers E) a JSearchableComboBox that shows you the first option that matches the letters you have typed so far. F>Special JTextFields for entering SSNs, IP numbers, telephone numbers and more.  
V. JAVA SWING EDUCATON - The last major objective of JGuiGen is to help educate developers on techniques need to write real-world rich client applications. Part of this is done by generating annotated Swing Code that can be viewed on a web Site. The Swing Demo discusses and shows this code.  
VI. DEVELOP CODE THAT WRITES CODE. Generation 2 for JGuiGen uses a code generation system that reads marked up working Java code and does mail-merge type substitution to create java applications that are tailored to your individual SQL tables. There is a mixture of substituing lists of variables taken from the data dictionary table and taking lines of working code to generate the final java classes. This allows us to tweak working Java code templates to add new features and then generate new classes for different SQL tables that have these new features.  

VII JGUIGEN REPLICATION SYSTEM - Many desktop applications need to run stand-alone and in a shared envionment. The stand-alone versions often need to synchronize (replicate) their data with a home site. The developer of JGuiGen is migrating code from a system that successfully replicated dozens of sites to Java and the JGuiGen project. This replication system will also be used to migrate JGuiGen from the HSQL database it ships with to other database such as mySQL, Oracle, and others.

Feature highlight

Each Class generated creates a JPanel which:

·has a configurable Menu (with or without icons, top or bottom of screen) which provide standard options (like VIEW, EDIT, ADD, DELETE, and FIND ). The modern acronymn is CRUD - Create, Review, Update and Delete. We has added FIND, REPORTWRITER, PRINT and HELP.  
·is ready to run under Windows or Linux. (I assume they would run under other *nix OS's, but I haven't tried them.  
·a wide selection of Swing visual components can be used - JComboBox, JList (multiple selection combobox), radiobuttons, checkboxes and special components for common fields such as telephone, SSN, IP addresses, etc.  
·has an optional scrolling JTable that shows selected columns from the table being edited. Users can drag columns to customize this table.  
·runs with different backend databases (PostgreSQL, MySQL, SQL-SERVER, Oracle, MS Access and Hypersonic SQL for now - more soon.)  
·has a pop-up menu with the same options as the main menu, plus options to select a different look and feel, refresh the table, duplicate a record and move to the next or previous record.  
·is multi-user safe (SAVE's automatically check for overwriting someone else's recent update)  
·will run in Java Web Start, from a jar, or from standalones classes ,  
·is internationalized (I18N)  
·is accessible (A11y) (this includes a Low Vision /High Contrast look and feel for the visually handicapped)  
·Has special fieatures to maximize data integrity in your tables. For example:  
·the system reminds the user when they try to do something that would result in losing unsaved data  
·tests for required fields or conditions before saving or adding a row  
·comes with many special visual editing components that improve data integrity (such a a bounded text field that will not let users enter more characters than a field can hold, a pop-up screen for selecting dates, classes to enforce the entry for SSNs, IP Addresses, email addresses, money, positive and negative integers, State in the USA, etc.).  
·allows you to mandate range limits on selected fields or just warn about limits on those fields.  
·comes with its own console screen so users can see SQL query status (including errors). This is especially important for applications that use Java Web Start since the standard console is hidden by default  
·has an authorization system to restrict user access to any screen. A user can be given no rights to even see the screen, view-only rights, edit rights, add rights and/or delete rights.  
·comes with with a button that calls a Java Help system  
·has a PrintScreen button  
·Is keyboard accessible (as much as possible) with different hot keys for different languages  
·automatically uses the current system's Look and Feel  
·saves user preferences for screen size and placement, and look and feel  
·reads setup information from an XML file.  
·has an optional Find button that pops-up a simple SQL Query builder  
·users can save frequently used SQL queries and call them from a list.  
·comes with a simple Report System that users can use to build their own reports.  
·comes with an option to frequency count columns and give the mean for numeric columns. This data can excluded selection values as "Missing" and can be exported to an Excel file and to the user's clipboard.  
·comes with a simple row-layout manager for laying out the screen to your needs  
·does database access using an AbstractTableModel  
·does database access using preparedstatements in order to improve speed and protect against SQL injection attacks.  
·uses the java logger facility to log application information,  
·has special features to help identify code that changes when a screen is regenerated after a column as been added or changed in the backend database.  
·shows a screen in a scrollable JPanel so that all of the components are viewable even before the developer modifies the row layout.  
·comes with a main method to assist with testing and debugging. The main class comes with options so that you can easily change the locale or look and feel for a test run.  
·Comes with a routine to show a History.htm file that you can use to notify users of changes to the latest system. The date on this file can also be used to determine what version a user was using when they had problems.  
·automatically builds JUnit TestCases to test the functionality of the classes it generates.  
Outputs Generated by JGuiGen:

· Annotated documentation describing tables in your database. You can add descriptions and notes about each column in each table.  
·A Java file to create a JPanel that views, edits, adds, deletes, queries, and reports on records to a table in your database. The layout activity is contained in its own class file so that you can tweak it and not loose the tweaks if you regenerate the application.  
· A Java file that contains an abstractTableModel for the table your JPanel is editing. This file is linked to a class called Model.java which contains many utility methods. For example, Model contains the method used to open the connection to your database and the methods used to parse the XML ini file. All calls to the SQL backend database are made through these model files. This gives you one place to change if you need to make a change that is specific to your particular site.  
· Resource bundle files that contains all of the text that is used by the JPanel you just created. All prompts and messages are in these files which are used for internationalizing an application.  
·Two Java files that contain a JUnit Testcase to test your JPanel. One of these is an abstractModel file. This allows the test system to setup the JPanel once and run lots of tests against it. The other file is the TestCase.java file and it inherits from the abstract class. These files use the jfcUnit extension to JUnit.  
·A copy of the java file written in HTML format. This includes internal links that highlight parts of the code.  
·An HTML file that lists all of the internal links contained in the HTML version of the generated JGuiGen panel. This file is used to insure that the web site being used to document the system contains a link to each interal link.