Gridarta Editor
InputActions.java
Go to the documentation of this file.
1 /*
2  * InputHandler.java - Manages key bindings and executes actions
3  * Copyright (C) 1999 Slava Pestov
4  * Copyright (C) 2000-2015 The Gridarta Developers.
5  *
6  * You may use and modify this package for any purpose. Redistribution is
7  * permitted, in both source and binary form, provided that this notice
8  * remains intact in all source distributions of this package.
9  */
10 
11 package net.sf.gridarta.textedit.textarea.actions;
12 
13 import java.awt.event.ActionListener;
14 import java.util.HashMap;
15 import java.util.Map;
19 import org.jetbrains.annotations.NotNull;
20 
25 public class InputActions {
26 
33  public static final String SMART_HOME_END_PROPERTY = "InputHandler.homeEnd";
34 
35  public final ActionListener backspace = new Backspace();
36 
37  public final ActionListener backspaceWord = new BackspaceWord();
38 
39  public final ActionListener delete = new Delete();
40 
41  public final ActionListener deleteWord = new DeleteWord();
42 
43  public final ActionListener end = new End(false);
44 
45  public final ActionListener documentEnd = new DocumentEnd(false);
46 
47  public final ActionListener selectEnd = new End(true);
48 
49  public final ActionListener selectDocEnd = new DocumentEnd(true);
50 
51  public final ActionListener insertBreak = new InsertBreak();
52 
53  public final ActionListener insertTab = new InsertTab();
54 
55  public final ActionListener home = new Home(false);
56 
57  public final ActionListener documentHome = new DocumentHome(false);
58 
59  public final ActionListener selectHome = new Home(true);
60 
61  public final ActionListener selectDocHome = new DocumentHome(true);
62 
63  public final ActionListener nextChar = new NextChar(false);
64 
65  public final ActionListener nextLine = new NextLine(false);
66 
67  public final ActionListener nextPage = new NextPage(false);
68 
69  public final ActionListener nextWord = new NextWord(false);
70 
71  public final ActionListener selectNextChar = new NextChar(true);
72 
73  public final ActionListener selectNextLine = new NextLine(true);
74 
75  public final ActionListener selectNextPage = new NextPage(true);
76 
77  public final ActionListener selectNextWord = new NextWord(true);
78 
79  public final ActionListener overwrite = new Overwrite();
80 
81  public final ActionListener prevChar = new PrevChar(false);
82 
83  public final ActionListener prevLine = new PrevLine(false);
84 
85  public final ActionListener prevPage = new PrevPage(false);
86 
87  public final ActionListener prevWord = new PrevWord(false);
88 
89  public final ActionListener selectPrevChar = new PrevChar(true);
90 
91  public final ActionListener selectPrevLine = new PrevLine(true);
92 
93  public final ActionListener selectPrevPage = new PrevPage(true);
94 
95  public final ActionListener selectPrevWord = new PrevWord(true);
96 
97  public final ActionListener repeat = new Repeat();
98 
99  public final ActionListener toggleRectangle = new ToggleRectangle();
100 
101  public final ActionListener functionMenu;
102 
103  // Default action
104 
105  public final ActionListener insertChar = new InsertChar();
106 
107  private final Map<String, ActionListener> actions = new HashMap<>();
108 
109  public InputActions(@NotNull final ScriptEditControl scriptEditControl, @NotNull final MenuEntries menuEntries) {
110  final ActionListener save = new Save(scriptEditControl);
111  functionMenu = new FunctionMenu(scriptEditControl, menuEntries);
112  actions.put("backspace", backspace);
113  actions.put("backspace-word", backspaceWord);
114  actions.put("delete", delete);
115  actions.put("delete-word", deleteWord);
116  actions.put("end", end);
117  actions.put("select-end", selectEnd);
118  actions.put("document-end", documentEnd);
119  actions.put("select-doc-end", selectDocEnd);
120  actions.put("insert-break", insertBreak);
121  actions.put("insert-tab", insertTab);
122  actions.put("home", home);
123  actions.put("select-home", selectHome);
124  actions.put("document-home", documentHome);
125  actions.put("select-doc-home", selectDocHome);
126  actions.put("next-char", nextChar);
127  actions.put("next-line", nextLine);
128  actions.put("next-page", nextPage);
129  actions.put("next-word", nextWord);
130  actions.put("select-next-char", selectNextChar);
131  actions.put("select-next-line", selectNextLine);
132  actions.put("select-next-page", selectNextPage);
133  actions.put("select-next-word", selectNextWord);
134  actions.put("overwrite", overwrite);
135  actions.put("prev-char", prevChar);
136  actions.put("prev-line", prevLine);
137  actions.put("prev-page", prevPage);
138  actions.put("prev-word", prevWord);
139  actions.put("select-prev-char", selectPrevChar);
140  actions.put("select-prev-line", selectPrevLine);
141  actions.put("select-prev-page", selectPrevPage);
142  actions.put("select-prev-word", selectPrevWord);
143  actions.put("repeat", repeat);
144  actions.put("toggle-rect", toggleRectangle);
145  actions.put("insert-char", insertChar);
146 
147  actions.put("copy", Actions.COPY);
148  actions.put("cut", Actions.CUT);
149  actions.put("paste", Actions.PASTE);
150 
151  actions.put("save", save);
152  actions.put("find", Actions.FIND);
153  actions.put("find-again", Actions.FIND_AGAIN);
154  actions.put("replace", Actions.REPLACE);
155  }
156 
163  @NotNull
164  public ActionListener getAction(final String name) {
165  final ActionListener action = actions.get(name);
166  if (action != null) {
167  return action;
168  } else {
169  throw new IllegalArgumentException("No action for " + name);
170  }
171  }
172 
173 }
static final ActionListener COPY
Definition: Actions.java:50
static final Find FIND
The "find" action listener.
Definition: Actions.java:62
InputActions(@NotNull final ScriptEditControl scriptEditControl, @NotNull final MenuEntries menuEntries)
Base package of all Gridarta classes.
This package contains the classes for the script editor used within the editor to create and modify P...
Definition: Actions.java:20
static final Replace REPLACE
The "replace" action listener.
Definition: Actions.java:68
Actions used by the script editor.
Definition: Actions.java:41
static final ActionListener CUT
Definition: Actions.java:53
ActionListener getAction(final String name)
Returns a named text area action.
ScriptEditControl - Manages events and data flow for the script editor entity.
static final FindAgain FIND_AGAIN
The "find again" action listener.
Definition: Actions.java:74
Action listener for SAVE actions.
Definition: Save.java:22
List of menu entries (all CFPython commands).
static final ActionListener PASTE
Definition: Actions.java:56
static final String SMART_HOME_END_PROPERTY
If this client property is set to Boolean.TRUE on the text area, the home/end keys will support &#39;smar...