by
Hale Pringle Ed.D.
Vernon Singleton
JGuiGen is the result of my attempts to create a Java Usual. It is a system with six main parts.I. Introduction
JGuiGen started of as an effort to create what we used to call "the usual" in xBase database development. Many developers
found a need to take an existing table and create a very simple application that had the CRUD functionality.
CRUD stands for Create, Read, Update, and Delete. There were several applications around that
would allow you to point at a table and bingo you had "the usual." I found that in my java database
work I often had need for "the usual." Even in very large projects, a considerable part of the effort went
into creating applications to edit various tables. Current applications have evolved to where
even "the usual" can be quite complex when it involves a SQL backend, users with different languages, etc.
When we create a Code Generator to we need some global guidelines. Here are ours.
We are getting close to meeting all of these goals. As a result of the Quick Create conversion we now have several new features
SPECIAL SETUP WHEN STARTING A CLASS
In addition to the reflection stuff just covered. We also have some other new features
for our generated classes.
SAVING HAND CODED ADDITIONS TO CLASSES
Here is how we are handling inserting hand-written code into JGuiGen classes without
losing this code when you regenerate the class. Note that JGuiGen generates an
XXExtra class for when it generates a class called XX. This extra class is never
overwritten. Anything you place into it will exist after a regeneration.
With the functionality JGuiGen already has. These additions cover Goals 1 through 4. Now we need to finish the 5th goal. Here are the steps we are working on.
After the next set of updates when you look at all of the rows associated with a class you will see five types of rows in our data_dict table.
Getting to this point requires several steps.
NOTE:I should note that as I read articles on programming I see places where authors explain at great length why it is not best practice to do some of the things I do in JGuiGen. Some of these I agree with (and have reasons for ignoring) and some I disagree with. You need to make your own decision.
II. Version - This is Version 1.08 06/28/2006
To Do
III. History
-
6-20-2006 - Refoactored. Got rid of menu options to create a table. Now the Quick Create
screen allows you to select a class and push one button. It generates, compiles, and runs the
new class. You can edit Class level changes or column level changes. Close tha new
screen and click the create button to generates, compile and run again.
4/20/2006 - Refactored and added Mark Tables Menu option (instead of editing XML file)
4/10/2006 - Separated the Edit Class Description into its own menu option. It was just a tab in the screen that mostly dealt with editing column data.
4/2/2006 - Finished the LDAP and encrypted password code. JGuiGen will now check a password
against a hash stored in an LDAP store. It then unencrypts the database username and password
needed to access the SQL backend.
3/28/2006 - The main code is now read from a template called /Template/MainSource.java. This
is a working java class that has been annotated to supply the guts of the JGuiGen generated
class.
1/23/2006 - Added ability to create a tabbed screen automatically.
;;
1/23/2006 - Refactored Data Dictionary Application into separate Sections.
;;
1/10/2006 - Added OracleXE to list of databases supported.
;;
1/4/2006 - Added MS SQL-SERVER to list of databases supported.
;;
1/2/2006 - Cleaned up and expanded the I18N code. For example it now automatically checks for
duplicated prompts in the JGuiGen_i18n table.
12/20/2005 - When the scrolling table is filtered and a row is deleted, redisplay the
scrolling table using the filter.
12/19/2005 - Enhanced the FIND utility (SQLWhereClause builder). Some tables never delete a row.
Rows are just marked as "inactive." The query builder now lets you look at the inactive rows.
;;
4/29/2004 - added the ability to save queries and rerun them later.
Added a link to the JFreeReports system. You can take the JTable that is
part of the normal edit screen, drag the columns around until you are happy
and then print a report based upon your layout.
4/7/2004 -
Modified the I18N routine. See the section on Internationalization.
Removed some of
the code from the generated files. For example the code that actually
builds the layout of the screen is now in its own class file. This is
written the first time you generate an application. From then on it is
not overwritten. This
allows you to manually set up the screen the way you want and if you
regenerate the
application these changes are not lost.
Enhanced the
Find routine.
Added a
Duplicate current row, NEXT and PREVIOUS button to the pop-up menu.
When you save
changes, these changes are reflected immediately in the JTable that
displays the rows. This was done without re-reading
all of the data and rebuilding the JTable.
Added an EXTRA
button to each application. This button activates a separate class.
The first time the application is generated this class is written out
with dummy code.
You can add functionality to this class and it will not be overwritten
if the application is
regenerated. You can change the name from "eXtra" using the I18N table
edit described above.
Added another
demo application to the sample application. This is an inventory
edit screen that uses the extra button to merge table information into
an HTML template.
This template creates an ad for eBay. The Extra button also has an
option that writes the necessary data out to a CSV formatted text file
for import into eBay's Turbo Lister
program. Using this system you can keep track of inventory, build ads
to auction the
inventory and automatically send the ads to Turbo Lister. Turbo Lister
allows you to
double check your work and upload the ads to eBay when you are ready
for the auctions to start.
;;
10/7/2003 -
Removed JGuiGenIni.xml, JGuiGen.Java,
com/halepringle/src/UserLogData.Java,
com/jguigen/standard/Model.java and
com/jguigen/standard/DBMaster.java
from the CVS repository and renamed them to *.javatemplate. ;
These
three files were added to the CVS repository. ; A setup.bat
and a
setup.sh file were also created. The batch/script files copy the
template
files into their proper place. The net result is that changes to
the xml
file, UserLogData.java, JGuiGen.java, Model.java and
DBMaster.java are not
updated into the CVS repository. Since these files are edited by
each
project in a unique way, this is desirable behavior. ; In
order to
commit a change to the repository so that every new project will have
the
change, the javatemplate files must be updated. ;
10/10/2003 -
automated some steps that required cut and paste. The steps
automatically
insert code into the XML file and the Model.java file as needed now. Java Web Start - When I reactivate it you will
be able to download an sample executable JGuiGen using Java Web Start (JAWS) on the
SourceForge web site. Right now this is not functioning Full Copy - You can
copy down a full copy of JGuiGen from the HalePringle.com web
site. You will need to unzip the three files ; There are
more instructions below. SVN Repository on SourceForge- You
can obtain the most recent code from the SVN repository. If you have installed subversion
you can download a working copy of everything with the following command
B. WHAT TO DO FIRST Java Web Start (JAWS) - When you launch JGuiGen with JAWS
the sample program runs automatically. (You will be asked to okay a certificate from Hale Pringle
that is not verified. You will need to say it is okay for the system to download and run.) Full Copy and SVN versions-
After you download and unzip the full copy. Edit JGuiGenIni.xml file -
After you start you may want to use a text editor and edit the
JGuiGenIni.xml file. There is a list of users in this (you will
see Hale, Vernon, and Tester already there.) You may want to add
your name to this list. ; If you don't modify the file, you can use any of the
three names that are already there and the system will run using the HSQL tiny database system. WHEN YOU FIRST RUN the
JGuiGen.class- you will be asked to point to the path to the
executable file that runs your browser of choice and your word processor/editor of choice.
When one of the applications needs to show you something in HTML format
it will invoke the file you point to. You will only need to do this
once per machine. Typical paths are shown in the prompt when you are asked to pick the path to your browser of choice.
The buttons on this screen are grouped. The first group are actions that will edit
the entire class you just created.
The second group of items is the Column Level edits. These allow you to modify things
about one visual component in the GUI that is ued to edit one column in the SQL table.
NOTE: ; If you using the version of
JGuiGen that was downloaded by JAWS and you
want to compile the generated code and try it
yourself, you will need to do several things.
We have tried to make sure that JGuiGen does not access the systemRoot preferences file.
If by some chance this changes you can run the program once as the root user and the folders will be created.
You will need to give your users read/write rights to these two places. JGuiGen saves
things like the Look and Feel and Color Scheme that a user prefers in the UserRoot.
It does not save anything (currently) in the systemRoot. On the other hand the folder
must exist or you get an error that I cannot trap for. See http://www.allaboutbalance.com/disableprefs/
for more information about this "problem."
II. If you want and Integrated Development Environment (IDE) you will need to download
Eclipse
NOTE: See the section on Eclipse below. There is one change in the Elcipse
environment that you MUST make in order for Eclipse to run JGuiGen correctly.
III Download the source code
IV Running Eclipse
V. Running the Application in Eclipse
See the section about running JGuiGen in the Eclipse IDE for setup instructions.
Click on the plus beside the JGuiGen Package (upper left corner of Java
Perspective
VI. Running from the command line
We have created two shell scripts ./build.sh and ./run.sh.
or
JAVA_HOME="/usr/java/j2sdk1.4.2_10"
export JAVA_HOME
VI. Accessing HSQL database
II. If you want an Integrated Development Environment (DE) you will need to download
Eclipse
III. Now we download the source code
III Running Eclipse
See the section below for instructions on setting up JGuiGen in Eclipse.
You will also have to change the folder where Eclipse finds the
Note: You will need to change the JRE and add these three external jar
V. Running from the command line
We have created three batch files build.bat, run.bat. and buildwork.bat
VI. Accessing HSQL database
You will need to download the source code
The following steps are all described in more detail in the manual and on the web site
but here is a brief overview of the steps involved in creating a real application. You will
be able to skip a number of these steps when you run the samples and examples that come with
JGuiGen. In normal development, I use the Eclipse (from eclipse.org) and run the DataDictionary
application in com.jguigen.standard directly from the IDE and run the
applications generated directly.
The jar files needed in the JGuiGen classpath are all located in a lib folder under the
main JGuiGen folder. The build.sh, build.bat, run.sh and run.bat files all have code that automatically
creates a classpath using the jars that are currently in the lib folder. In addition, after you
have generated a class there in a YourClassName-manifest.mf file in the lib folder that contains one line
that contains this class path if you need something to cut and paste from.
ACCESSIBILITY - A11y
See the manual for information about the many A11y features in JGuiGen generated applications.
For example:
INTERNATIONALIZATION - I18N
The system java uses to interationalize an application uses a text file for each language.
These have an extension ".property" and are called properties files. Each of these files
is made up of lines that contains prompts and values. For example title=TITLE SCREEN. Your
application will look for the word "title" and replace it with the words "TITLE SCREEN". If you
are running the application on a machine that is using a language other than English, the
system automatically looks for a file containing prompts in your language. If the file exists
it will contain exactly the same prompts as the English file. The values will be different in that
they will be in your language.
Managing changes across several of these files is a nightmare. This problem is made even more
difficult when working with a code generator like JGuiGen. Every time you regenerate the code
you tend to overwrite any manual changes you made previously or you end up with properties files
that do not contain the prompts for things you added during the new generation session.
JGuiGen now handles this problem by using a table to store the prompts and values. The table in the
database is called
JGuiGen_I18N. This table contains the information needed to create the properties files for up
to 10 different translations of the prompts and error messages used in your project. Each row contains a prompt, a default value and the
value you currently want placed in the properties file. It also
contains the translations of the values for the foreign language
properties files. There are three major advantages to this system.
NOTE: You should NOT change the properties fields manually. They will be
overwritten every time you generate a file using JGuiGen.
In order to use the internationalization system you will need to carry out three steps.
One part of building applications that is often difficult is handling errors and support.
JGuiGen and its generated applications come with a number of built in features to facilitate
use and support.
First there is a second screen (that starts minimized) when JGuiGen or one of its applications
starts. This screen has the icon LOG. You can see error messages and messages about
how many rows where selected etc. on this screen. You or your users can also print this
screen to communicate errors and problems.
When a problem occurs (or a warning occurs) a pop-up screen usually appears in the upper
right hand corner of the users screen. This window indicates that there is something in the
log screen that is probably worth looking at.
There are also some debugging and error messages that appear in the standard command window.
If you are running JGuiGen using JAWS, there is a JAWS console that will contain these messages.
Finally there is a text file generated while JGuiGen is running. Developers or administrators
can use these files to look for errors or to see who made certain changes. The files
are called JGuiGen.txt.x where the "x" is replaced with 1, 2, 3, etc. They are written to
the /Logs folder under the root folder for JGuiGen.
NOTE: You will probably have to EDIT the various libraries to fix the PATH.
The project I upload runs on the E: drive of a windows PC in a path that you probably won't have.
The files in the work.src folder will NOT be automatically compiled by Eclipse. I do one
of two things. 1) run buildwork.bat from a command prompt or 2) add work and work.src back
to the classpath and change the packages in each of the files to work.src. I don't use
option 2 very often. or 3) I could creates a src folder under the JGuiGen folder and
copy the generated files to this folder. They would run fine there.
Down the right margin of the edit screen there are small red bars that tell you where in the
whole java class Eclipse has detected errors. You can click on one of these bars to move
the editor to that place in the file.
There are several button at the top of the Edit screen that are worth looking into. One of these
will take you to the next error in your file. Another takes you to the previous error.
(There are also buttons to move to the last place you edited code - even if it is in a different
class file. These are very useful.)
When you SAVE a file, the red X that indicates the file has errors in it does not
always go away even though there are no errors left in your java class. The Projects -->
Build Project button almost always takes care of this. In the very rare cases that it does
not you can exit Eclipse and restart it. So far this has always worked for me.
Beside the RUN button there is a green bug button. This is the "run as debug" button and it
works just like the RUN button.
If you right click on the margin beside an active line of code you get a pop-up menu that includes "Toggle
breakpoint". When you first click it a blue circle appears in the left margin. This indicates
a line that the application will stop running on when you are running in debug mode. There are
several buttons available in the DEBUG view for stepping to the next line, stepping into a called
class, etc. Note: If you have double clicked the tab containing the name of the file you
are editing, Eclipse makes the EDIT panel full size for the Eclipse window. This is great for
editing, but it hides the "Step over" and "Step into" buttons. You need to double click the
tab again to reduce the size of the edit panel. The red square button allows you to terminate
the running of the class at any time.
My 10 Favorite Eclipse Tips (From an Eclipse Presentation I made a few years ago)
If the XML file has still not found, the system exits.
Note: At the time of this writing, the author does not actually have an LDAP system running.
I am using JNDI which is Java's system for accessing multiple directory services with a
standard set of calls. These calls should access Novel's NDS, Microsoft's Active Directory
Service, various versions of LDAP - such as Open LDAP, etc. In this can I am using FSCONTEXT.jar
which is a reference system provided by Sun to emulate LDAP. The information is being
saved in a file called .bindings in the root directory where JGuiGen resides. While the
user names are visible, the password information stored there is in hash form and it is VERY
difficult to go from the exposed hash to the password that created that hash. These calls
should work on a real LDAP or they may need some modification. I believe that they are close.
Note: The JGuiGenIni.xml file contains an entry for a shared path. This is a location where
the encrypted text files are stored. This can be a shared network directory where IT can
remove and add files at will or a local directory. If the shared path is "DEFAULT", the
files will be in a System directory under the root location where JGuiGen resides.
Files: You will see the following files in the shared directory:
NOTE: I have not worked on these files at this time and hence don't know if they will work
for us, but they should.
First I take a working java program and mark it up. This becomes my
template. The template always compiles and runs. This allows me to use
an IDE to syntax check while I add features. It also allows me to compile and run the
template until I get the results that I am looking for.
There are a few simple definitions and rules.
"public class _JGG_classname_JGG_ () { //MAINSOURCE"
results in a line that compiles cleanly. JGuiGen would include this line if it is looking
for the Line Marker "//MAINSOURCE" and could substitute the classname for _JGG_classname_JGG_.
Part of what I am working toward is to merge two types of templates as
part of the generation process.
Type one - Constant code I have a large class (5000 plus) lines that will edit a SQL
table. You have seen an example on the web site. This is what I call
constant code even though there are elements in it (such as classname)
that are variables.
TYPE 2 Variable code- Code that is specific to one type of Visual Component.
The current JGuiGen application has 20 different
places in it that need java code to be generated that is specific to one
SQL table and the columns that it contains. Most of these places
involve Visual Components. For example: If I have a SQL table with the
column lastname char(30) I would have the following places that this
appears in my code:
DECLARE JBoundedTextFeild txtLastName = new JBoundedTextField(30);
INCLUDE IN AN ARRAY OF TABLE HEADERS ,"lastname"
INCLUDE ITS WIDTH IN AN ARRAY OF COLUMN WIDTHS ,75
CREATE A LOCAL INT THAT
ACCESSES THE FIELD IN A JTABLE CLASSNAME_LASTNAME = 2;
INSTANTIATE txtLastName.setToolTip("_JGG_description_JGG_");
CODE TO CHECK FOR ERRORS
CODE TO GET THIS FIELD OUT OF A SQL RESULTSET AND PUTS IT INTO A BEAN
There are a number of special files and jars used by JGuiGen.
Here is a listing of some of the critical ones for developers.
The special classes provided for your use and used by JGuiGen
applications are listed on the web site. These are both
provided through Java Web Start so that they are available to run the
application and they are needed in your CLASSPATH when you develop
using the JGuiGen system. I use the Eclipse IDE and I need to
Right Click on the Project name, choose Properties and choose
BUILDPATH. I then "add external libraries" and add all of these. In addition there are three jar files and some other files created
by JGuiGen. When these
are downloaded by Java Web Start they will have the letters "RM" added
to the front of each file. JGuiGen Files
FILES for HSQL DATABASE
FILES for MS SQL-SERVER DATABASE
The JDBC driver jar is the only file provided. You will need to down load MSDE or
install a full SQL-SERVER you purchase from MS. See the section of MS SQL-SERVER to
see a discussion of on open source management package you can download.
FILES for Oracle (XE) DATABASE
None of the Oracle files (including the JDBC drivers) are included in this download.
Oracle requires a commitment to not ship their JDBC drivers to selected foreign
countries and I cannot guarantee this. See the section on Oracle for information about
where to download the file.
FILES for MYSQL DATABASE
FILES for MS ACCESS DATABASE
Once the system has been
downloaded, several files will be created and taken out of the
jars. If you use the DataDictionary --> Edit menu option and
generate new files, they will exist on your system but you cannot run
them from inside the JGuiGen application that Java Web Start
downloads. This application is compressed into a jar and the files
you have created are not part of this jar. Here are the steps to
try out the files you create. Obviously if you changed the name
of the UserLogData.java file, you will need to make the changes to
com\halepringle\standard\Model.java, recompile it and use your file
name in steps 3, 4 and 5 in place of UserLogData.
Warning: Be careful when editing /etc/profile.d/java.sh.
Here is the document that describes the JGuiGen Replication system.
JGReplication.html
IV. Getting Started - Obtaining the code and Menu options to generate an application
A. OBTAINING A COPY:
The classes downloaded via JAWS will automatically unjar a copy of the
necessary data base using Hypersonic SQL (hsqlhd on SourceForge.net).
It will also automatically unjar a copy of the XML file that contains
setup information JGuiGen uses when an application starts up (JGuiGenIni.XML).
The XML file contains references to the JDBC Driver, the data base URL,
the account to use to open the data base, etc.
There are currently URLS, Driver setups, etc. for six different backend SQL databases
in the XML setup file (JGuiGenIni.xml). The set pointing to the 1) HSQL database is
live. The xml properties pointing to the 2) MS Access, 3) PostgreSQL,
4) MS SQL-SERVER, 5) OracleXE, and 6) MySQL databases are commented out. You can edit
the XML file and run the application against the other database types. See the sections
below for information about running against PostgreSQL, SQL-SERVER, Oracle, mySQL and MS Access
databases.
svn checkout https://svn.sourceforge.net/svnroot/jguigen/JGuiGen/trunk jguigen
In this case the last word is the name of the folder that svn will create with this project
installed. You can look at a video that walks through the steps at
http://sourceforge.net/projects/jguigen or
http://vernon.is-a-geek.org/mediawiki/index.php/JGuiGen_Demo_with_Hale%27s_notes
Note: the PostgreSQL data base on my web site are not currently active.
I will reactivate it upon request.
run build.bat or ./build.sh
This sets up a classpath and compiles the code.
Then run run.bat com.jguigen.standard.JGuiGen
or ./run.sh com.jguigen.standard.JGuiGen to run the main application. You can run
run.bat com.halepringle.src.JGuiGenDemo
or ./run.sh com/halepringle/src/JGuiGenDemo to run a demonstration of what JGuiGen
generates. There is more information below. I use the Eclipse IDE and
there is a section below that describes running JGuiGen from this IDE. Other IDE are
similar.
Running the sample JGuiGen Application - The Main JGuiGen screen
will come up. If you want to see what a generated screen looks like
click on USERS --> View JGuiGenDemo. This will bring up a sample screen that has been generated by JGuiGen.
This screen demonstrates virtually all of the special features that JGuiGen can generate.
These are covered in some detail on the web site.
Creating a JGuiGen generated application You can click the Create button on the main
JGuiGen screen. This will bring up what we call the Quick Create screen.
Options in the Create Screen
C. Running the samples already in the Jar file.
The third menu option in the main JGuiGen application (USERS) already
has menu options to run UserLogData.class, JGuiGenDemo.class and an empty class
called Tester. JGuiGenDemo
is a JGuiGen generated screen that has been tweaked a little like a
developer would normally do to create a production version of the code
generated by JGuiGen. When the project is shipped there is
a dummy UserLogData class file included so that the JGuiGen file will
compile. You will overwrite this file if you generate your own
UserLogData.java file.
The final menu option under the second menu option lets you see the resource
bundle file. Linux - Step by Step
Notes are specific to Fedora Core 4 - adjustments may be necessary
I. First we need to download a more current version of Java. The 1.4.2 version
that comes with Fedora is not current enough to run JGuiGen.
1. Navigate to javasoft.com
The RedHat user forums indicate problems with Linux and Java 1.5. We have used
it successfully. You can use it or you can go with 1.4_2_10
2. If you want 1.4.2_10, Search (Upper left corner Download 1.4.2_10
added /opt/j2sdk1.4.2_10/bin: right after PATH=
line became PATH=/opt/j2sdk1.4.2_10:
When it comes up make sure it says Eclipse 3.1 If it says Native Eclipse
and has Fedora on the splash screen you are not running the new one.
command is /Downloads/eclipse/eclipse
icon is /Downloads/eclipse/icon.xpm
workpath is /Downlods/eclipse
svn checkout https://svn.sourceforge.net/svnroot/jguigen/JGuiGen/trunk jguigen
This creates a folder called jguigen under your home (or wherever you were when you
ran the file.) If you use this option you only need to unzip JGuiGenMisc.zip
Once it is happy it is going to build the whole project. Look in the lower
right corner of the screen if you see a small progress bar with 10%, 20%
that is what is going on. Sometimes it seems as if things have hung when
in fact it building the project.
I kill the Welcome Screen (red x on its tab)
Click on Window --> Open Perspective --> Debug
Now you will see two tabs in the upper right. You can switch back and forth.
The Java Perspective has the nice tree for opening files
The Debug Perspective allows you to "Terminate and Remove Threads" (Right
click on a thread in the upper left and click on Terminate and Remove.
You will need this because HSQL (the sample database in use) is truly
single-user. If a thread hangs you can't open it again until that "user"
goes away.
The first time I did this I clicked on Finish at this point. It failed.
The second time I chose Java Project under Java (not the top Java Project)
and I clicked on Next instead of finish.
Click on Window Tab --> Preferences --> Installed JRE's
I had to add /opt/j2sdk1.4.2_10 and put a check mark by it to make it live
Right Click on JGuiGen Project (upper left in Java Perspective)
Preferences --> JAVA Build Path --> External Jars --> Add
add these two /opt/j2sdk1.4.2_10/lib/jce.jar
/opt/j2sdk1.4.2_10/jre/lib/jsse.jar
/opt/j2sdk1.4.2_10/lib/tools.jar
- this is the compiler.
Note: You will need to change the JRE and add these three external jar
files every time you download a complete copy of the source. If you do not
unzip JGuiGenMisc.zip you will not need to modify the class path again.
Click on the plus be Default Package
Double Click on JGuiGen.java
Click on arrow beside the green circle --> run --> as Java Application
One of the first steps should be run the JGuiGenDemo under the Users mens option.
You can then generate UserLogData using the options under Data Dictionary.
After the UserLogData files (model java code and main class java code) have been generated,
you will need to right click on the JGuiGen Project in the upper left corner of the
Eclipse Java Perspective. Choose "Refresh" and Eclipse will find the new java files in
the com.halepringle.src folder. User projects choose "Build Project" or "Clear" to compile
all of the new files. You can then run UserLogData on the Users menu option.
note the Db on the last line
Windows - Step by Step
Notes are specific to Windows 2000 Pro - adjustments may be necessary
I. First we need to download a fairly current version of Java.
Navigate to javasoft.com
You need to have a later version of 1.4_8 (or so) or Java 1.5. If you decide on 1.4.2_10 (the
last version of 1.4, you will need to search for the download using the search
area in the upper right corner of the screen.
When it comes up make sure it says Eclipse 3.1
Tortisesvn merged into your windows explorer. Open the windows explorer and create a folder.
Highlight the folder and right click. You should see a Tortisesvn Checkout option. Click
on that and fill in the information. The "URL of Repository" is
https://svn.sourceforge.net/svnroot/jguigen/JGuiGen/trunk Then "Checkout Directory" should
already be filled in. The only other things that should be checked is the "HEAD Revision"
checkbox. If you download a command line client the command will be
svn checkout https://svn.sourceforge.net/svnroot/jguigen/JGuiGen/trunk jguigen
This creates a folder called jguigen under your home (or wherever you were when you
ran the file.) If you download using subversion you only need to unzip JGuiGenMisc.zip
Once it is happy it is going to build the whole project. Look in the lower
right corner of the screen if you see a small progress bar with 10%, 20%
that is what is going on. Sometimes it seems as if things have hung when
in fact it building the project.
I kill the Welcome Screen (red x on its tab)
Click on Window --> Open Perspective --> Debug
Now you will see two tabs in the upper right. You can switch back and forth.
The Java Perspective has the nice tree for opening files
The Debug Perspective allows you to "Terminate and Remove Threads" (Right
click on a thread in the upper left and click on Terminate and Remove.
You will need this because HSQL (the sample database in use) is truly
single-user. If a thread hangs you can't open it again until that "user"
goes away.
Click on Window Tab --> Preferences --> Installed JRE's
I had to add c:\j2sdk1.4.2_10 and put a check mark by it to make it live
Right click on the JGuiGen in the upper left of the Java Perspective.
Click on Properties and Java Build Path
Click the Libraries tab and remove the ojdbc14.jar. This is Oracle JDBC
file and they won't let me send it unless I agree that I won't let people
from foreign countries that the US doesn't like download it. I can't
possibly stop them so there we are.
files every time you download a complete copy of the source. If you do not
unzip the JGuiGenMisc.zip file you will not need to update the classpath.
IV Running the Application in Eclipse
You can then generate UserLogData using the options under Data Dictionary.
note the DB on the last line
V. CREATING EDIT SCREENS USING JGUIGEN in your own projects
.
After you have tried the sample in the Java Web Start folder, you are
better off
downloading the source and setting up your own project and running from
there.
You can either download the three zip files or use the SVN repository on SourceForge.net.
NOTE: JGuiGen requires one special field to be identified and works best if three other fields
are available.
You can override any of these default marking if they are not what you wanted.
*****************************************
VI The CLASSPATH used by JGUIGEN:
JGuiGen uses a number of packages from other sources. These will
need to be in your CLASSPATH. In Eclipse, I checkout the project and then
Right
Click on the Project --> properties. One of the options is
BUILD CLASSPATH. I add them all by clicking the top one and shift-clicking the
bottom onw in the "Add a Jar" option.
VII. JGuiGen - Accessibility and Internationalization
VIII. Logging and Error Handling
IX. Databases supported
Currently there are six back-end databases supported by JGuiGen.
X Using Eclipse and HSQL with JGuiGen
There must be a way to open an existing project in Eclipse, but I haven't found it.
What I found is that if you create a new project, change from the default workspace and
enter the path to the folder you unzipped JGuiGen into and enter the project name JGuiGen,
Eclipse will recognize that there is an existing project and open it.
This is not very intuitive, but it works.
Eclipse has a number of "views" or "perspectives" that are different screens that have
a combination of panels
that facilitates a certain operation. I use the JAVA view and the DEBUG view extensively.
In the newer versions of Eclipse you click on the Windows --> Perspectives menu option and click
on the various available views to make them active in your project. From then on there will
be tabs (usually in the upper right hand corner of the screen) that allow you to switch
perspectives.
Click on the JAVA perspective and you should see a panel with a tree with the word JGuiGen
at the top. You may have to click on the plus sign to open this tree. Click on the tree
to highlight it and then bring up the right-click menu. Choose Properties-->Java Build
Path from this menu. Click on the Libraries tab. This is where the external jar go. There is a
whole list of them elsewhere in this help file.
In the JAVA perspective there are four paths in the tree that you will using.
By default (on Windows PCs) when you save a class file
in Eclipse you automatically compile it. I spent some time looking for the "compile" button
when I first started using Eclipse. Note that on Linux machines you have to activate this
option. See the Linux Considerations portion of this help file.
I use the Projects --> Build Project menu option regularly to compile all of the files that need
updating.
JGuiGen generates code that contains a lot of warnings. I have
decided to live with this. For example I include the java libraries for all of the things
the JGuiGen might generate. If you are not using certain features you will see a warning
that an include is not necessary. Small yellow circles indicate warnings.
Eclipse shows you that you have errors in your files using several
visual clues. In the tree a class with a small red X beside it has errors. At the top of
your edit screen there are tabs for each of the files you have open. Those with a red X have
errors. (Those with an asterisk haven't been saved yet.) As you scroll up and down in a the
java edit screen (either in the JAVA perspective or the DEBUG perspective) you will see
a red X in the right hand margin beside lines that have errors. You can cursor over this X
or over the code underlined in red to get a message about what Eclipse thinks is wrong.
The single use hypersonic
database (HSQL) that JGuiGen uses as a default (since it can be shipped with JAWS) is very sensitive
to being SINGLE USER. This means that running a program in Eclipse that crashes, may leave
the HSQL connection open. Click on the DEBUG perspective, highlight the threads area, right
click and choose Terminate and Remove.
Just above the Edit Screens in Eclipse there are two buttons that run applications. The
green arrow runs applications "as Java Applications" or "as JUnit Applications" (and others).
When you click the drop down part of the button you can choose "run as" --> Java Application
and run the java class that is currently open. Most JGuigen classes have a MAIN method so
that they can be run as Standalone files for testing. Once you have run a file using the
drop down arrow, it is added to a list and this list appears when you activate the drop down.
The last file you ran runs if you just click the arrow without the drop down.
XI The XML INI file
JGuiGen is driven by an XML file. The name of the file is
JGuiGenIni.xml. The system looks for this XML file in several places.
There are instructions in the XML file for editing it. You will need to
edit this file
to change which database you are using and where it is located.
The
changed needed include the following:
XII JGuiGen Security and LDAP Support
JGuiGen is designed to create a CRUD application that will edit a SQL backend database table.
Creating such an application without regard to security doesn't make any sense. On the
other hand Java is a quasi-interpreted language which makes securing the code difficult. Here
are the solutions offered by JGuiGen.
Authentication - who can log in
Connection conn = Model.getConnection(username, password);,
then call Model.setConnection(conn);
You can optionally call Model.setUser("name of a user to record in tables"). If you don't
make this call the user making changes will be recorded as "unknown".
You get the database username and password and the username from your own code.
Authorization
Each screen has an option "Screen number." If this number is not -1 or 999, JGuiGen will
query the Model file for the user's rights to this screen. This information either comes
from the UserLogData table when the user log's in or you can manually set is with a call
to Model.setScreenRights(ScreenNumber, rights). The rights code has the following format.
In typical *nix fashion you add the rights you want the user to have together.
* 0 = view only
* 1 = add
* 2 = edit
* 3 = delete
* 7 = view, add, edit , delete
* 8 = do not even show screen
Note: The "Delete" rights are set when the application is generated. They may actually delete
rows or they may mark them a "removed/inactive."
Encryption
JGuiGen has an option to encrypt individual fields in a table. The password is stored for each
user when they are created. The password is encrypted and the user never see it. At the
time of this writing I have not actually activated the encryption option. I will do so soon.
The checkbox is in the Data Dictionary table and the Data Dictionary edit screen used to
create JGuiGen Applications. My intent is to allow encryption of varchar fields only. In
any case users will see the data while they are editing the table. The values will be
decrypted on their way from the SQL table to the user edit screen and encrypted on their way back to the SQL
table.
General
All of the classes used to secure JGuiGen are stored in the com.jguigen.secure folder. Debugging
statements are surrounded with an if (DEBUG) {xx} statement so that they disappear from the
resulting class file when DEBUG is set to false. To increase security you can remove the
.java files from your system and even store these classes in an obsfucated jar.
HTTP Tunneling
JGuiGen ships with files from the Wrox book "Profession Java Security" which allow you to
create an SSL encrypted tunnel between a user machine and a remote database. This ensures
that data between the application and the database is difficult to "sniff" on the wire.
XIII The JGuiGen Code Generator
JGuiGen is code that writes code. When I started it was similar to Java Servelets.
In a sevelet every line of HTML code is written out by the developer. This ends up with
code that is very difficult to modify. The current version of JGUiGen is more like
Java Server Pages. There is live java code mixed with merge codes.
For example:
//Example code for the JGuiGen Code Generator //MAIN
When I use this code as a template lines 2 and 4 are not used (they don't have the
//MAIN line marker) and lines 3 and 5 take their place. If we run this using the classname
"Sample" and the package "com.halepringle.src" we get the following lines
package Templates.stable;
//+package _JGG_packagename_JGG_ //MAIN
#import java.swing.utils; //MAIN
public class Tester() {
//+public class _JGG_classname_JGG_() { //MAIN
System.out.println("Generated _JGG_classname_JGG_.java"); //MAIN
System.out.println("Hello World") //MAIN
) //MAIN
//Example code for the JGuiGen Code Generator
package com.halepringle.src;
#import java.swing.utils;
public class Sample() {
System.out.println("Generated Sample.java");
System.out.println("Hello World")
)
txtLastName.getAccessibility......
txtLastName.setName("last name");
etc.
LISTENER FOR VALIDATAION
tmpString = (String) rs.getString(tablename.LASTNAME);
if (tmpString = null) {tmpString = "";}
origDataBean.setLastName(tmpString);
CODE THAT TAKES IT FROM A BEAN AND PUTS IT INTO THE VISUAL COMPONENT
txtLastName.setText(origDataBeam.getLastName());
CODE THAT TAKES IT OUT OF THE VISUAL COMPONENT AND PUTS IT INTO A
NEW BEAN
revisedDataBean.setLastName(txtLastName.value);
CODE THAT COMPARES THE TWO BEANS AND CREATES SQL STATEMENTS
classname_UPDATE_VARLIST += "lastname, ";
classname UPDATE_VALUELIST +=
"'"+revisedDataBean.getLastName()+"', ";
if (!{origBean.getLastName().equals(
revisedBean.get:astLastName())){
msg =+ "LastName changed":
classname_INSERLIST += "lastname = '"+
revisedBean.getLastName()+"', ";
changes++
}
Code is also needed to update a row in the JTABLE, special renders that
might be needed for the JTable, etc. etc.
The bottom line is that all of this code is specific to a
JBoundedTextField and will be extracted from a Java class file that is
running code, but only has a couple of fields - one of which is a
JBoundedTextField. The column name is this code will be
_JGG_colname_JGG_ This will compile and run, but will be easy to find
and substitute when I use the code in the merge. I'll have another
class that contains all of the same code for a date, an integer, a regex
field, etc.
Putting it together:
The final generated application will take all of the constant code and
bits and pieces of the Variable definition files. If you have 30 char
fields in your SQL table, it will have the same code 30 times, but with
different column names substituted in the appropriate places.
I haven't been really scoping this out as a generic tool, but I know that when I finish
I will have enough pieces to fit into almost any running java code that
I have worked with and turn it into a template.
XIV - Files and Jars used by JGuiGen
Property files (I18N) - in the /conf folder
JGuiGen WORKING TOOLS
FILES for POSTGRESQL DATABASE
pg_admin II.
XV. Java Web Start (JAWS)
Java Web Start is part of java 1.4 and up. This system allows
developers to put an full java application on a web site. Users click
on a special link and JAWS will check to see if they are running the
right version of Java, check to see if the current version of all the
jar files in the system are already on the local PC and download those
that are newer on the web site. In order for the jar files that are
downloaded to be accessed, the developer must sign the jars with a certificate. The
user must indicate that they accept the certificate before the jar will
be allowed read/write access to the local PC. This verification only
needs to be done once.
XVI. Linux Considerations
You may not be able to run Linux afterwards.
In this case, use the Red Hat Linux CD-ROM with boot: Linux rescue [root]# vi /etc/profile.d/java.sh
export NPX_PLUGIN_PATH=/usr/java/j2sdk1.4.1_10/jre/plugin/i386/ns4/
export PATH=$PATH:/usr/java/j2sdk1.4.1_10/bin/:/usr/java/j2skd1.r.1_02/jre/javaws
XVII. Running JUnit TestCase Suites
Part of the generation process automatically creates a JUnit (and
jfcUnit) test suite for each screen that is generated. These can be run
from a command prompt as java where the ??? is the same name you gave
the generated java class (e.g. UserLogData.java will have
UserLogDataTest.java as its testCase.) These don't seem to run well as
menu options inside a larger application.
XVIII. Replication - A General Purpose Replication System
XIX. HSQL - Special Considerations.
Managing the database - runUtil.bat and runUtil.sh
are a batch file and a script that runs the DataBaseManager supplied
with HSQL. jawsRunUtil.bat and jawsRunUtil.sh are
version that run in the folder that Java Web Start downloaded JGuiGen
into. Java Web Start automatically added "RM" to each jar, so the
"jaws*" versions look for the hsqldb.jar to be named RMhsqldb.jar.
You will need to open a command window, CD to the root folder where the
project is running (This will be "interesting" for the Java Web Start
versions - the path is under the C:\Program Files\ or your home folder,
but it is a long way down.)
Type jawsRunUtil DatabaseManager or ./jawsRunUitl.sh
DatabaseManager
This will bring up a screen that lets you choose the
type of HSQL database and point to the database you want to open.
1. Choose "Standalone" from the top combobox
2. Change
3. Press OK.
Database Access - a ready-to-run database is shipped with
JGuiGen. NOTE: By default JGuiGen uses the Standalone version
of the HSQL databases. This version will only allow
ONE application at a time to access the database. You
will need to make sure that there are no application
threads in your IDE that are still attached before you
can run the DatabaseManager. You must close it before
you can run JGuiGen. (In Eclipse this means going to the debug view and
highlighting a thread and pressing
the button with a red square to kill the threads and
then the stacked boxes button to remove them. You can also right click after you have left
clicked on one of the thread and choose the "TERMINATE and REMOVE" or "TERMINATE and REMOVE ALL" options.
Notes HSQL has a few quirks.