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 static java.util.Arrays.asList;
024    import java.util.Iterator;
025    import java.util.List;
026    import javax.swing.AbstractListModel;
027    
028    /** A PreferencesGroup is an ordered set of {@link Prefs}, for use with {@link PreferencesPane}.
029     * @author <a href="mailto:chris@riedquat.de">Christian Hujer</a>
030     */
031    public class PreferencesGroup extends AbstractListModel implements Iterable<Prefs> {
032    
033        /** The preferences modules.
034         * @serial include
035         */
036        private final List<Prefs> prefs;
037    
038        /** The preferences title.
039         * @serial include
040         */
041        private final String title;
042    
043        /** Create a Preferences group.
044         * @param prefs Preferences modules to initially add
045         * @param title Title for Preferences
046         */
047        public PreferencesGroup(final String title, final Prefs... prefs) {
048            this.title = title;
049            this.prefs = asList(prefs);
050        }
051    
052        /** Get the title.
053         * @return title
054         */
055        public String getTitle() {
056            return title;
057        }
058    
059        /** {@inheritDoc} */
060        public Iterator<Prefs> iterator() {
061            return prefs.iterator();
062        }
063    
064        /** {@inheritDoc} */
065        public int getSize() {
066            return prefs.size();
067        }
068    
069        /** {@inheritDoc} */
070        public Prefs getElementAt(final int index) {
071            return prefs.get(index);
072        }
073    
074    } // class PreferencesGroup