001    /* JAPI - (Yet anothr (hopefully) useful) Java API
002     *
003     * Copyright (C) 2004-2006 Christian Hujer
004     *
005     * This program is free software; you can redistribute it and/or
006     * modify it under the terms of the GNU General Public License as
007     * published by the Free Software Foundation; either version 2 of the
008     * License, or (at your option) any later version.
009     *
010     * This program is distributed in the hope that it will be useful, but
011     * WITHOUT ANY WARRANTY; without even the implied warranty of
012     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013     * General Public License for more details.
014     *
015     * You should have received a copy of the GNU General Public License
016     * along with this program; if not, write to the Free Software
017     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
018     * 02111-1307, USA.
019     */
020    
021    package net.sf.japi.swing.prefs;
022    
023    import java.net.URL;
024    import javax.swing.Icon;
025    import javax.swing.JComponent;
026    import javax.swing.JPanel;
027    import javax.swing.BoxLayout;
028    
029    /** Abstract preferences implementation.
030     * Subclass this.
031     * Build the panel in your constructor.
032     * The default layout of an AbstractPrefs is {@link BoxLayout} with {@link BoxLayout#Y_AXIS}.
033     * @author <a href="mailto:Christian.Hujer@itcqis.com">Christian Hujer</a>
034     */
035    public abstract class AbstractPrefs extends JPanel implements Prefs {
036    
037        /** The icon to be displayed in the list where the user can choose amongst preferences.
038         * @see #getListLabelIcon()
039         * @serial include
040         */
041        private Icon listLabelIcon;
042    
043        /** The label text to be displayed in the list where the user can choose amongst preferences.
044         * @see #getListLabelText()
045         * @serial include
046         */
047        private String listLabelText;
048    
049        /** The title text to be displayed as title for this prefs module.
050         * @see #getLabelText()
051         * @serial include
052         */
053        private String labelText;
054    
055        /** The Help URL.
056         * @serial include
057         */
058        private URL helpURL;
059    
060        /** The Help text (HTML).
061         * @serial include
062         */
063        private String helpText;
064    
065        /** Constructor. */
066        protected AbstractPrefs() {
067            setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
068        }
069    
070        /** {@inheritDoc} */
071        public final JComponent getEditComponent() {
072            return this;
073        }
074    
075        /** {@inheritDoc} */
076        public final Icon getListLabelIcon() {
077            return listLabelIcon;
078        }
079    
080        /** Set the icon that is to be displayed in the list where the user can choose amongst preferences.
081         * @param listLabelIcon icon
082         */
083        protected final void setListLabelIcon(final Icon listLabelIcon) {
084            this.listLabelIcon = listLabelIcon;
085        }
086    
087        /** {@inheritDoc} */
088        public final String getListLabelText() {
089            return listLabelText;
090        }
091    
092        /** Set the label text that is to be displayed in the list where the user can choose amongst preferences.
093         * @param listLabelText text
094         */
095        protected final void setListLabelText(final String listLabelText) {
096            this.listLabelText = listLabelText;
097        }
098    
099        /** {@inheritDoc} */
100        public final String getLabelText() {
101            return labelText;
102        }
103    
104        /** Set the title text that is to be displayed as title for this prefs module.
105         * @param labelText text
106         */
107        protected final void setLabelText(final String labelText) {
108            this.labelText = labelText;
109        }
110    
111        /** {@inheritDoc} */
112        public final URL getHelpURL() {
113            return helpURL;
114        }
115    
116        /** Set the help URL.
117         * @param helpURL Help URL
118         */
119        protected final void setHelpURL(final URL helpURL) {
120            this.helpURL = helpURL;
121        }
122    
123        /** {@inheritDoc} */
124        public final String getHelpText() {
125            return helpText;
126        }
127    
128        /** Set the help text.
129         * @param helpText Help text
130         */
131        protected final void setHelpText(final String helpText) {
132            this.helpText = helpText;
133        }
134    
135    } // class AbstractPrefs