001    package sale;
002    
003    import java.io.*;
004    
005    /**
006     * Helper class that creates the contents of a {@link FormSheet}.
007     *
008     * <p>A FormSheetContentsCreator is used by FormSheets to create their contents, i.e. to set their component
009     * and the buttons in the FormSheet's button bar. Objectifying this process is needed to make FormSheets
010     * persistent as the Swing components' serializability is not reliable. Therefore, whenever you create a
011     * serializable FormSheet, use FormSheetContentsCreators.</p>
012     *
013     * @see FormSheet#addContentCreator
014     *
015     * @author Steffen Zschaler
016     * @version 2.0 17/08/1999
017     * @since v2.0
018     */
019    public abstract class FormSheetContentCreator extends Object implements Serializable {
020    
021        /**
022         * The parent of this FormSheetContentCreator. The parent of a FormSheetContentCreator is the
023         * FormSheetContentCreator that was added to the FormSheet immediately before this FormSheetContentCreator.
024         *
025         * @serial
026         */
027        private FormSheetContentCreator m_fsccParent;
028    
029        /**
030         * Create the FormSheet's contents.
031         *
032         * <p>This method is called in the following circumstances:</p>
033         *
034         * <ol>
035         *   <li>On creation of the FormSheet object.</li>
036         *   <li>Whenever the FormSheet gets deserialized from a stream.</li>
037         * </ol>
038         *
039         * <p>Although the FormSheet whose contents is to be set is passed as a parameter, a new instance of the
040         * FormSheetContentCreator is needed with every new instance of the FormSheet!</p>
041         *
042         * @override Always
043         *
044         * @param fs the FormSheet whose contents is to be created.
045         */
046        protected abstract void createFormSheetContent(FormSheet fs);
047    
048        /**
049         * Internal communication method called by FormSheet.
050         *
051         * @override Never
052         *
053         * @param fs the FormSheet that needs to be set up.
054         * @param fCallParent if true, the entire chain of FormSheetContentCreators will be called.
055         */
056        void createFormSheetContent(FormSheet fs, boolean fCallParent) {
057            if ((fCallParent) && (m_fsccParent != null)) {
058                m_fsccParent.createFormSheetContent(fs, true);
059            }
060            createFormSheetContent(fs);
061        }
062    
063        /**
064         * Internal communication method called by FormSheet.
065         *
066         * @override Never
067         *
068         * @param fsccParent the new parent of this FormSheetContentCreator
069         */
070        void setParent(FormSheetContentCreator fsccParent) {
071            m_fsccParent = fsccParent;
072        }
073    }