001    /* JAPI - (Yet another (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 java.awt.LayoutManager;
025    import javax.swing.Icon;
026    import javax.swing.JComponent;
027    import javax.swing.JPanel;
028    import javax.swing.BoxLayout;
029    import net.sf.japi.swing.ColumnLayout;
030    
031    /** Abstract preferences implementation.
032     * Subclass this.
033     * Build the panel in your constructor.
034     * The default layout of an AbstractPrefs is {@link BoxLayout} with {@link BoxLayout#Y_AXIS}.
035     * @author <a href="mailto:chris@riedquat.de">Christian Hujer</a>
036     */
037    public abstract class AbstractPrefs extends JPanel implements Prefs {
038    
039        /** The icon to be displayed in the list where the user can choose amongst preferences.
040         * @see #getListLabelIcon()
041         * @serial include
042         */
043        private Icon listLabelIcon;
044    
045        /** The label text to be displayed in the list where the user can choose amongst preferences.
046         * @see #getListLabelText()
047         * @serial include
048         */
049        private String listLabelText;
050    
051        /** The title text to be displayed as title for this prefs module.
052         * @see #getLabelText()
053         * @serial include
054         */
055        private String labelText;
056    
057        /** The Help URL.
058         * @serial include
059         */
060        private URL helpURL;
061    
062        /** The Help text (HTML).
063         * @serial include
064         */
065        private String helpText;
066    
067        /** Constructor. */
068        protected AbstractPrefs() {
069            super(new ColumnLayout());
070            // setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
071        }
072    
073        /** Constructor that allows setting the initial layout.
074         * @param layout Layout
075         */
076        protected AbstractPrefs(final LayoutManager layout) {
077            super(layout);
078        }
079    
080        /** {@inheritDoc} */
081        public final JComponent getEditComponent() {
082            return this;
083        }
084    
085        /** {@inheritDoc} */
086        public final Icon getListLabelIcon() {
087            return listLabelIcon;
088        }
089    
090        /** Set the icon that is to be displayed in the list where the user can choose amongst preferences.
091         * @param listLabelIcon icon
092         */
093        protected final void setListLabelIcon(final Icon listLabelIcon) {
094            this.listLabelIcon = listLabelIcon;
095        }
096    
097        /** {@inheritDoc} */
098        public final String getListLabelText() {
099            return listLabelText;
100        }
101    
102        /** Set the label text that is to be displayed in the list where the user can choose amongst preferences.
103         * @param listLabelText text
104         */
105        protected final void setListLabelText(final String listLabelText) {
106            this.listLabelText = listLabelText;
107        }
108    
109        /** {@inheritDoc} */
110        public final String getLabelText() {
111            return labelText;
112        }
113    
114        /** Set the title text that is to be displayed as title for this prefs module.
115         * @param labelText text
116         */
117        protected final void setLabelText(final String labelText) {
118            this.labelText = labelText;
119        }
120    
121        /** {@inheritDoc} */
122        public final URL getHelpURL() {
123            return helpURL;
124        }
125    
126        /** Set the help URL.
127         * @param helpURL Help URL
128         */
129        protected final void setHelpURL(final URL helpURL) {
130            this.helpURL = helpURL;
131        }
132    
133        /** {@inheritDoc} */
134        public final String getHelpText() {
135            return helpText;
136        }
137    
138        /** Set the help text.
139         * @param helpText Help text
140         */
141        protected final void setHelpText(final String helpText) {
142            this.helpText = helpText;
143        }
144    
145    } // class AbstractPrefs