[Jsxe-cvs] SF.net SVN: jsxe: [976] trunk/jsxe
Status: Inactive
Brought to you by:
ian_lewis
From: <ian...@us...> - 2006-06-23 19:35:46
|
Revision: 976 Author: ian_lewis Date: 2006-06-23 12:35:33 -0700 (Fri, 23 Jun 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=976&view=rev Log Message: ----------- Added back rudimentary key bindings Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java trunk/jsxe/src/net/sourceforge/jsxe/action/FileCloseAction.java trunk/jsxe/src/net/sourceforge/jsxe/action/FileExitAction.java trunk/jsxe/src/net/sourceforge/jsxe/action/FileNewAction.java trunk/jsxe/src/net/sourceforge/jsxe/action/FileOpenAction.java trunk/jsxe/src/net/sourceforge/jsxe/action/FileSaveAction.java trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java trunk/jsxe/src/net/sourceforge/jsxe/gui/menu/EnhancedMenu.java trunk/jsxe/src/net/sourceforge/jsxe/properties Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-06-23 19:13:40 UTC (rev 975) +++ trunk/jsxe/Changelog 2006-06-23 19:35:33 UTC (rev 976) @@ -1,3 +1,9 @@ +06/23/2006 Ian Lewis <Ian...@me...> + + * Added back rudimentary key bindings using Swing Actions so they get + dispached by Swing and are displayed in menus. But infrastructure is + in place to allow jsXe to catch key bindings itself. + 06/21/2006 Ian Lewis <Ian...@me...> * Moved EnhancedMenu to it's own package. I will be creating a new menu Modified: trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java 2006-06-23 19:13:40 UTC (rev 975) +++ trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java 2006-06-23 19:35:33 UTC (rev 976) @@ -87,21 +87,23 @@ * @param name the name of the action. */ public static Action getAction(String name) { + Log.log(Log.NOTICE, ActionManager.class, "Loading key bindings."); Action action = (Action)m_actionMap.get(name); if (action == null) { LocalizedAction editAction = getLocalizedAction(name); if (editAction != null) { action = new Wrapper(name); - if (editAction == null) { - String dispName = editAction.getLabel(); - String keyBinding = jsXe.getProperty(name+".shortcut"); - - action.putValue(Action.NAME, dispName); - - if (keyBinding != null) { - action.putValue(Action.ACCELERATOR_KEY, keyBinding); - } + String dispName = editAction.getLabel(); + //TODO: add method for setting menu mnemonic from label + + String keyBinding = jsXe.getProperty(name+".shortcut"); + + action.putValue(Action.NAME, dispName); + + if (keyBinding != null) { + action.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(keyBinding)); + Log.log(Log.NOTICE, ActionManager.class, "Loaded key binding for "+name+": "+keyBinding); } m_actionMap.put(name, action); @@ -149,7 +151,11 @@ if (msg.getKey().endsWith(".shortcut")) { String actionName = msg.getKey().substring(0, msg.getKey().lastIndexOf(".")); String keyBinding = jsXe.getProperty(msg.getKey()); - addKeyBinding(keyBinding, actionName); + if (keyBinding != null) { + addKeyBinding(keyBinding, actionName); + } else { + removeKeyBinding(msg.getOldValue()); + } } } }//}}} @@ -191,6 +197,8 @@ if (action != null && keyBinding != null) { Action wrapper = getAction(action.getName()); m_keyBindingMap.put(keyBinding,wrapper); + + //need to do this so that the accelerator key is rendered on menu items wrapper.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(keyBinding)); } }//}}} Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/FileCloseAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/FileCloseAction.java 2006-06-23 19:13:40 UTC (rev 975) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/FileCloseAction.java 2006-06-23 19:35:33 UTC (rev 976) @@ -59,7 +59,6 @@ //{{{ FileCloseAction constructor public FileCloseAction() { super("close-file"); - // putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl W")); }//}}} //{{{ actionPerformed() Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/FileExitAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/FileExitAction.java 2006-06-23 19:13:40 UTC (rev 975) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/FileExitAction.java 2006-06-23 19:35:33 UTC (rev 976) @@ -50,7 +50,6 @@ //{{{ FileExitAction constructor public FileExitAction() { super("exit"); - // putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl Q")); }//}}} //{{{ invoke() Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/FileNewAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/FileNewAction.java 2006-06-23 19:13:40 UTC (rev 975) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/FileNewAction.java 2006-06-23 19:35:33 UTC (rev 976) @@ -55,7 +55,6 @@ //{{{ FileNewAction constructor public FileNewAction() { super("new-file"); - // putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl N")); }//}}} //{{{ invoke() Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/FileOpenAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/FileOpenAction.java 2006-06-23 19:13:40 UTC (rev 975) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/FileOpenAction.java 2006-06-23 19:35:33 UTC (rev 976) @@ -58,7 +58,6 @@ //{{{ FileOpenAction constructor public FileOpenAction() { super("open-file"); - // putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl O")); }//}}} //{{{ invoke() Modified: trunk/jsxe/src/net/sourceforge/jsxe/action/FileSaveAction.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/action/FileSaveAction.java 2006-06-23 19:13:40 UTC (rev 975) +++ trunk/jsxe/src/net/sourceforge/jsxe/action/FileSaveAction.java 2006-06-23 19:35:33 UTC (rev 976) @@ -59,7 +59,6 @@ //{{{ FileSaveAction constructor public FileSaveAction() { super("save-file"); - // putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl S")); }//}}} //{{{ invoke() Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java 2006-06-23 19:13:40 UTC (rev 975) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/TabbedView.java 2006-06-23 19:35:33 UTC (rev 976) @@ -326,6 +326,11 @@ protected void processKeyEvent(KeyEvent e) { //TODO: process shortcuts Log.log(Log.DEBUG, this, e.toString()); + /* + TODO: We should process all key events here instead of having Swing + process them. Since we don't know which would be added to menus and + which aren't. + */ super.processKeyEvent(e); }//}}} Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/menu/EnhancedMenu.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/menu/EnhancedMenu.java 2006-06-23 19:13:40 UTC (rev 975) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/menu/EnhancedMenu.java 2006-06-23 19:35:33 UTC (rev 976) @@ -47,7 +47,7 @@ * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id$ */ -public class EnhancedMenu extends JMenu implements EBListener { +public class EnhancedMenu extends JMenu { //{{{ EnhancedMenu constructor /** Modified: trunk/jsxe/src/net/sourceforge/jsxe/properties =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/properties 2006-06-23 19:13:40 UTC (rev 975) +++ trunk/jsxe/src/net/sourceforge/jsxe/properties 2006-06-23 19:35:33 UTC (rev 976) @@ -51,4 +51,10 @@ metal.secondary.fontstyle=0 #}}} - +#{{{ Default key bindings +open-file.shortcut=ctrl O +exit.shortcut=ctrl Q +close-file.shortcut=ctrl W +new-file.shortcut=ctrl N +save-file.shortcut=ctrl S +#}}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |