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.keys;
022    
023    import java.util.List;
024    import net.sf.japi.swing.ActionFactory;
025    import net.sf.japi.swing.treetable.AbstractTreeTableModel;
026    import net.sf.japi.swing.treetable.TreeTableModel;
027    
028    /**
029     * TODO
030     * @author <a href="mailto:chris@itcqis.com">Christian Hujer</a>
031     */
032    public class KeyStrokeTreeTableModel extends AbstractTreeTableModel<KeyStrokeRootNode, AbstractSimpleNode<AbstractSimpleNode>> {
033    
034        /** Create a KeyStrokeTreeTableModel. */
035        public KeyStrokeTreeTableModel(final List<ActionFactory> factories) {
036            super(new KeyStrokeRootNode(factories));
037        }
038    
039        /** {@inheritDoc} */
040        public AbstractSimpleNode<AbstractSimpleNode> getChild(final AbstractSimpleNode<AbstractSimpleNode> parent, final int index) {
041            //noinspection unchecked
042            return (AbstractSimpleNode<AbstractSimpleNode>) parent.getChild(index);
043        }
044    
045        /** {@inheritDoc} */
046        public int getChildCount(final AbstractSimpleNode<AbstractSimpleNode> node) {
047            return node.getChildCount();
048        }
049    
050        /** {@inheritDoc} */
051        public int getColumnCount() {
052            return 2;
053        }
054    
055        /** {@inheritDoc} */
056        public String getColumnName(final int column) {
057            return new String[] {"col1", "col2"}[column];
058        }
059    
060        /** {@inheritDoc} */
061        public Object getValueAt(final AbstractSimpleNode<AbstractSimpleNode> node, final int column) {
062            return node.getValueAt(column);
063        }
064    
065        /** {@inheritDoc} */
066        @Override public Class<?> getColumnClass(final int column) {
067            return new Class[] { TreeTableModel.class, String.class}[column];
068        }
069    
070    } // class KeyStrokeTreeTableModel