64 |
} |
} |
65 |
} |
} |
66 |
|
|
67 |
|
public static class CopyAction |
68 |
|
extends TextAction |
69 |
|
{ |
70 |
|
public CopyAction() |
71 |
|
{ |
72 |
|
super(copyAction); |
73 |
|
} |
74 |
|
public void actionPerformed(ActionEvent event) |
75 |
|
{ |
76 |
|
} |
77 |
|
} |
78 |
|
|
79 |
|
public static class CutAction |
80 |
|
extends TextAction |
81 |
|
{ |
82 |
|
public CutAction() |
83 |
|
{ |
84 |
|
super(cutAction); |
85 |
|
} |
86 |
|
public void actionPerformed(ActionEvent event) |
87 |
|
{ |
88 |
|
} |
89 |
|
} |
90 |
|
|
91 |
|
public static class DefaultKeyTypedAction |
92 |
|
extends TextAction |
93 |
|
{ |
94 |
|
public DefaultKeyTypedAction() |
95 |
|
{ |
96 |
|
super(defaultKeyTypedAction); |
97 |
|
} |
98 |
|
public void actionPerformed(ActionEvent event) |
99 |
|
{ |
100 |
|
JTextComponent t = getTextComponent(event); |
101 |
|
if (t != null) |
102 |
|
{ |
103 |
|
try |
104 |
|
{ |
105 |
|
t.getDocument().insertString(t.getCaret().getDot(), event.getActionCommand(), null); |
106 |
|
t.getCaret().setDot(Math.min(t.getCaret().getDot() + 1, |
107 |
|
t.getDocument().getEndPosition().getOffset())); |
108 |
|
t.repaint(); |
109 |
|
} |
110 |
|
catch (BadLocationException be) |
111 |
|
{ |
112 |
|
// FIXME: we're not authorized to throw this.. swallow it? |
113 |
|
} |
114 |
|
} |
115 |
|
} |
116 |
|
} |
117 |
|
|
118 |
|
public static class InsertBreakAction |
119 |
|
extends TextAction |
120 |
|
{ |
121 |
|
public InsertBreakAction() |
122 |
|
{ |
123 |
|
super(insertBreakAction); |
124 |
|
} |
125 |
|
public void actionPerformed(ActionEvent event) |
126 |
|
{ |
127 |
|
} |
128 |
|
} |
129 |
|
|
130 |
|
public static class InsertContentAction |
131 |
|
extends TextAction |
132 |
|
{ |
133 |
|
public InsertContentAction() |
134 |
|
{ |
135 |
|
super(insertContentAction); |
136 |
|
} |
137 |
|
public void actionPerformed(ActionEvent event) |
138 |
|
{ |
139 |
|
} |
140 |
|
} |
141 |
|
|
142 |
|
public static class InsertTabAction |
143 |
|
extends TextAction |
144 |
|
{ |
145 |
|
public InsertTabAction() |
146 |
|
{ |
147 |
|
super(insertTabAction); |
148 |
|
} |
149 |
|
public void actionPerformed(ActionEvent event) |
150 |
|
{ |
151 |
|
} |
152 |
|
} |
153 |
|
|
154 |
|
public static class PasteAction |
155 |
|
extends TextAction |
156 |
|
{ |
157 |
|
public PasteAction() |
158 |
|
{ |
159 |
|
super(pasteAction); |
160 |
|
} |
161 |
|
public void actionPerformed(ActionEvent event) |
162 |
|
{ |
163 |
|
} |
164 |
|
} |
165 |
|
|
166 |
private static final long serialVersionUID = 9017245433028523428L; |
private static final long serialVersionUID = 9017245433028523428L; |
167 |
|
|
168 |
public static final String backwardAction = "caret-backward"; |
public static final String backwardAction = "caret-backward"; |
220 |
{ |
{ |
221 |
} |
} |
222 |
|
|
223 |
|
private static Action[] defaultActions = |
224 |
|
new Action[] { |
225 |
|
new BeepAction(), |
226 |
|
new CopyAction(), |
227 |
|
new CutAction(), |
228 |
|
new DefaultKeyTypedAction(), |
229 |
|
new InsertBreakAction(), |
230 |
|
new InsertContentAction(), |
231 |
|
new InsertTabAction(), |
232 |
|
new PasteAction(), |
233 |
|
new TextAction(deleteNextCharAction) |
234 |
|
{ |
235 |
|
public void actionPerformed(ActionEvent event) |
236 |
|
{ |
237 |
|
JTextComponent t = getTextComponent(event); |
238 |
|
if (t != null) |
239 |
|
{ |
240 |
|
try |
241 |
|
{ |
242 |
|
int pos = t.getCaret().getDot(); |
243 |
|
if (pos < t.getDocument().getEndPosition().getOffset()) |
244 |
|
{ |
245 |
|
t.getDocument().remove(t.getCaret().getDot(), 1); |
246 |
|
t.repaint(); |
247 |
|
} |
248 |
|
} |
249 |
|
catch (BadLocationException e) |
250 |
|
{ |
251 |
|
// FIXME: we're not authorized to throw this.. swallow it? |
252 |
|
} |
253 |
|
} |
254 |
|
} |
255 |
|
}, |
256 |
|
new TextAction(deletePrevCharAction) |
257 |
|
{ |
258 |
|
public void actionPerformed(ActionEvent event) |
259 |
|
{ |
260 |
|
JTextComponent t = getTextComponent(event); |
261 |
|
if (t != null) |
262 |
|
{ |
263 |
|
try |
264 |
|
{ |
265 |
|
int pos = t.getCaret().getDot(); |
266 |
|
if (pos > t.getDocument().getStartPosition().getOffset()) |
267 |
|
{ |
268 |
|
t.getDocument().remove(pos - 1, 1); |
269 |
|
t.getCaret().setDot(pos - 1); |
270 |
|
t.repaint(); |
271 |
|
} |
272 |
|
} |
273 |
|
catch (BadLocationException e) |
274 |
|
{ |
275 |
|
// FIXME: we're not authorized to throw this.. swallow it? |
276 |
|
} |
277 |
|
} |
278 |
|
} |
279 |
|
}, |
280 |
|
new TextAction(backwardAction) |
281 |
|
{ |
282 |
|
public void actionPerformed(ActionEvent event) |
283 |
|
{ |
284 |
|
JTextComponent t = getTextComponent(event); |
285 |
|
if (t != null) |
286 |
|
{ |
287 |
|
t.getCaret().setDot(Math.max(t.getCaret().getDot() - 1, |
288 |
|
t.getDocument().getStartPosition().getOffset())); |
289 |
|
} |
290 |
|
} |
291 |
|
}, |
292 |
|
new TextAction(forwardAction) |
293 |
|
{ |
294 |
|
public void actionPerformed(ActionEvent event) |
295 |
|
{ |
296 |
|
JTextComponent t = getTextComponent(event); |
297 |
|
if (t != null) |
298 |
|
{ |
299 |
|
t.getCaret().setDot(Math.min(t.getCaret().getDot() + 1, |
300 |
|
t.getDocument().getEndPosition().getOffset())); |
301 |
|
} |
302 |
|
} |
303 |
|
}, |
304 |
|
new TextAction(selectionBackwardAction) |
305 |
|
{ |
306 |
|
public void actionPerformed(ActionEvent event) |
307 |
|
{ |
308 |
|
JTextComponent t = getTextComponent(event); |
309 |
|
if (t != null) |
310 |
|
{ |
311 |
|
t.getCaret().moveDot(Math.max(t.getCaret().getDot() - 1, |
312 |
|
t.getDocument().getStartPosition().getOffset())); |
313 |
|
} |
314 |
|
} |
315 |
|
}, |
316 |
|
new TextAction(selectionForwardAction) |
317 |
|
{ |
318 |
|
public void actionPerformed(ActionEvent event) |
319 |
|
{ |
320 |
|
JTextComponent t = getTextComponent(event); |
321 |
|
if (t != null) |
322 |
|
{ |
323 |
|
t.getCaret().moveDot(Math.min(t.getCaret().getDot() + 1, |
324 |
|
t.getDocument().getEndPosition().getOffset())); |
325 |
|
} |
326 |
|
} |
327 |
|
}, |
328 |
|
}; |
329 |
|
|
330 |
/** |
/** |
331 |
* Called when the kit is being removed from the JEditorPane. |
* Called when the kit is being removed from the JEditorPane. |
332 |
*/ |
*/ |
340 |
|
|
341 |
public Caret createCaret() |
public Caret createCaret() |
342 |
{ |
{ |
343 |
return null; |
return new DefaultCaret(); |
344 |
} |
} |
345 |
|
|
346 |
public Document createDefaultDocument() |
public Document createDefaultDocument() |
347 |
{ |
{ |
348 |
return new PlainDocument(); |
return new PlainDocument(); |
349 |
} |
} |
350 |
|
|
351 |
public Action[] getActions() |
public Action[] getActions() |
352 |
{ |
{ |
353 |
return null; |
return defaultActions; |
354 |
} |
} |
355 |
|
|
356 |
public String getContentType() |
public String getContentType() |