com.jFormTK
Class JFormState

java.lang.Object
  extended by com.jFormTK.JFormState
All Implemented Interfaces:
JConstants

public class JFormState
extends java.lang.Object
implements JConstants

        There is an instance of this Class for each 'JFormForm' Sub-Class in an 'jFormTK'
        Application. The instance is produced by the 'JFormForm' Super-Class as each
        'JFormForm' Sub-Class is loaded into the AppForms Class.
 
        As the Application End User enter data into the Application Forms the associated
        JFormState parameters are set so that the "State" of each Form is available when
        the Form is Saved or reloded.

        There is a JCouple instance for each 'JFormForm' SubClass Application form.
        This is necessary so that there is no restriction on unloading a form while
        executing a "Load couple" LOOP...
        

Version:
1.00, 11 Dec 1999
Author:
Jim Crowell
Professional Computer Solutions [PCS]
URL: http://jFormTK.com/
E-Mail: JimCrowell@EMail.com

Copyright (c) 2009 by Professional Computer Solutions [PCS]
All Rights Reserved

Field Summary
 
Fields inherited from interface com.jFormTK.JConstants
__, _AB, _AB_, _AField, _B, _BField, _CField, _CIField, _DField, _EU_, _H, _HEIGHT, _HEIGHT_INV, _HField, _I, _IField, _LField, _MField, _NField, _NotRequired, _PField, _PIField, _QField, _Required, _RField, _TAField, _TField, _WIDTH, _WIDTH_INV, _XField, AB, APP_TRACE_FOCUS, APP_TRACE_GET, APP_TRACE_SET, B_, BAR, BAR_, BB, BH, BI, BREAKPOINT_FOCUS, BREAKPOINT_GET, BREAKPOINT_SET, BVB, C_QUOTE, CLOSE, CLOSE_BRACKET, COLORS_DELIMITER, COMMA, COMMA_, D_ELEMENT, D_ELEMENT_N, D_ELEMENT_N1, D_ELEMENT_N2, D_ELEMENT_N3, D_FIELDS, D_FIELDS_N, D_FIELDS_N1, D_FIELDS_N2, D_FIELDS_N3, D_ITEMS, DASH, DOT, EOL, EOP, EOS, FIELD_TRACE_FOCUS, FIELD_TRACE_GET, FIELD_TRACE_SET, FONT_DELIMITER, H_, HB, HH, HI, I_, IB, IH, II, JLAF_DELIMITER, LF, LISTBRACKET, NO, OPEN, OPEN_BRACKET, pCheckboxGroup, QUOTE, SPACE_, TAB, YES
 
Constructor Summary
JFormState(JFormForm parent)
           Constructor used when this Form is initialized, that is the first time this 'JFormForm' Super-Class is instanced by the 'AppForm' Class...
 
Method Summary
 void addToFocusTrace(java.lang.String newID)
           Add the given 'JFormField' ID to the current 'focusTrace' String.
 JFormField getCurrentJFormField(java.lang.String from)
           Get a Reference to the current 'JFormField'...
 java.lang.String getFocusTrace()
           Return the current 'focusTrace' JFormState parameter, that is the String that contains the 'ID' fields of each 'JFormField' that received Focus while the 'jFormTK' Kernel "Focus Trace" feature was active.
 JCouple getJCouple()
           Return the 'JCouple' instance held by this 'JFormState' Class...
 char getLoadState()
           Get the 'loadState' JFormState parameter...
 java.lang.String getParentJFormFormID()
           
 JFormField getPreviousFocus()
           Return a "Reference" to the Previously Focused 'JFormField'...
 int getPreviousFormIndex()
           Get the Previous Form Order Index...
 boolean isFile()
           Get the JFormState 'isFile' Flag, i.
 boolean isFile(java.lang.String category, java.lang.String fileName)
           Get the JFormState 'isFile' Flag, i.
 boolean isSaved()
           Return the 'isSaved' JFormState Flag.
 boolean JFormFieldCompare(JFormField fld)
           Compare the given 'JFormField' [fld] with the last Focused 'JFormField'...
 void loadJFormState(java.lang.String savedJFormState, java.lang.String from)
           Load the parameters of '*this*.JFormState' instance from the given Saved JFormState String...
 void setCurrentJFormField(JFormField fld, java.lang.String from)
           Set the '*this*.JFormState.currentJFormField' parameter...
 void setFocusTrace(java.lang.String traceString)
           Set the '*this*.JFormState.focusTrace' String...
 void setIsFile(boolean flag)
           Set the '*this*.JFormState.isFile' Flag...
 void setIsSaved(boolean flag, java.lang.String from)
           Set the '*this*.isSaved' Flag...
 void setJCouple(JCouple c)
           Set the 'JCouple' instance...
 void setLoadState(char flag, java.lang.String from)
           Set the '*this*.loadState' Control...
 void setPreviousFocus(JFormField fld)
           Set the '*this*.previousFocus' parameter to the given 'JFormField' [fld]...
 void setPreviousFormIndex(int iPreviousFormIndex)
           Set '*this*.JFormState.previousFormIndex' parameter...
 void showSTATE(java.lang.String from)
           This method is a "DEBUG' method to display the current "State" of a 'jFormFrom'...
 java.lang.String toString()
           This method is designed to create the 'saveJFormState' data in a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JFormState

