diff options
author | Lillian Angel <langel@redhat.com> | 2005-12-21 19:58:13 +0000 |
---|---|---|
committer | Lillian Angel <langel@redhat.com> | 2005-12-21 19:58:13 +0000 |
commit | 35120fde7e03c34122786c988f69be69fdfc57c6 (patch) | |
tree | 4fcc752240cf47475ede186a8a4114c2d59f2479 | |
parent | baf43c6743ad45dc972311597ccadd1a19e2f6d3 (diff) | |
download | classpath-35120fde7e03c34122786c988f69be69fdfc57c6.tar.gz |
2005-12-20 Lillian Angel <langel@redhat.com>
* javax/swing/UIDefaults.java:
(LazyInputMap): InputMap should be an InputMapUIResource.
* javax/swing/plaf/basic/BasicLookAndFeel.java
(initComponentDefaults): Added all key bindings for Text*.
* javax/swing/plaf/basic/BasicTextUI.java
(installKeyboardActions): Fixed call to replaceUIActionMap
to create a new ActionMap from textComponent's actions. Prevents
an infinite loop. Fixed loop to set the parentActionMap and the
parentInputMap.
(ActionListenerProxy): Removed. No longer needed.
(convertModifiers): Likewise.
(creatActionMap): New function creates the action map to
be installed on the text component.
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | javax/swing/UIDefaults.java | 3 | ||||
-rw-r--r-- | javax/swing/plaf/basic/BasicLookAndFeel.java | 154 | ||||
-rw-r--r-- | javax/swing/plaf/basic/BasicTextUI.java | 100 |
4 files changed, 166 insertions, 107 deletions
@@ -1,5 +1,21 @@ 2005-12-20 Lillian Angel <langel@redhat.com> + * javax/swing/UIDefaults.java: + (LazyInputMap): InputMap should be an InputMapUIResource. + * javax/swing/plaf/basic/BasicLookAndFeel.java + (initComponentDefaults): Added all key bindings for Text*. + * javax/swing/plaf/basic/BasicTextUI.java + (installKeyboardActions): Fixed call to replaceUIActionMap + to create a new ActionMap from textComponent's actions. Prevents + an infinite loop. Fixed loop to set the parentActionMap and the + parentInputMap. + (ActionListenerProxy): Removed. No longer needed. + (convertModifiers): Likewise. + (creatActionMap): New function creates the action map to + be installed on the text component. + +2005-12-20 Lillian Angel <langel@redhat.com> + * javax/swing/plaf/basic/BasicLookAndFeel.java (initComponentDefaults): Added focusInputMap added for PasswordField. diff --git a/javax/swing/UIDefaults.java b/javax/swing/UIDefaults.java index f6aee1b94..04b6c3f5c 100644 --- a/javax/swing/UIDefaults.java +++ b/javax/swing/UIDefaults.java @@ -54,6 +54,7 @@ import java.util.ResourceBundle; import javax.swing.border.Border; import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.InputMapUIResource; /** * UIDefaults is a database where all settings and interface bindings are @@ -95,7 +96,7 @@ public class UIDefaults extends Hashtable } public Object createValue(UIDefaults table) { - InputMap im = new InputMap (); + InputMapUIResource im = new InputMapUIResource (); for (int i = 0; 2*i+1 < bind.length; ++i) { im.put (KeyStroke.getKeyStroke ((String) bind[2*i]), diff --git a/javax/swing/plaf/basic/BasicLookAndFeel.java b/javax/swing/plaf/basic/BasicLookAndFeel.java index 5391f9f85..ffce1f4fa 100644 --- a/javax/swing/plaf/basic/BasicLookAndFeel.java +++ b/javax/swing/plaf/basic/BasicLookAndFeel.java @@ -220,7 +220,6 @@ public abstract class BasicLookAndFeel extends LookAndFeel "TextPaneUI", "javax.swing.plaf.basic.BasicTextPaneUI", "TextAreaUI", "javax.swing.plaf.basic.BasicTextAreaUI", "TextFieldUI", "javax.swing.plaf.basic.BasicTextFieldUI", - "TextUI", "javax.swing.plaf.basic.BasicTextUI", "ToggleButtonUI", "javax.swing.plaf.basic.BasicToggleButtonUI", "ToolBarSeparatorUI", "javax.swing.plaf.basic.BasicToolBarSeparatorUI", "ToolBarUI", "javax.swing.plaf.basic.BasicToolBarUI", @@ -1070,23 +1069,61 @@ public abstract class BasicLookAndFeel extends LookAndFeel "TextArea.foreground", new ColorUIResource(Color.black), "TextArea.inactiveForeground", new ColorUIResource(Color.gray), "TextArea.focusInputMap", new UIDefaults.LazyInputMap(new Object[] { - "UP", "caret-up", + "shift UP", "selection-up", + "ctrl RIGHT", "caret-next-word", + "shift ctrl LEFT", "selection-previous-word", + "shift KP_UP", "selection-up", "DOWN", "caret-down", - "PAGE_UP", "page-up", - "PAGE_DOWN", "page-down", - "ENTER", "insert-break", - "TAB", "insert-tab", + "shift ctrl T", "previous-link-action", + "ctrl LEFT", "caret-previous-word", + "CUT", "cut-to-clipboard", + "END", "caret-end-line", + "shift PAGE_UP", "selection-page-up", + "KP_UP", "caret-up", + "DELETE", "delete-next", + "ctrl HOME", "caret-begin", + "shift LEFT", "selection-backward", + "ctrl END", "caret-end", + "BACK_SPACE", "delete-previous", + "shift ctrl RIGHT", "selection-next-word", "LEFT", "caret-backward", + "KP_LEFT", "caret-backward", + "shift KP_RIGHT", "selection-forward", + "ctrl SPACE", "activate-link-action", + "ctrl H", "delete-previous", + "ctrl BACK_SLASH", "unselect", + "ENTER", "insert-break", + "shift HOME", "selection-begin-line", "RIGHT", "caret-forward", - "BACK_SPACE", "delete-previous", + "shift ctrl PAGE_UP", "selection-page-left", + "shift DOWN", "selection-down", + "PAGE_DOWN", "page-down", + "shift KP_LEFT", "selection-backward", + "shift ctrl O", "toggle-componentOrientation", "ctrl X", "cut-to-clipboard", + "shift ctrl PAGE_DOWN", "selection-page-right", "ctrl C", "copy-to-clipboard", + "ctrl KP_RIGHT", "caret-next-word", + "shift END", "selection-end-line", + "ctrl KP_LEFT", "caret-previous-word", + "HOME", "caret-begin-line", "ctrl V", "paste-from-clipboard", - "shift LEFT", "selection-backward", + "KP_DOWN", "caret-down", + "ctrl A", "select-all", "shift RIGHT", "selection-forward", - "HOME", "caret-begin-line", - "END", "caret-end-line", - "DELETE", "delete-next" + "shift ctrl END", "selection-end", + "COPY", "copy-to-clipboard", + "shift ctrl KP_LEFT", "selection-previous-word", + "ctrl T", "next-link-action", + "shift KP_DOWN", "selection-down", + "TAB", "insert-tab", + "UP", "caret-up", + "shift ctrl HOME", "selection-begin", + "shift PAGE_DOWN", "selection-page-down", + "KP_RIGHT", "caret-forward", + "shift ctrl KP_RIGHT", "selection-next-word", + "PAGE_UP", "page-up", + "PASTE", "paste-from-clipboard" }), "TextArea.margin", new InsetsUIResource(0, 0, 0, 0), "TextArea.selectionBackground", new ColorUIResource(Color.black), @@ -1115,7 +1152,28 @@ public abstract class BasicLookAndFeel extends LookAndFeel "shift RIGHT", "selection-forward", "HOME", "caret-begin-line", "END", "caret-end-line", - "DELETE", "delete-next" + "DELETE", "delete-next", + "shift ctrl O", "toggle-componentOrientation", + "shift KP_LEFT", "selection-backward", + "ctrl H", "delete-previous", + "KP_LEFT", "caret-backward", + "KP_RIGHT", "caret-forward", + "shift ctrl KP_RIGHT", "selection-next-word", + "COPY", "copy-to-clipboard", + "shift HOME", "selection-begin-line", + "shift ctrl LEFT", "selection-previous-word", + "ctrl KP_LEFT", "caret-previous-word", + "ctrl KP_RIGHT", "caret-next-word", + "PASTE", "paste-from-clipboard", + "shift ctrl RIGHT", "selection-next-word", + "ctrl BACK_SLASH", "unselect", + "ctrl A", "select-all", + "shift KP_RIGHT", "selection-forward", + "CUT", "cut-to-clipboard", + "ctrl LEFT", "caret-previous-word", + "shift ctrl KP_LEFT", "selection-previous-word", + "shift END", "selection-end-line", + "ctrl RIGHT", "caret-next-word" }), "TextField.margin", new InsetsUIResource(0, 0, 0, 0), "TextField.selectionBackground", new ColorUIResource(Color.black), @@ -1128,23 +1186,61 @@ public abstract class BasicLookAndFeel extends LookAndFeel "TextPane.foreground", new ColorUIResource(Color.black), "TextPane.inactiveForeground", new ColorUIResource(Color.gray), "TextPane.focusInputMap", new UIDefaults.LazyInputMap(new Object[] { - "UP", "caret-up", - "DOWN", "caret-down", - "PAGE_DOWN", "page-down", - "PAGE_UP", "page-up", - "ENTER", "insert-break", - "TAB", "insert-tab", - "LEFT", "caret-backward", - "RIGHT", "caret-forward", - "BACK_SPACE", "delete-previous", - "ctrl X", "cut-to-clipboard", - "ctrl C", "copy-to-clipboard", - "ctrl V", "paste-from-clipboard", - "shift LEFT", "selection-backward", - "shift RIGHT", "selection-forward", - "HOME", "caret-begin-line", - "END", "caret-end-line", - "DELETE", "delete-next" + "shift UP", "selection-up", + "ctrl RIGHT", "caret-next-word", + "shift ctrl LEFT", "selection-previous-word", + "shift KP_UP", "selection-up", + "DOWN", "caret-down", + "shift ctrl T", "previous-link-action", + "ctrl LEFT", "caret-previous-word", + "CUT", "cut-to-clipboard", + "END", "caret-end-line", + "shift PAGE_UP", "selection-page-up", + "KP_UP", "caret-up", + "DELETE", "delete-next", + "ctrl HOME", "caret-begin", + "shift LEFT", "selection-backward", + "ctrl END", "caret-end", + "BACK_SPACE", "delete-previous", + "shift ctrl RIGHT", "selection-next-word", + "LEFT", "caret-backward", + "KP_LEFT", "caret-backward", + "shift KP_RIGHT", "selection-forward", + "ctrl SPACE", "activate-link-action", + "ctrl H", "delete-previous", + "ctrl BACK_SLASH", "unselect", + "ENTER", "insert-break", + "shift HOME", "selection-begin-line", + "RIGHT", "caret-forward", + "shift ctrl PAGE_UP", "selection-page-left", + "shift DOWN", "selection-down", + "PAGE_DOWN", "page-down", + "shift KP_LEFT", "selection-backward", + "shift ctrl O", "toggle-componentOrientation", + "ctrl X", "cut-to-clipboard", + "shift ctrl PAGE_DOWN", "selection-page-right", + "ctrl C", "copy-to-clipboard", + "ctrl KP_RIGHT", "caret-next-word", + "shift END", "selection-end-line", + "ctrl KP_LEFT", "caret-previous-word", + "HOME", "caret-begin-line", + "ctrl V", "paste-from-clipboard", + "KP_DOWN", "caret-down", + "ctrl A", "select-all", + "shift RIGHT", "selection-forward", + "shift ctrl END", "selection-end", + "COPY", "copy-to-clipboard", + "shift ctrl KP_LEFT", "selection-previous-word", + "ctrl T", "next-link-action", + "shift KP_DOWN", "selection-down", + "TAB", "insert-tab", + "UP", "caret-up", + "shift ctrl HOME", "selection-begin", + "shift PAGE_DOWN", "selection-page-down", + "KP_RIGHT", "caret-forward", + "shift ctrl KP_RIGHT", "selection-next-word", + "PAGE_UP", "page-up", + "PASTE", "paste-from-clipboard" }), "TextPane.margin", new InsetsUIResource(3, 3, 3, 3), "TextPane.selectionBackground", new ColorUIResource(Color.black), diff --git a/javax/swing/plaf/basic/BasicTextUI.java b/javax/swing/plaf/basic/BasicTextUI.java index 4089e28db..9de140ed5 100644 --- a/javax/swing/plaf/basic/BasicTextUI.java +++ b/javax/swing/plaf/basic/BasicTextUI.java @@ -652,33 +652,26 @@ public abstract class BasicTextUI extends TextUI // load any bindings for the newer InputMap / ActionMap interface SwingUtilities.replaceUIInputMap(textComponent, JComponent.WHEN_FOCUSED, getInputMap(JComponent.WHEN_FOCUSED)); - SwingUtilities.replaceUIActionMap(textComponent, textComponent.getActionMap()); + SwingUtilities.replaceUIActionMap(textComponent, createActionMap()); - InputMap focusInputMap = textComponent.getInputMap(JComponent.WHEN_FOCUSED); + InputMap focusInputMap = (InputMap) UIManager.get(getPropertyPrefix() + ".focusInputMap"); InputMapUIResource parentInputMap = new InputMapUIResource(); ActionMap parentActionMap = new ActionMapUIResource(); - Object keys[] = focusInputMap.allKeys(); - + KeyStroke[] keys = focusInputMap.allKeys(); + + Action[] actions = textComponent.getActions(); + for (int j = 0; j < actions.length; j++) + { + Action currAction = actions[j]; + parentActionMap.put(currAction.getValue(Action.NAME), currAction); + } + for (int i = 0; i < keys.length; i++) { String act = (String) focusInputMap.get((KeyStroke) keys[i]); - Action[] actions = textComponent.getActions(); - for (int j = 0; j < actions.length; j++) - { - Action currAction = actions[j]; - if (currAction != null - && (currAction.getValue(Action.NAME).equals(act))) - parentActionMap.put(act, new ActionListenerProxy(currAction, act)); - } - - parentInputMap.put(KeyStroke.getKeyStroke(((KeyStroke) keys[i]).getKeyCode(), - convertModifiers(((KeyStroke) keys[i]).getModifiers())), - act); - parentInputMap.put(KeyStroke.getKeyStroke(((KeyStroke) keys[i]).getKeyCode(), - ((KeyStroke) keys[i]).getModifiers()), - act); + parentInputMap.put(KeyStroke.getKeyStroke(act),act); } - + parentInputMap.setParent(textComponent.getInputMap(JComponent.WHEN_FOCUSED).getParent()); parentActionMap.setParent(textComponent.getActionMap().getParent()); textComponent.getInputMap(JComponent.WHEN_FOCUSED).setParent(parentInputMap); @@ -686,68 +679,21 @@ public abstract class BasicTextUI extends TextUI } /** - * This class is used to mimic the behaviour of the JDK when registering - * keyboard actions. It is the same as the private class used in JComponent - * for the same reason. This class receives an action event and dispatches it - * to the true receiver after altering the actionCommand property of the - * event. - */ - private static class ActionListenerProxy extends AbstractAction - { - ActionListener target; - - String bindingCommandName; - - public ActionListenerProxy(ActionListener li, String cmd) - { - target = li; - bindingCommandName = cmd; - } - - public void actionPerformed(ActionEvent e) - { - ActionEvent derivedEvent = new ActionEvent(e.getSource(), e.getID(), - bindingCommandName, - e.getModifiers()); - target.actionPerformed(derivedEvent); - } - } - - /** - * Converts the modifiers. + * Creates an ActionMap to be installed on the text component. * - * @param mod - - * modifier to convert - * @returns the new modifier + * @return an ActionMap to be installed on the text component */ - private int convertModifiers(int mod) + ActionMap createActionMap() { - if ((mod & KeyEvent.SHIFT_DOWN_MASK) != 0) - { - mod |= KeyEvent.SHIFT_MASK; - mod &= ~KeyEvent.SHIFT_DOWN_MASK; - } - if ((mod & KeyEvent.CTRL_DOWN_MASK) != 0) - { - mod |= KeyEvent.CTRL_MASK; - mod &= ~KeyEvent.CTRL_DOWN_MASK; - } - if ((mod & KeyEvent.META_DOWN_MASK) != 0) - { - mod |= KeyEvent.META_MASK; - mod &= ~KeyEvent.META_DOWN_MASK; - } - if ((mod & KeyEvent.ALT_DOWN_MASK) != 0) - { - mod |= KeyEvent.ALT_MASK; - mod &= ~KeyEvent.ALT_DOWN_MASK; - } - if ((mod & KeyEvent.ALT_GRAPH_DOWN_MASK) != 0) + Action[] actions = textComponent.getActions(); + ActionMap am = new ActionMapUIResource(); + for (int i = 0; i < actions.length; ++i) { - mod |= KeyEvent.ALT_GRAPH_MASK; - mod &= ~KeyEvent.ALT_GRAPH_DOWN_MASK; + String name = (String) actions[i].getValue(Action.NAME); + if (name != null) + am.put(name, actions[i]); } - return mod; + return am; } /** |