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.treetable;
022    
023    import javax.swing.tree.TreeModel;
024    import javax.swing.tree.TreePath;
025    import javax.swing.event.TreeModelListener;
026    import javax.swing.event.EventListenerList;
027    
028    /**
029     * TODO
030     * @author <a href="mailto:chris@riedquat.de">Christian Hujer</a>
031     */
032    public class TreeTableModelTreeModelAdapter<R, T> implements TreeModel {
033    
034        /** The Event listener list for registering TreeModelListeners. */
035        private final EventListenerList listenerList = new EventListenerList();
036    
037        /** The underlying TreeTableModel. */
038        private TreeTableModel<R, T> treeTableModel;
039    
040        public TreeTableModelTreeModelAdapter(final TreeTableModel<R, T> treeTableModel) {
041            this.treeTableModel = treeTableModel;
042        }
043    
044        /** {@inheritDoc} */
045        public Object getRoot() {
046            return treeTableModel.getRoot();
047        }
048    
049        /** {@inheritDoc} */
050        public Object getChild(final Object parent, final int index) {
051            return treeTableModel.getChild((T) parent, index);
052        }
053    
054        /** {@inheritDoc} */
055        public int getChildCount(final Object parent) {
056            return treeTableModel.getChildCount((T) parent);
057        }
058    
059        /** {@inheritDoc} */
060        public boolean isLeaf(final Object node) {
061            return treeTableModel.isLeaf((T) node);
062        }
063    
064        /** {@inheritDoc} */
065        public void valueForPathChanged(final TreePath path, final Object newValue) {
066        }
067    
068        /** {@inheritDoc} */
069        public int getIndexOfChild(final Object parent, final Object child) {
070            return 0;  //TODO
071        }
072    
073        /** {@inheritDoc} */
074        public void addTreeModelListener(final TreeModelListener l) {
075            //TODO
076        }
077    
078        /** {@inheritDoc} */
079        public void removeTreeModelListener(final TreeModelListener l) {
080            //TODO
081        }
082    
083    } // class TreeTableModelTreeModelAdapter