public JFormState(JFormForm parent)
        Constructor used when this Form is initialized, that is the first time this
        'JFormForm' Super-Class is instanced by the 'AppForm' Class...

Parameters:
parent - 'JFormForm' Sub-Class that will hot this JFormState instance.
Method Detail

addToFocusTrace

public void addToFocusTrace(java.lang.String newID)
        Add the given 'JFormField' ID to the current 'focusTrace' String. A line feed
        [LF] is used as a 'prefix' so that each new ID will appear on a new line when
        displayed...
 
        Kernel Usage:
        1)      'JFocus.doFocus.focusJFormField' Method when a focus 'JFormField' request
                is about to be enforced and the state of the 'FormForm' Focus Trace Flag
                [controlled by Alt/F10 keys] is true...
        

Parameters:
newID - New 'JFormField' ID to be added to the 'jFormTK' Focus Trace String...

getCurrentJFormField

public JFormField getCurrentJFormField(java.lang.String from)
        Get a Reference to the current 'JFormField'...
 
        Kernel Usage:
        1)      This method is used liberally throughout the 'jFormTK' Kernel when
                controlling what 'JFormField' has or shall have the Focus in the
                'jFormTK' Show Panel....
    
        

Parameters:
from - DEBUG String to annotate where this method cas envoked....
Returns:
The Current 'JFormField' "Reference"...

getFocusTrace

public java.lang.String getFocusTrace()
        Return the current 'focusTrace' JFormState parameter, that is the String that
        contains the 'ID' fields of each 'JFormField' that received Focus while the
        'jFormTK' Kernel "Focus Trace" feature was active.

        Kernel Usage:
        1)      Not currently used...
        

Returns:
'focusTrac' JFormState.java Parameter[String]...

getJCouple

public JCouple getJCouple()
        Return the 'JCouple' instance held by this 'JFormState' Class...

        Kernel Usage:
        1)      Used in all 'JFormForm' SubClass forms that require the 'jFormTK' "Couple'
                processing...
        

Returns:
Hosted 'JCouple' instance...

getLoadState

