I love that. I was banging my head against the wall in the past,
trying to figure out how to trick Swing into platform-friendly
shortcut behavior. Very nice, thanks!
Andrus
Begin forwarded message:
> From: BlackNeXT <blacknex..sers.sourceforge.net>
> Date: March 2, 2006 4:06:23 AM GMT+03:00
> To: cayenne-cv..bjectstyle.org
> Subject: cayenne/cayenne-java/src/modeler/java/org/objectstyle/
> cayenne/modeler/action NewProjectAction.java,1.1,1.2
> ValidateAction.java,1.1,1.2 SaveAction.java,1.1,1.2
> SaveAsAction.java,1.1,1.2 ObjEntitySyncAction.java,1.1,1.2
> OpenProjectAction.java,1.1,1.2 RemoveAction.java,1.6,1.7
>
> Update of /cvsroot/cayenne/cayenne/cayenne-java/src/modeler/java/
> org/objectstyle/cayenne/modeler/action
> In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20779/src/
> modeler/java/org/objectstyle/cayenne/modeler/action
>
> Modified Files:
> NewProjectAction.java ValidateAction.java SaveAction.java
> SaveAsAction.java ObjEntitySyncAction.java
> OpenProjectAction.java RemoveAction.java
> Log Message:
> Keyboard shortcut enhancements.
>
> Index: ObjEntitySyncAction.java
> ===================================================================
> RCS file: /cvsroot/cayenne/cayenne/cayenne-java/src/modeler/java/
> org/objectstyle/cayenne/modeler/action/ObjEntitySyncAction.java,v
> retrieving revision 1.1
> retrieving revision 1.2
> diff -u -d -r1.1 -r1.2
> --- ObjEntitySyncAction.java 4 Nov 2005 10:15:06 -0000 1.1
> +++ ObjEntitySyncAction.java 2 Mar 2006 01:06:21 -0000 1.2
>.. -55,7 +55,11 @@
> */
> package org.objectstyle.cayenne.modeler.action;
>
> +import java.awt.Toolkit;
> import java.awt.event.ActionEvent;
> +import java.awt.event.KeyEvent;
> +
> +import javax.swing.KeyStroke;
>
> import org.objectstyle.cayenne.map.DataMap;
> import org.objectstyle.cayenne.map.ObjEntity;
>.. -87,6 +91,9 @@
> return "icon-sync.gif";
> }
>
> + public KeyStroke getAcceleratorKey() {
> + return KeyStroke.getKeyStroke(KeyEvent.VK_U,
> Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
> + }
> /**
> *..ee
> org.objectstyle.cayenne.modeler.util.CayenneAction#performAction
> (ActionEvent)
> */
>
> Index: NewProjectAction.java
> ===================================================================
> RCS file: /cvsroot/cayenne/cayenne/cayenne-java/src/modeler/java/
> org/objectstyle/cayenne/modeler/action/NewProjectAction.java,v
> retrieving revision 1.1
> retrieving revision 1.2
> diff -u -d -r1.1 -r1.2
> --- NewProjectAction.java 4 Nov 2005 10:15:06 -0000 1.1
> +++ NewProjectAction.java 2 Mar 2006 01:06:21 -0000 1.2
>.. -55,11 +55,11 @@
> */
> package org.objectstyle.cayenne.modeler.action;
>
> +import java.awt.Toolkit;
> import java.awt.event.ActionEvent;
> import java.awt.event.KeyEvent;
>
> import javax.swing.KeyStroke;
> -
> import org.objectstyle.cayenne.access.DataDomain;
> import org.objectstyle.cayenne.conf.Configuration;
> import org.objectstyle.cayenne.modeler.Application;
>.. -87,7 +87,7 @@
> }
>
> public KeyStroke getAcceleratorKey() {
> - return KeyStroke.getKeyStroke(KeyEvent.VK_N,
> ActionEvent.CTRL_MASK);
> + return KeyStroke.getKeyStroke(KeyEvent.VK_N,
> Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
> }
>
> public void performAction(ActionEvent e) {
>
> Index: ValidateAction.java
> ===================================================================
> RCS file: /cvsroot/cayenne/cayenne/cayenne-java/src/modeler/java/
> org/objectstyle/cayenne/modeler/action/ValidateAction.java,v
> retrieving revision 1.1
> retrieving revision 1.2
> diff -u -d -r1.1 -r1.2
> --- ValidateAction.java 4 Nov 2005 10:15:06 -0000 1.1
> +++ ValidateAction.java 2 Mar 2006 01:06:21 -0000 1.2
>.. -56,7 +56,11 @@
>
> package org.objectstyle.cayenne.modeler.action;
>
> +import java.awt.Toolkit;
> import java.awt.event.ActionEvent;
> +import java.awt.event.KeyEvent;
> +
> +import javax.swing.KeyStroke;
>
> import org.objectstyle.cayenne.modeler.Application;
> import
> org.objectstyle.cayenne.modeler.dialog.validator.ValidationDisplayHand
> ler;
>.. -81,7 +85,13 @@
> super(getActionName(), application);
> }
>
> - /**
> + public KeyStroke getAcceleratorKey() {
> + return KeyStroke.getKeyStroke
> + (KeyEvent.VK_V,
> + Toolkit.getDefaultToolkit
> ().getMenuShortcutKeyMask() | ActionEvent.SHIFT_MASK);
> + }
> +
> + /**
> * Validates project for possible conflicts and incomplete mappings.
> */
> public void performAction(ActionEvent e) {
>
> Index: SaveAction.java
> ===================================================================
> RCS file: /cvsroot/cayenne/cayenne/cayenne-java/src/modeler/java/
> org/objectstyle/cayenne/modeler/action/SaveAction.java,v
> retrieving revision 1.1
> retrieving revision 1.2
> diff -u -d -r1.1 -r1.2
> --- SaveAction.java 4 Nov 2005 10:15:06 -0000 1.1
> +++ SaveAction.java 2 Mar 2006 01:06:21 -0000 1.2
>.. -56,7 +56,7 @@
>
> package org.objectstyle.cayenne.modeler.action;
>
> -import java.awt.event.ActionEvent;
> +import java.awt.Toolkit;
> import java.awt.event.KeyEvent;
>
> import javax.swing.KeyStroke;
>.. -78,7 +78,7 @@
> }
>
> public KeyStroke getAcceleratorKey() {
> - return KeyStroke.getKeyStroke(KeyEvent.VK_S,
> ActionEvent.CTRL_MASK);
> + return KeyStroke.getKeyStroke(KeyEvent.VK_S,
> Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
> }
>
> public String getIconName() {
>
> Index: RemoveAction.java
> ===================================================================
> RCS file: /cvsroot/cayenne/cayenne/cayenne-java/src/modeler/java/
> org/objectstyle/cayenne/modeler/action/RemoveAction.java,v
> retrieving revision 1.6
> retrieving revision 1.7
> diff -u -d -r1.6 -r1.7
> --- RemoveAction.java 23 Feb 2006 04:09:23 -0000 1.6
> +++ RemoveAction.java 2 Mar 2006 01:06:21 -0000 1.7
>.. -56,6 +56,7 @@
>
> package org.objectstyle.cayenne.modeler.action;
>
> +import java.awt.Toolkit;
> import java.awt.event.ActionEvent;
> import java.awt.event.KeyEvent;
> import java.util.ArrayList;
>.. -111,7 +112,7 @@
> }
>
> public KeyStroke getAcceleratorKey() {
> - return KeyStroke.getKeyStroke(KeyEvent.VK_D,
> ActionEvent.CTRL_MASK);
> + return KeyStroke.getKeyStroke(KeyEvent.VK_D,
> Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
> }
>
> public void performAction(ActionEvent e) {
>
> Index: OpenProjectAction.java
> ===================================================================
> RCS file: /cvsroot/cayenne/cayenne/cayenne-java/src/modeler/java/
> org/objectstyle/cayenne/modeler/action/OpenProjectAction.java,v
> retrieving revision 1.1
> retrieving revision 1.2
> diff -u -d -r1.1 -r1.2
> --- OpenProjectAction.java 4 Nov 2005 10:15:06 -0000 1.1
> +++ OpenProjectAction.java 2 Mar 2006 01:06:21 -0000 1.2
>.. -55,6 +55,7 @@
> */
> package org.objectstyle.cayenne.modeler.action;
>
> +import java.awt.Toolkit;
> import java.awt.event.ActionEvent;
> import java.awt.event.KeyEvent;
> import java.io.File;
>.. -97,7 +98,7 @@
> }
>
> public KeyStroke getAcceleratorKey() {
> - return KeyStroke.getKeyStroke(KeyEvent.VK_O,
> ActionEvent.CTRL_MASK);
> + return KeyStroke.getKeyStroke(KeyEvent.VK_O,
> Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
> }
>
> public void performAction(ActionEvent e) {
>
> Index: SaveAsAction.java
> ===================================================================
> RCS file: /cvsroot/cayenne/cayenne/cayenne-java/src/modeler/java/
> org/objectstyle/cayenne/modeler/action/SaveAsAction.java,v
> retrieving revision 1.1
> retrieving revision 1.2
> diff -u -d -r1.1 -r1.2
> --- SaveAsAction.java 4 Nov 2005 10:15:06 -0000 1.1
> +++ SaveAsAction.java 2 Mar 2006 01:06:21 -0000 1.2
>.. -55,9 +55,13 @@
> */
> package org.objectstyle.cayenne.modeler.action;
>
> +import java.awt.Toolkit;
> import java.awt.event.ActionEvent;
> +import java.awt.event.KeyEvent;
> import java.io.File;
>
> +import javax.swing.KeyStroke;
> +
> import org.objectstyle.cayenne.CayenneRuntimeException;
> import org.objectstyle.cayenne.modeler.Application;
> import
> org.objectstyle.cayenne.modeler.dialog.validator.ValidationDisplayHand
> ler;
>.. -90,6 +94,12 @@
> this.fileChooser = new ProjectOpener();
> }
>
> + public KeyStroke getAcceleratorKey() {
> + return KeyStroke.getKeyStroke
> + (KeyEvent.VK_S,
> + Toolkit.getDefaultToolkit
> ().getMenuShortcutKeyMask() | ActionEvent.SHIFT_MASK);
> + }
> +
> /**
> * Saves project and related files. Saving is done to
> temporary files, and only on
> * successful save, master files are replaced with new versions.
>
>
This archive was generated by hypermail 2.0.0 : Thu Mar 02 2006 - 06:08:39 EST