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.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@riedquat.de">Christian Hujer</a> 031 */ 032 public class KeyStrokeTreeTableModel extends AbstractTreeTableModel<KeyStrokeRootNode, AbstractSimpleNode<AbstractSimpleNode>> { 033 034 /** Action Factory. */ 035 private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.japi.swing.prefs.keys"); 036 037 /** Column names. */ 038 private static final String[] COLUMN_NAMES = { 039 ACTION_FACTORY.getString("keystroke.table.column.action.title"), 040 ACTION_FACTORY.getString("keystroke.table.column.keystroke.title"), 041 }; 042 043 /** Create a KeyStrokeTreeTableModel. */ 044 public KeyStrokeTreeTableModel(final List<ActionFactory> factories) { 045 super(new KeyStrokeRootNode(factories)); 046 } 047 048 /** {@inheritDoc} */ 049 public AbstractSimpleNode<AbstractSimpleNode> getChild(final AbstractSimpleNode<AbstractSimpleNode> parent, final int index) { 050 //noinspection unchecked 051 return (AbstractSimpleNode<AbstractSimpleNode>) parent.getChild(index); 052 } 053 054 /** {@inheritDoc} */ 055 public int getChildCount(final AbstractSimpleNode<AbstractSimpleNode> node) { 056 return node.getChildCount(); 057 } 058 059 /** {@inheritDoc} */ 060 public int getColumnCount() { 061 return 2; 062 } 063 064 /** {@inheritDoc} */ 065 public String getColumnName(final int column) { 066 return COLUMN_NAMES[column]; 067 } 068 069 /** {@inheritDoc} */ 070 public Object getValueAt(final AbstractSimpleNode<AbstractSimpleNode> node, final int column) { 071 return node != null ? node.getValueAt(column) : null; 072 } 073 074 /** {@inheritDoc} */ 075 @Override public Class<?> getColumnClass(final int column) { 076 return new Class[] { TreeTableModel.class, String.class}[column]; 077 } 078 079 } // class KeyStrokeTreeTableModel