shortcuts for xpad
Sylvestre Koumar [Fri, 4 Sep 2009 23:28:01 +0000 (01:28 +0200)]
18 files changed:
scilab/modules/xpad/src/java/org/scilab/modules/xpad/Xpad.java
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/CloseAction.java
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/ColorizeAction.java
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/CommentAction.java
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/CopyAction.java
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/CutAction.java
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/ExitAction.java
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/FindAction.java
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/IndentAction.java
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/NewAction.java
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/OpenAction.java
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/PasteAction.java
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/PrintAction.java
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/PrintPreviewAction.java
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/RedoAction.java
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/SaveAction.java
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/SelectAllAction.java
scilab/modules/xpad/src/java/org/scilab/modules/xpad/actions/UndoAction.java

index c8e87d9..4c0d597 100644 (file)
@@ -14,12 +14,14 @@ package org.scilab.modules.xpad;
 
 import java.awt.Color;
 import java.awt.Event;
+import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
 import java.io.File;
 import java.io.IOException;
 import java.util.Scanner;
 
 import javax.swing.BorderFactory;
+import javax.swing.JMenuItem;
 import javax.swing.JOptionPane;
 import javax.swing.JScrollPane;
 import javax.swing.JTabbedPane;
@@ -167,7 +169,7 @@ public class Xpad extends SwingScilabTab implements Tab {
        editMenu.addSeparator();
        editMenu.add(new IndentAction(editor));
        menuBar.add(editMenu);
-
+       
        // Create SEARCH menubar
        Menu searchMenu = ScilabMenu.createMenu(); 
        searchMenu.setText("Search");
@@ -224,7 +226,7 @@ public class Xpad extends SwingScilabTab implements Tab {
        helpMenu.add(new HelpAction(editor));
        helpMenu.add(new AboutAction(editor));
        menuBar.add(helpMenu);
-
+       
        editor.setMenuBar(menuBar);
        mainWindow.setTitle("XPad");
        mainWindow.setVisible(true);
@@ -263,7 +265,9 @@ public class Xpad extends SwingScilabTab implements Tab {
        textPane.setCharacterAttributes(textPane.getStyle("Default"), true);
 
        textPane.setFocusable(true);
-       KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_Z, Event.CTRL_MASK);
+
+       KeyStroke key;
+       key = KeyStroke.getKeyStroke(KeyEvent.VK_Z, Event.CTRL_MASK);
        textPane.getInputMap().put(key, new UndoAction(this));
        key = KeyStroke.getKeyStroke(KeyEvent.VK_Y, Event.CTRL_MASK);
        textPane.getInputMap().put(key, new RedoAction(this));
index 1635817..4b9fe12 100644 (file)
 package org.scilab.modules.xpad.actions;
 
 
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.KeyStroke;
+
 import org.scilab.modules.xpad.Xpad;
 
 public class CloseAction extends DefaultAction {
     
     public CloseAction(Xpad editor) {
         super("Close", editor);
-        setMnemonic('W');
+        //setMnemonic('W');
+        setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.CTRL_MASK));
     }
     
     public void doAction() {
index 9053c7a..ddb5fcb 100644 (file)
 
 package org.scilab.modules.xpad.actions;
 
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.KeyStroke;
+
 import org.scilab.modules.xpad.Xpad;
 import org.scilab.modules.xpad.style.ScilabStyleDocument;
 
@@ -19,6 +24,7 @@ public class ColorizeAction extends DefaultAction {
 
        public ColorizeAction(Xpad editor) {
                super("Colorize", editor);
+               //setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_, ActionEvent.CTRL_MASK));
        }
 
        public void doAction() {
index 846cf36..9f400db 100644 (file)
 
 package org.scilab.modules.xpad.actions;
 
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.KeyStroke;
+
 import org.scilab.modules.xpad.Xpad;
 
 public class CommentAction extends DefaultAction {
 
        public CommentAction(Xpad editor) {
                super("Comment Selection", editor);
+               setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_SLASH, ActionEvent.CTRL_MASK));
        }
 }
index d6f96e2..5a64e37 100644 (file)
 
 package org.scilab.modules.xpad.actions;
 
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.KeyStroke;
 import javax.swing.text.DefaultEditorKit;
 
 import org.scilab.modules.xpad.Xpad;
@@ -20,7 +24,8 @@ public class CopyAction extends DefaultAction {
 
     public CopyAction(Xpad editor) {
        super("Copy", editor);
-       setMnemonic('c');
+       //setMnemonic('c');
+       setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK));
     }
     
     public void doAction() {
index 571ba25..cf20c4b 100644 (file)
 
 package org.scilab.modules.xpad.actions;
 
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.KeyStroke;
 import javax.swing.text.DefaultEditorKit;
 
 import org.scilab.modules.xpad.Xpad;
@@ -20,7 +24,8 @@ public class CutAction extends DefaultAction {
 
     public CutAction(Xpad editor) {
        super("Cut", editor);
-       setMnemonic('c');
+       //setMnemonic('c');
+       setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));
     }
     
     public void doAction() {
index a6187ea..09d45e6 100644 (file)
 package org.scilab.modules.xpad.actions;
 
 
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.KeyStroke;
+
 import org.scilab.modules.xpad.Xpad;
 
 public class ExitAction extends DefaultAction {
     
     public ExitAction(Xpad editor) {
         super("Exit", editor);
-        setMnemonic('X');
+        //setMnemonic('X');
+        setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
     }
     
     public void doAction() {
index a197456..f4e49fa 100644 (file)
@@ -19,6 +19,7 @@ import java.awt.GridBagLayout;
 import java.awt.Insets;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
 import java.util.Vector;
 
 import javax.swing.BorderFactory;
@@ -30,6 +31,7 @@ import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.JRadioButton;
 import javax.swing.JTextField;
+import javax.swing.KeyStroke;
 import javax.swing.text.BadLocationException;
 import javax.swing.text.DefaultHighlighter;
 import javax.swing.text.Highlighter;
@@ -66,7 +68,8 @@ public class FindAction extends DefaultAction {
 
        public FindAction(Xpad editor) {
                super("Find/Replace...", editor);
-               setMnemonic('F');
+               //setMnemonic('F');
+               setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK));
        }
 
        public void doAction() {
index 38a3f4a..4ad87cc 100644 (file)
 
 package org.scilab.modules.xpad.actions;
 
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.KeyStroke;
+
 import org.scilab.modules.xpad.Xpad;
 import org.scilab.modules.xpad.style.ScilabStyleDocument;
 
@@ -19,6 +24,8 @@ public class IndentAction extends DefaultAction {
        
        public IndentAction(Xpad editor) {
                super("Indent", editor);
+               setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.CTRL_MASK));
+
        }
        
        public void doAction() {
index 2a1617a..f736161 100644 (file)
 
 package org.scilab.modules.xpad.actions;
 
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.KeyStroke;
+
 import org.scilab.modules.xpad.Xpad;
 
 public class NewAction extends DefaultAction {
 
        public NewAction(Xpad editor) {
                super("New...", editor);
+               setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
        }
 
        public void doAction() {
index 173fcdc..74fb343 100644 (file)
 
 package org.scilab.modules.xpad.actions;
 
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
 import java.io.File;
 
 import javax.swing.JFileChooser;
+import javax.swing.KeyStroke;
 
 import org.scilab.modules.xpad.Xpad;
 
@@ -22,7 +25,8 @@ public class OpenAction extends DefaultAction {
 
     public OpenAction(Xpad editor) {
        super("Open...", editor);
-       setMnemonic('O');
+       //setMnemonic('O');
+       setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
     }
 
     public void doAction() {
index 2a0525e..cc0255c 100644 (file)
 
 package org.scilab.modules.xpad.actions;
 
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.KeyStroke;
 import javax.swing.text.DefaultEditorKit;
 
 import org.scilab.modules.xpad.Xpad;
@@ -20,7 +24,8 @@ public class PasteAction extends DefaultAction {
 
     public PasteAction(Xpad editor) {
        super("Paste", editor);
-       setMnemonic('c');
+       //setMnemonic('c');
+       setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));
     }
     
     public void doAction() {
index f4bcfc8..b9eabf6 100644 (file)
 
 package org.scilab.modules.xpad.actions;
 
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.KeyStroke;
+
 import org.scilab.modules.xpad.Xpad;
 
 public class PrintAction extends DefaultAction {
 
        public PrintAction(Xpad editor) {
                super("Print...", editor);
+               setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK));
        }
 
 }
index 0a96558..8ce2a0a 100644 (file)
 
 package org.scilab.modules.xpad.actions;
 
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.KeyStroke;
+
 import org.scilab.modules.xpad.Xpad;
 
 public class PrintPreviewAction extends DefaultAction {
index ceddd5d..11d6f5a 100644 (file)
 
 package org.scilab.modules.xpad.actions;
 
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.KeyStroke;
+
 import org.scilab.modules.xpad.Xpad;
 
 public class RedoAction extends DefaultAction {
 
        public RedoAction(Xpad editor) {
                super("Redo", editor);
+               setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, ActionEvent.CTRL_MASK));
        }
 
        public void doAction() {
index e027f76..99bed1d 100644 (file)
 
 package org.scilab.modules.xpad.actions;
 
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
 import java.io.File;
 import java.io.FileWriter;
 
 import javax.swing.JFileChooser;
 import javax.swing.JOptionPane;
 import javax.swing.JTextPane;
+import javax.swing.KeyStroke;
 import javax.swing.text.BadLocationException;
 import javax.swing.text.Document;
 import javax.swing.text.StyleConstants;
@@ -28,7 +31,8 @@ public class SaveAction extends DefaultAction {
 
        public SaveAction(Xpad editor) {
                super("Save", editor);
-               setMnemonic('S');
+               //setMnemonic('S');
+               setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
        }
 
        public void doAction() {
index cfebcc9..463f620 100644 (file)
 
 package org.scilab.modules.xpad.actions;
 
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.KeyStroke;
 import javax.swing.text.DefaultEditorKit;
 
 import org.scilab.modules.xpad.Xpad;
@@ -20,6 +24,7 @@ public class SelectAllAction extends DefaultAction {
 
     public SelectAllAction(Xpad editor) {
        super("Select All", editor);
+       setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK));
     }
     
     public void doAction() {
index 3363383..5dd7533 100644 (file)
 
 package org.scilab.modules.xpad.actions;
 
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.KeyStroke;
+
 import org.scilab.modules.xpad.Xpad;
 
 public class UndoAction extends DefaultAction {
 
        public UndoAction(Xpad editor) {
                super("Undo", editor);
+               setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, ActionEvent.CTRL_MASK));
        }
 
        public void doAction() {