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.ArrayList;
024 import static java.util.Arrays.asList;
025 import java.util.List;
026 import java.awt.BorderLayout;
027 import javax.swing.JScrollPane;
028 import net.sf.japi.swing.ActionFactory;
029 import net.sf.japi.swing.prefs.AbstractPrefs;
030 import net.sf.japi.swing.treetable.JTreeTable;
031
032 /** Prefs implementation for configuring keystrokes of one or more {@link ActionFactory ActionFactories}.
033 * TODO
034 * @author <a href="mailto:chris@itcqis.com">Christian Hujer</a>
035 */
036 public class KeyStrokePrefs extends AbstractPrefs {
037
038 /** Create KeyStrokePrefs for a list of ActionFactories.
039 * @param actionFactories ActionFactories
040 */
041 public KeyStrokePrefs(final ActionFactory... actionFactories) {
042 setListLabelText("ListLabelText");
043 setLabelText("LabelText");
044 final List<ActionFactory> factories = asList(actionFactories);
045 setLayout(new BorderLayout());
046 add(new JScrollPane(new JTreeTable(new KeyStrokeTreeTableModel(factories))));
047 add(new ActionKeyDisplay(), BorderLayout.SOUTH);
048 }
049
050 /** Create KeyStrokePrefs for a list of named ActionFactories.
051 * @param factoryNames names of ActionFactories
052 */
053 public KeyStrokePrefs(final String... factoryNames) {
054 setListLabelText("ListLabelText");
055 setLabelText("LabelText");
056 final List<ActionFactory> factories = new ArrayList<ActionFactory>();
057 for (final String factoryName : factoryNames) {
058 factories.add(ActionFactory.getFactory(factoryName));
059 }
060 setLayout(new BorderLayout());
061 add(new JScrollPane(new JTreeTable(new KeyStrokeTreeTableModel(factories))));
062 add(new ActionKeyDisplay(), BorderLayout.SOUTH);
063 }
064
065 /** {@inheritDoc} */
066 public boolean isChanged() {
067 return false; //TODO
068 }
069
070 /** {@inheritDoc} */
071 public void defaults() {
072 //TODO
073 }
074
075 /** {@inheritDoc} */
076 public void revert() {
077 //TODO
078 }
079
080 /** {@inheritDoc} */
081 public void apply() {
082 //TODO
083 }
084
085 } // class KeyStrokePrefs