public char getLoadState()
        Get the 'loadState' JFormState parameter...
 
        NOTE:
        'loadState indicates the current load State of *this* 'JFormForm as Follows:   
        Each 'JFormForm' Sub-Class instance shall host a 'JFormData' Vector.
        This Vector contains a 'savedJFormField' String for each 'JFormField' of the
        'JFormForm' Sub-Class Application Form.
 
        NOTE:
        A 'savedJFormField' String contains all the 'JFormField' parameters that are
        required to build a 'JFormField'. It is built by the JFormField.toString' Method
        and used to construct a 'JFormField' instance
        [via the JFormField(SavedJFormField) Constructor]...
        Also, the 'savedJFormData' String is used by the 'data' 'jFormTK' Class to
        return specific parameters without constructing a 'JFormField' instance...

        The "state" of this 'JFormForm' is a function of 'loadState' Control as follows:
        loadState       |       Description
                'N'             |       "Not Loaded State" - The 'JFormForm' has never been loaded,
                                |       i.e. the 'init' Method has not been used to create a 'JFormData'
                                |       Vector...
                'D'             |       "Data Request State" - The 'JFormData' Vector exist and shall be
                                |       loaded from the storage device whenever the associated
                                |       'JFormForm' is requested by the End User...
                'U'             |       "Data Request State" with some fields having been modified in
                                |       the 'SavedJFormField' String since the last Save,
                                |       i.e. 'jFormTK.JHDD_IO.writeToFile' deployment...
                'A'             |       This 'JFormForm' exist in the 'JFormFrame.ShowPanel',
                                |       i.e. it is the "Active" 'JFormForm' Sub-Class. Any reference to
                                |       JFormField's while in this state are made to the current
                                |       'Components' of the 'JFormFrame.ShowPanel'...
        NOTE:
        The 'insert' and 'remove' operations are made to the 'jFormFrame.ShowPanel'
        components iff the 'loadState' is 'A'. The 'Row' Numbers during the 'A' load
        state are not to be used since they are NOT maintained as the JFormField's are
        inserted or removed from the "ordered" 'jFormFrame.ShowPanel' Components list. 

        When the current 'jFormFrame' is saved to the storage device, the row numbers
        are updated prior to producing the new 'savedJFormData' Strings...

        This Control is set to 'N' in the JFormState Constructor. It is set to 'D' when
        the 'JFormData' Vector is created by the 'JFormForm' 'init' Override method of
        each Application Form...

        When the Application End User request a 'JFormForm' for display, the '.showPage'
        method constructs 'JFormField' instances from each 'savedJFormField' String and
        loads it into the 'jFormFrame.ShowPanel' components list. The *this* loadState
        is set to 'A' at this time.

        When the end user selects a different 'JFormForm' OR quits the Application,
        the 'JFormFrame.getJFormData' Method converts the JFormField's of the
        'JFormFrame.ShowPanel' to the 'JFormData' Vector and set the *this* 
        loadState to 'D'...

        Kernel Usage:
        1)      This method is used throughout the 'jFormTK' Kernel when a difference
                'JFormForm' Sub-Class Form is requested by the 'jFormTK' Application End
                User.
        

Returns:
Current 'loadState' [char]

getParentJFormFormID

public java.lang.String getParentJFormFormID()
Returns:
'parent 'JFormForm' ID' JFormState.java Parameter[String]...

getPreviousFocus

public JFormField getPreviousFocus()
        Return a "Reference" to the Previously Focused 'JFormField'...
 
        Holds the 'currentJFormField' Reference at the time the 'setCurrentJFormField'
        is used to adjust the Focused 'JFormField' State...
 
        Kernel Usage:
        1)      'JFocus.setUnselectedLAF' Method to unselect the previous 'JFormField' insxtance...
        

Returns:
'previousFocus' JFormState.java Parameter[JFormField]...

getPreviousFormIndex

public int getPreviousFormIndex()
        Get the Previous Form Order Index...
 
        Kernel Usage:
        1)      This method is used by the 'jFormTK.ApppForms.loadJFormForm [4]' Method
        to set the "Tool Tip" for the Previous 'JFormField' 'Forms' TAB previous 
                Form Button...
        2)      'JFormFrame.doPriorForm' Method...
        

Returns:
'previousFormOrder' JFormState.java Paramete [int]...

isFile

public boolean isFile()
        Get the JFormState 'isFile' Flag, i. e. the flag that indicates if
        '*this.JFormState' has an existing HDD file.

        Kernel Usage:
        1)      Various classes to determine if the 'JFormForm' Sub-Class has been
                previously loaded by the Application End User......
        

Returns:
'isFile' JFormState.java Parameter[boolean]...

isFile

public boolean isFile(java.lang.String category,
                      java.lang.String fileName)
        Get the JFormState 'isFile' Flag, i. e. the flag that indicates if
        '*this.JFormState' has an existing HDD file.

        Kernel Usage:
        1)      Various classes to determine if the 'JFormForm' Sub-Class has been
                previously loaded by the Application End User......
 

Parameters:
category - Category [String]
fileName - File Name [String]
Returns:
'isFile' JFormState.java Parameter[boolean]...

isSaved

