11 package net.sf.gridarta.textedit.textarea;
13 import java.awt.Component;
14 import java.awt.event.ActionEvent;
15 import java.awt.event.ActionListener;
16 import java.awt.event.KeyEvent;
17 import java.awt.event.KeyListener;
18 import java.util.EventObject;
19 import javax.swing.JPopupMenu;
20 import org.apache.log4j.Category;
21 import org.apache.log4j.Logger;
22 import org.jetbrains.annotations.NotNull;
23 import org.jetbrains.annotations.Nullable;
84 return repeat ? Math.max(1, repeatCount) : 1;
108 public void executeAction(
final ActionListener listener,
final Object source, @Nullable
final String actionCommand) {
110 final ActionEvent evt =
new ActionEvent(source, ActionEvent.ACTION_PERFORMED, actionCommand);
113 final boolean repeatBak =
repeat;
117 listener.actionPerformed(evt);
119 for (
int i = 0; i < Math.max(1, repeatCount); i++) {
120 listener.actionPerformed(evt);
126 if (grabAction == null) {
146 final Object o = evt.getSource();
147 if (o instanceof Component) {
149 Component c = (Component) o;
152 return (JEditTextArea) c;
153 }
else if (c == null) {
156 if (c instanceof JPopupMenu) {
157 c = ((JPopupMenu) c).getInvoker();
166 LOG.fatal(
"BUG: getTextArea() returning null");
167 LOG.fatal(
"Report this to Slava Pestov <sp@gjt.org>");
168 assert false :
"BUG: getTextArea() returning null";
169 throw new Error(
"BUG: getTextArea() returning null");
182 if (grabAction == null) {
188 final ActionListener grabAction2 =
grabAction;
190 executeAction(grabAction2, evt.getSource(), String.valueOf(evt.getKeyChar()));
void setRepeatCount(final int repeatCount)
Sets the number of times the next action will be repeated.
boolean handleGrabAction(final KeyEvent evt)
If a key is being grabbed, this method should be called with the appropriate key event.
ActionListener grabAction
If an action implements this interface, it should not be repeated.
An input handler converts the user's key strokes into concrete actions.
boolean isRepeatEnabled()
Returns if repetition is enabled.
static final Category LOG
The Logger for printing log messages.
static JEditTextArea getTextArea(final EventObject evt)
Returns the text area that fired the specified event.
void setRepeatEnabled(final boolean repeat)
Sets the enabled state of repetition.
int getRepeatCount()
Returns the number of times the next action will be repeated.
abstract void addDefaultKeyBindings()
Adds the default key bindings to this input handler.
jEdit's text area component.
void executeAction(final ActionListener listener, final Object source, @Nullable final String actionCommand)
Executes the specified action, repeating and recording it as necessary.
abstract InputHandler copy()
Returns a copy of this input handler that shares the same key bindings.