From 9e216cdc8b5df36af855b9f7314c7e4a83eb4a12 Mon Sep 17 00:00:00 2001 From: hzzz Date: Wed, 24 May 2017 20:04:04 +0800 Subject: [PATCH] fix --- .../src/com/fr/design/gui/ilist/UIList.java | 13 +++++++++++++ .../com/fr/design/gui/itextarea/UITextArea.java | 13 +++++++++++++ .../fr/design/gui/itextfield/UITextField.java | 17 ++++++++++++++--- .../gui/itree/checkboxtree/CheckBoxTree.java | 9 +++++++-- .../loghandler/DesignerLogHandler.java | 9 +++------ 5 files changed, 50 insertions(+), 11 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/ilist/UIList.java b/designer_base/src/com/fr/design/gui/ilist/UIList.java index b01f40f0b..2a31fe6c3 100644 --- a/designer_base/src/com/fr/design/gui/ilist/UIList.java +++ b/designer_base/src/com/fr/design/gui/ilist/UIList.java @@ -6,10 +6,14 @@ import com.fr.design.mainframe.JTemplate; import com.fr.stable.StringUtils; import javax.swing.*; +import javax.swing.text.DefaultEditorKit; import java.awt.*; +import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.util.Vector; +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + /** * Created with IntelliJ IDEA. * User: pony @@ -22,6 +26,15 @@ public class UIList extends JList{ public UIList() { super(); + InputMap inputMap = this.getInputMap(); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), + DefaultEditorKit.selectAllAction); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), + DefaultEditorKit.copyAction); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER), + DefaultEditorKit.pasteAction); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER), + DefaultEditorKit.cutAction); } public UIList(ListModel dataModel) { diff --git a/designer_base/src/com/fr/design/gui/itextarea/UITextArea.java b/designer_base/src/com/fr/design/gui/itextarea/UITextArea.java index cf89971b3..8194b10ce 100644 --- a/designer_base/src/com/fr/design/gui/itextarea/UITextArea.java +++ b/designer_base/src/com/fr/design/gui/itextarea/UITextArea.java @@ -7,13 +7,26 @@ import com.fr.design.utils.gui.GUICoreUtils; import javax.swing.*; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; +import javax.swing.text.DefaultEditorKit; import java.awt.*; +import java.awt.event.KeyEvent; + +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; public class UITextArea extends JTextArea implements UIObserver { private UIObserverListener uiObserverListener; public UITextArea(int i, int j) { super(i, j); + InputMap inputMap = this.getInputMap(); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), + DefaultEditorKit.selectAllAction); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), + DefaultEditorKit.copyAction); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER), + DefaultEditorKit.pasteAction); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER), + DefaultEditorKit.cutAction); initComponents(); } diff --git a/designer_base/src/com/fr/design/gui/itextfield/UITextField.java b/designer_base/src/com/fr/design/gui/itextfield/UITextField.java index 7a451593b..ff4556acb 100644 --- a/designer_base/src/com/fr/design/gui/itextfield/UITextField.java +++ b/designer_base/src/com/fr/design/gui/itextfield/UITextField.java @@ -1,12 +1,12 @@ package com.fr.design.gui.itextfield; import java.awt.*; +import java.awt.event.KeyEvent; -import javax.swing.JFrame; -import javax.swing.JPanel; -import javax.swing.JTextField; +import javax.swing.*; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; +import javax.swing.text.DefaultEditorKit; import javax.swing.text.Document; import com.fr.design.event.GlobalNameListener; @@ -16,6 +16,8 @@ import com.fr.design.event.UIObserverListener; import com.fr.stable.Constants; import com.fr.design.utils.gui.GUICoreUtils; +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + /** * @author Jerry */ @@ -30,6 +32,15 @@ public class UITextField extends JTextField implements UIObserver, GlobalNameObs public UITextField() { super(); + InputMap inputMap = this.getInputMap(); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), + DefaultEditorKit.selectAllAction); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), + DefaultEditorKit.copyAction); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER), + DefaultEditorKit.pasteAction); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER), + DefaultEditorKit.cutAction); initListener(); } diff --git a/designer_base/src/com/fr/design/gui/itree/checkboxtree/CheckBoxTree.java b/designer_base/src/com/fr/design/gui/itree/checkboxtree/CheckBoxTree.java index 0511504cf..c56efdfd6 100644 --- a/designer_base/src/com/fr/design/gui/itree/checkboxtree/CheckBoxTree.java +++ b/designer_base/src/com/fr/design/gui/itree/checkboxtree/CheckBoxTree.java @@ -16,10 +16,10 @@ import java.beans.PropertyChangeListener; import java.util.Hashtable; import java.util.Vector; -import javax.swing.JTree; -import javax.swing.SwingUtilities; +import javax.swing.*; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; +import javax.swing.text.DefaultEditorKit; import javax.swing.text.Position; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.TreeCellRenderer; @@ -29,6 +29,8 @@ import javax.swing.tree.TreePath; import com.fr.design.gui.icheckbox.UICheckBox; +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + /** * CheckBoxTree is a special JTree which uses UICheckBox as the tree renderer. * In addition to regular JTree's features, it also allows you select any number @@ -87,6 +89,9 @@ public class CheckBoxTree extends JTree { public CheckBoxTree(TreeModel newModel) { super(newModel); + InputMap inputMap = this.getInputMap(); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), + "selectAll"); init(); } diff --git a/designer_base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java b/designer_base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java index 8da862fb6..0bf286e51 100644 --- a/designer_base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java +++ b/designer_base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java @@ -13,10 +13,7 @@ import com.fr.general.LogRecordTime; import com.fr.stable.xml.LogRecordTimeProvider; import javax.swing.*; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.SimpleAttributeSet; -import javax.swing.text.StyleConstants; +import javax.swing.text.*; import java.awt.*; import java.awt.event.*; import java.text.SimpleDateFormat; @@ -192,9 +189,9 @@ public class DesignerLogHandler { private JTextPane initLogJTextArea() { JTextPane resultPane = new JTextPane(); InputMap inputMap = resultPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), "copy"); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), DefaultEditorKit.copyAction); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), DefaultEditorKit.selectAllAction); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_L, DEFAULT_MODIFIER), "clear"); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), "select-all"); ActionMap actionMap = resultPane.getActionMap(); actionMap.put("clear", new AbstractAction() { public void actionPerformed(ActionEvent evt) {