public boolean isSaved()
        Return the 'isSaved' JFormState Flag.
 
        Note:
        This flag is initialized in the *this* Constructor as a function of the
        AppDB. parameter and the Category" and "FileName" field of
        *this* Object.

        During 'run-time', as the JFormState parent 'JFormForm' Sub-Class is "Saved",
        this flag is set by the 'jFormTK.JHDD_IO.writeToFile method. This is done as a
        function of the 'jFormFrame' "Save" or "Quit" Button usage...
 
        This flag [isSaved] is cleared by the 'jFormTK' Application as the End User
        makes changes to any 'JFormField' to ensure that the 'JFormForm' Sub-Class Form
        is saved properly...
 
        Kernel Usage:
        1)      'BasejFormTK.doExitApplication' method to determine if the 'JFormForm'
                Sub-Class is unloaded needs to be saved. If so, then the End User is
                provided options to control the Save, No-Save and Revert options...
        2)      'JFormFrame.verifyForm' Method to determine if the 'JFormForm' Sub-Class
                to be removed from the 'Show Panel' needs to be saved to the storage device...
        ?)      Used by 'jFormTK.JFormFrame.doQuit' Method to determine if the End User has
                requested a 'Quit' but has not Saved the associated 'JFormForm' Sub-Class...
        ?)      Used by the 'jFormTK.BasejFormTK.doExitApplication' Method to determine if
                an 'Exit' Application request has been made with one or more 'Open'
                'JFormForm' instances, i.e. JFormForm Sub-Class's that have not been saved
                since it was modified by the 'jFormTK' Application End User or a Dynamic
                Referencing Run-Time process...
        

Returns:
'isSaved' JFormState.java Parameter[boolean]...

JFormFieldCompare

public boolean JFormFieldCompare(JFormField fld)
        Compare the given 'JFormField' [fld] with the last Focused 'JFormField'...

        Kernel Usage:
        1)      Not currently used by the 'jFormTK' Kernel...
        

Parameters:
fld - 'JFormField' to compare...
Returns:
Flag [boolean] as a function of the compare...

setCurrentJFormField

public void setCurrentJFormField(JFormField fld,
                                 java.lang.String from)
        Set the '*this*.JFormState.currentJFormField' parameter...
 
        Kernel Usage:
        1)      Used by the 'jFormTK' Kernel whenever a 'JFormField' receives the Focus
                in the 'jFormTK' Show Panel...
 

Parameters:
fld - 'JFormField' that has the focus...
from - DEBUG annotation of the calling 'jFormTK' Method...

setFocusTrace

public void setFocusTrace(java.lang.String traceString)
        Set the '*this*.JFormState.focusTrace' String...
 
        Kernel Usage:
        1)      Currently NOT USED by the 'jFormTK' Kernel...
        XXX     Currently this method is used exclusively to clear the current 'focusTrace'
                String by the 'BasejFormTK' Class Menu option.
                See the '*this*.addToFocusTrace' method to see how the 'JFormField' ID for
                each Focus Event is accomplished... 
        

Parameters:
traceString - String with the Focused 'JFormField' ID...

loadJFormState

public void loadJFormState(java.lang.String savedJFormState,
                           java.lang.String from)
        Load the parameters of '*this*.JFormState' instance from the given Saved
        JFormState String...
 
        Kernel Usage:
        1)      This method is envoked by the 'JFormForm' Super-Class when the 'JFormForm'
                Sub-Class File is found in the 'jFormTK' Application Folder.
        

Parameters:
savedJFormState - Saved JFormState String created by the JFormState.toString method...
from - DEBUG annotation of the calling Class / Method...

setIsFile

public void setIsFile(boolean flag)
        Set the '*this*.JFormState.isFile' Flag...

        Kernel Usage:
        1)      'JFormFrame.loadFormFieldsVector' Method when a new 'JFormForm' Sub-Class
                is loaded into the 'jFormTK' Show Panel...
        2)      'JHDD_IO.writeToFile' when a 'JF0ormFrm' Sub-Class is saved to the HDD...
        

Parameters:
flag - Flag [boolean] to set the 'isFile' parameter...

setIsSaved

