chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1096384 - in /chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench: ClientFrame.java ClientHelper.java
Date Sun, 24 Apr 2011 22:01:53 GMT
Author: fmui
Date: Sun Apr 24 22:01:53 2011
New Revision: 1096384

URL: http://svn.apache.org/viewvc?rev=1096384&view=rev
Log:
CMIS Workbench: added key bindings for Mac OS X

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientFrame.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientFrame.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientFrame.java?rev=1096384&r1=1096383&r2=1096384&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientFrame.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientFrame.java
Sun Apr 24 22:01:53 2011
@@ -96,6 +96,7 @@ public class ClientFrame extends JFrame 
 
     public ClientFrame() {
         super();
+        ClientHelper.installKeyBindings();
 
         model = new ClientModel();
         createGUI();

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java?rev=1096384&r1=1096383&r2=1096384&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java
Sun Apr 24 22:01:53 2011
@@ -38,8 +38,12 @@ import java.util.List;
 import java.util.Properties;
 
 import javax.swing.ImageIcon;
+import javax.swing.InputMap;
 import javax.swing.JFileChooser;
 import javax.swing.JOptionPane;
+import javax.swing.KeyStroke;
+import javax.swing.UIManager;
+import javax.swing.text.DefaultEditorKit;
 
 import org.apache.chemistry.opencmis.client.api.CmisObject;
 import org.apache.chemistry.opencmis.client.api.Document;
@@ -55,7 +59,7 @@ public class ClientHelper {
 
     private static final Log log = LogFactory.getLog(ClientHelper.class);
     private static final int BUFFER_SIZE = 64 * 1024;
-    
+
     private ClientHelper() {
     }
 
@@ -85,6 +89,40 @@ public class ClientHelper {
                 JOptionPane.ERROR_MESSAGE);
     }
 
+    public static boolean isMacOSX() {
+        return System.getProperty("os.name").startsWith("Mac OS X");
+    }
+
+    public static void installKeyBindings() {
+        if (isMacOSX()) {
+            final KeyStroke copyKeyStroke = KeyStroke.getKeyStroke("meta pressed C");
+            final KeyStroke pasteKeyStroke = KeyStroke.getKeyStroke("meta pressed V");
+            final KeyStroke cutKeyStroke = KeyStroke.getKeyStroke("meta pressed X");
+            final KeyStroke allKeyStroke = KeyStroke.getKeyStroke("meta pressed A");
+
+            InputMap textFieldMap = (InputMap) UIManager.get("TextField.focusInputMap");
+            textFieldMap.put(copyKeyStroke, DefaultEditorKit.copyAction);
+            textFieldMap.put(pasteKeyStroke, DefaultEditorKit.pasteAction);
+            textFieldMap.put(cutKeyStroke, DefaultEditorKit.cutAction);
+            textFieldMap.put(allKeyStroke, DefaultEditorKit.selectAllAction);
+
+            InputMap formattedTextFieldMap = (InputMap) UIManager.get("FormattedTextField.focusInputMap");
+            formattedTextFieldMap.put(copyKeyStroke, DefaultEditorKit.copyAction);
+            formattedTextFieldMap.put(pasteKeyStroke, DefaultEditorKit.pasteAction);
+            formattedTextFieldMap.put(cutKeyStroke, DefaultEditorKit.cutAction);
+            formattedTextFieldMap.put(allKeyStroke, DefaultEditorKit.selectAllAction);
+
+            InputMap textAreaMap = (InputMap) UIManager.get("TextArea.focusInputMap");
+            textAreaMap.put(copyKeyStroke, DefaultEditorKit.copyAction);
+            textAreaMap.put(pasteKeyStroke, DefaultEditorKit.pasteAction);
+            textAreaMap.put(cutKeyStroke, DefaultEditorKit.cutAction);
+            textAreaMap.put(allKeyStroke, DefaultEditorKit.selectAllAction);
+
+            InputMap passwordFieldMap = (InputMap) UIManager.get("PasswordField.focusInputMap");
+            passwordFieldMap.put(pasteKeyStroke, DefaultEditorKit.pasteAction);
+        }
+    }
+
     public static ImageIcon getIcon(String name) {
         URL imageURL = ClientHelper.class.getResource("/images/" + name);
         if (imageURL != null) {



Mime
View raw message