Model Class
[Previous] [Main] [Next]

Model CLASS



The Model.java file is part of the com.jguigen.standard package. It contains utilities can links the various GUIs being generated for an application together.

Here are the parts of the Model class with references to a sample of the actuall code.

Instantiation and Overview - Description of Model

Constructor - Constructor of Model class - This can be with a specified Locale or without.

Look for XML Ini file - Look for XML Ini file - Model looks first for the XML file containing setup information in c:\JGuiGen. If the file is not there, it looks in /usr/local/JGuiGen. If the file is not there it looks in the folder the application is running in. If the file still does not exist, it looks to see if the application is running from a JAR. If it is, it tries to unzip a copy from the jar into the folder where the application is running.

Note: At the same time if a DatabaseRM.jar exists, and there is no XML file, the system will attempt to unzip a copy of the HSQL database and the XML file that goes with it into the working folder.

Assuming the XML file is found, it is parsed and the values in it are stored in variables or arrays in Model.java.

The last line of the constructor calls the SetupHelp() method. This attempts to link to a JavaHelp file using a name obtained in the XML file.

getSecurity() - Description of Model - this method queries the userlogdata table and returns a row for the user who is trying to login if such a row exists.
   Note: This will return the "Active" row. Since this system uses inactive rows to store a users preferences on different PCs, a user could have several rows in this table. The system exits if a valid row for the user is not found. If a row is found several variables are set for this user.
   - the currentUser name
   - the date they last viewed the History.htm file
   - screen specific security for screens 0 - 10.
The system also updates several fields in the userlogdata table  
   - firstlogin date if it is empty
   - lastlogin date/time with the current time
- logFld - the current date/time is appended to a text field that contains a history of a users logins.  
   - lastloginTime - the current time.  
   - login_count - this is bumped by one for the current user.
NOTE: This routine can be bypassed if your system already has a login system. There is a setCurrentUser(String usr) method that can be called to set the current user name and a setViewHstoryDate(Date dt) routine that can be used to set the View History Date.  

Several Getter() methods - Several Getter() methods

·GetLogger() - get the current logger object so new log entries can be added to it.  
·getUpperAllowedInSql() - Some SQL backends do not allow "upper()" and "lower()" functions. These are usually already case insensitive. Other backend do allow them. These are often case sensitive. This value is set when the database type is determined and used by various methods that build SQL queries against a table in the SQL backend.  
·getDisplayAssistiveDemo() - This is logical variable set from a the XML file. If it is true a secondary screen is instanticated after your GUI is on the screen. As you mouse moves over the GUI, the second screen shows the Assistive Values of the components under the mouse.  
·getDbName() - getter() method to get the database name.(type of database). This returns "postgress" or "mysql" or "sql Server" etc.  
·getWorkingPath() - get method to get the path where the program is running  
·getCompanyName() - gets your company name from the XML file  
·getTestingId() - the TestCase program add a row and delete it from the table they are testing. This tells the system which ID number you have designated as this Testing Id number.  
·setTestingID() - allows you to set this number.  
·getLocalAdmin() - returns a name and phone number of the person users should call. This is taken from the XML file and is displayed in various error messages.  
·getLongProjectName() - The string is taken from the XML file.  
·getShortProjectName() - this is also taken from the XML file. This should be a one word name.  
·getPackageName() - this is taken from the XML file. It is the package name placed at the top of all files generated by JGuiGen.  
·getJDBCDriverName() - exact name of the JDBC driver that will be used to open the SQL backend.  
·setSecurityRights(int screenNumber, int rights) - you can use this to set an individuals rights to various screens if you are not using the JGuiGen provided getSecurityRights() method.  
Rights is an additive number
* 0 = view only
* 1 = add
* 2 = edit
* 3 = delete
* therefore 7 = view, add, edit , delete
* 8 = do not even show screen
·getSecurityRights(int screenNumber) - this gets the current users rights to a particular screen. The codes are the same as above.  
·getScreenRights() returns an array of screen names taken from the XML file.  
·getStateCodes() - the states used by the State JSearchableComboBox are stored in the XML file as a bar delimited string (e.g. |AR|AZ|..). This routine converts this string into an array and returns it.  
·getCompanyAddress1() - get your company address from the XML file  
·getCompanyAddress2() - get your company address from the XML file.  
·getCompanyCity() - get your company city from the XML file.  
·getCompanyZip() - get your company zip code from the XML file.  
·getCompanyPhone() - get your company phone number from the XML file  
·getCompanyLegalName1() - get a legal name from the XML file  
·getCompanyLegalName2() - get a legal name from the XML file  
·getCompanyBillingAddress1() - self evident  
·getCompanyBillingAddress2()  
·getCompanyBillingCity()  
·getCompanyBillingState()  
·getCompanyBillingZip()  
·getCompanyBillingPhone()  
·getSharedPath() - JGuiGen has a system where it looks for a copy of the XML file in a shared folder. Everyone gets the current copy from that folder if it is more recent than the one they are using.  
·setSharedPath() - establishes this path if you do not elect to get it from the XML file.  
·getIniPath() returns the folder where the XML INI file was found  
·setMyWpPath(String val) - set the path were the users Word Processor is found. This is used when a method want to run the users Word Processor to view/edit a file.  
·getMyWpPath() - gets the same path.  
·setMyBrowserPath() - set the path to the users broswer. This is used when a routine wants to run the users web browser to view a file.  
·getMyBrowserPath() - gets the same path.  
·getUser() - displays a list of users from the XML file and allows the user to pick one.  
·setCurrentUser(String user) - allows a developer to set the current user without using JGuiGens routines.  
·getCurrentUser() - return the login name of the current user. This is used to indicate who changed a row in a SQL table and used to log data.  
·getCurrentUserId() - return the ID number (primary key in userlogdata).  
·getCurrentLocale() - get the current locale  
·setCurrentLocale() - set the current locale  
·setViewHistoryDate(String dt) - set the date of the history.htm file the user last viewed  
·getCurrentAreaCode() - obtained from the XML file and can be used to set default phone numbers to the current area code.  
·getCurrentState() - obtained from the XML file.  
·getAllCurrentUser() - returns an array of user login names obtained from the XML file.  
·getKTextArea() - returns the textarea in the console set up by DBMaster.class.  
·getConnectionSuccess() - returns a true/false determined by the try for a connection.  