public void setIsSaved(boolean flag,
                       java.lang.String from)
        Set the '*this*.isSaved' Flag...
 
        Kernel Usage:
        This flag is initialized in the *this* Constructor as a function of the
        AppDB. parameter and the Category" and "FileName" field of
        *this* 'JFormState' instance...

        During 'run-time', as the JFormState parent 'JFormForm' Sub-Class is "Saved",
        this flag is set by the 'jFormTK.JHDD_IO.writeToFile method. This is done as a
        function of the 'jFormFrame' "Save" or "Quit" Button usage...
 
        This flag [isSaved] is cleared by the 'jFormTK' Kernel as the End User makes
        changes to any 'JFormField' to ensure that the 'JFormForm' Sub-Class Form is
        saved properly, i.e. is is written to the storage device after a "Quit" OR
        "UnLoad" operation is performed...

        Kernel Usage:
        1)      'AppForms.loadJFormForm' to set the flag after a 'JFormForm' Sub-Class is
                loaded into the 'jFormTK' Show Panel...
        2)      'JFormField.setText' Method iff the 'JFormField' is a '_TField' and the
                text is adjusted as a funcion of a <...> indirect references usage...
                NOTE:   ???How is this different than using the 'setReference' op???
        3)      'JFormForm.deleteGroup' when a Group has been removed from the 'Show Panel'...
        4)      'JHDD_IO.writeToFile' when a 'JFormForm' Sub-Class is written to the
                storage device...
        5)      'NotePad.savedNotePad' Method when the NotePad holder is modified...
        6)      'JFocus.doFocus' Method when the last Focused 'JFormField' instance and the
                current 'JFormField' instance are the same but the Text Values do not
                match...
        ?)      REMOVED after coding 6) above in the "JFocus' Class...  
                'JFormField.doPostProcess' Method to clear the flag prior to performing a
                Post Processor request.
                NOTE:   the postProcessor Flag is true BUT there is no assurance that the
                                'JFormForm' Sub-Class Saved state shall be modified.
                                ??? Is there a better place to clear the 'isSaved' Flag???

        

Parameters:
flag - Flag [boolean] to set the 'isSaved' JFormState Flag...

setJCouple

public void setJCouple(JCouple c)
        Set the 'JCouple' instance...

        Kernel Usage:
        1)      TBD
        

Parameters:
c -

setLoadState

public void setLoadState(char flag,
                         java.lang.String from)
        Set the '*this*.loadState' Control...
 
        See the 'getLoadState' JavaDoc...
        

Parameters:
flag - Code [char] to set the 'loadState'...
from - DEBUG annotation of invoking Class.Method...

setPreviousFocus

public void setPreviousFocus(JFormField fld)
        Set the '*this*.previousFocus' parameter to the given 'JFormField' [fld]...
 
        Kernel Usage:
        1)      'JFocus.FocusState.mouseFocus' Method when a mouse selection changes the
                normal 'jFormTK' Application Form Flow...
        1)      'jFormFrame.setFocusFields' Method [NOT Currently Used]...
        

Parameters:
fld - Previous Focus 'JFormField'...

setPreviousFormIndex

public void setPreviousFormIndex(int iPreviousFormIndex)
        Set '*this*.JFormState.previousFormIndex' parameter...
 
        Kernel Usage:
        1)      This method is used by the 'AppForms.loadJFormForm [4]' Method after a new
                'JFormForm' has been loaded into the 'jFormTK' Show Panel...   
        

Parameters:
iPreviousFormIndex - Previous 'JFormForm' index [int]

showSTATE

public void showSTATE(java.lang.String from)
        This method is a "DEBUG' method to display the current "State" of a 'jFormFrom'...
 
        NOTE:
        1)      If the 'previous Form Order is NOT Null, i.e. not = -1,
                Then display the Form Order Index followed by the previous JFormForm's ID 
                enclosed in brackets...
        

Parameters:
from -

toString

public java.lang.String toString()
 
        This method is designed to create the 'saveJFormState' data in a String.
        This data can then be used to re-load the JFormState when the 'JFormForm'
        Sub-Class file exist in the 'jFormTK' Application Folder...

        NOTE:
        Only the 'isFile', currentJFormField and JCouple objects are saved and
        reloaded...
 
        Kernel Usage:
        1)      Used by the 'jFormTK' Util.writeToFile Method to construct the
                'saveJFormState' String that is placed in Element 0 of the jFormFrame
                'JFormData' Vector. This vector is subsequently written to the
                'Category.FileName file on the storage device.

Overrides:
toString in class java.lang.Object