getConnectionObj - getConnectionObj - this method uses the JDBC driver name, the account name, account password and url taken from the XML file or accessing LDAP and encrypted files to open the SQL backend.

getDBConnectionObj()
- method return the object created in the method above.

getDatabaseMetaData() - returns an object containing the metadata for the tables.

getDataDictionaryTableModel()
- returns an object containing a reference to the AbstractTableModel used for the data_dict table. This Table model is still in the Model.java file

Several Utility Methods - Several Utility methods

·showErrorOccurred() - this pops-up a screen in the up right cornoer of the users screen. A button must be pressed to get rid of this screen. It contains the adminName/phoen from the XML file and an instruction to check the LOG screen - an error (usually SQL) has occurred.  
·showWarningOccurred() - this is similar to the last one. However this screen goes aways by itself after 10 seconds. This is for wornings instead of serious errors.  
·getRbString(resource bundle, string, className) - this is wrapper for the standard resource bundle getString. If the phrase cannont be found a woardning is displayed and the calling string is returned with [* *] around it. This is better than the null pointerexception that the regular getString ends you application with.  
·getShortTo4() - converts the "yy" portion of a date format to "yyyy"  
·propagateFont( Container parentComponent, Font font) - changes the font of every component in a container - recursively.  
·setUpHelp() - instanticates a HELP object that can be called to pop-up a help screen. This is internationalized. It will look for a history file in folders like history_en_US and history_en, or histoory_es_MX and history_es depending upon the locale the application is set to.  
·getImageIcon() - similar to the SetIcon static class. For use when that class can't be used.  
·getHTMLHead(String title) - returns the code for a standard HTML header.  
·rtrim(String str) - returns a string with trailing blanks trimmed off.  
·chkNumbers(String str) - checks that a field continas only numerical values.  
·PhoneRegEx(JFormattedTextField fld) - sets the formatting of a JFormattedTextfield to phone  
·txtEmailRegEx(JFormattedTextField fld) - sets the formatting of a JFormattedTextfield to email  
·txtIpAddresRegEx(JFormattedTextField fld) - sets the formatting of a JFormattedTextfield to IP Address  
·TimeRegEx(JFormattedTextField fld) - sets the formatting of a JFormattedTextfield to time  
·TimeRegExNow(JFormattedTextField fld) - sets the formatting of a JFormattedTextfield to time - using now() as a starting point.  
·addBs(String) - adds a backslash to a string if there is not already one there.  
·getOnlyTimeNow() - return just the time portion of now()  
·getToday() - returns a date with now()  
·replace( String, String) - a general routines used before straint.replaceAll() was added to java  
·proper(String) - returns first letter as upperCase and all others a lowercase()  
·capFirst(String) - just makes sure the first character is upperCase. All others are left alone.  
·lowerFirst(String) - just makes sure the first character is lowerCase.  
·QuoteReplacer(String) - makes sure any single quote marks are returns as two single quote marks together.  
·setJTextArea(testarea) - used to connect each class to the console created by DBMaster.class.  
 
 



AbstractTableModel for data_dict table - AbstractTableModel for data_dict table -
- this contains methods like tableQuery(), tableInsert(), getValueAt(), etc. This is modeled after Duke's Bakery.

Main Cleanup() - Main CleanUp()
- this closes all tables. This is also PLACE6 where you are instructed to place snippets of cleanup() code from each GUI generated by JGuiGen.

closeConnection() -
closes the DBMaster