KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > keys > SpecialKey


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ui.keys;
13
14 import java.util.SortedMap JavaDoc;
15 import java.util.TreeMap JavaDoc;
16
17 import org.eclipse.jface.bindings.keys.IKeyLookup;
18 import org.eclipse.jface.bindings.keys.KeyLookupFactory;
19
20 /**
21  * <p>
22  * Instances of <code>SpecialKey</code> represent the keys on keyboard
23  * recognized as neither modifier keys nor character keys. These are special
24  * control keys specific to computers (e.g., "left arrow", "page down", "F10",
25  * etc.). They do not include keys representing letters, numbers or punctuation
26  * from a natural language, nor do they include any key that can be represented
27  * by a Unicode character (e.g., "backspace").
28  * </p>
29  * <p>
30  * <code>SpecialKey</code> objects are immutable. Clients are not permitted to
31  * extend this class.
32  * </p>
33  *
34  * @deprecated Please use org.eclipse.jface.bindings.keys.KeyStroke and
35  * org.eclipse.jface.bindings.keys.KeyLookupFactory
36  * @since 3.0
37  */

38 public final class SpecialKey extends NaturalKey {
39
40     /**
41      * An internal map used to lookup instances of <code>SpecialKey</code>
42      * given the formal string representation of a special key.
43      */

44     static SortedMap JavaDoc specialKeysByName = new TreeMap JavaDoc();
45
46     /**
47      * The single static instance of <code>SpecialKey</code> which represents
48      * the 'Arrow Down' key.
49      */

50     public final static SpecialKey ARROW_DOWN;
51
52     /**
53      * The single static instance of <code>SpecialKey</code> which represents
54      * the 'Arrow Left' key.
55      */

56     public final static SpecialKey ARROW_LEFT;
57
58     /**
59      * The single static instance of <code>SpecialKey</code> which represents
60      * the 'Arrow Right' key.
61      */

62     public final static SpecialKey ARROW_RIGHT;
63
64     /**
65      * The single static instance of <code>SpecialKey</code> which represents
66      * the 'Arrow Up' key.
67      */

68     public final static SpecialKey ARROW_UP;
69
70     /**
71      * The single static instance of <code>SpecialKey</code> which represents
72      * the 'Break' key.
73      */

74     public final static SpecialKey BREAK;
75
76     /**
77      * The single static instance of <code>SpecialKey</code> which represents
78      * the 'Caps Lock' key.
79      */

80     public final static SpecialKey CAPS_LOCK;
81
82     /**
83      * The single static instance of <code>SpecialKey</code> which represents
84      * the 'End' key.
85      */

86     public final static SpecialKey END;
87
88     /**
89      * The single static instance of <code>SpecialKey</code> which represents
90      * the 'F1' key.
91      */

92     public final static SpecialKey F1;
93
94     /**
95      * The single static instance of <code>SpecialKey</code> which represents
96      * the 'F10' key.
97      */

98     public final static SpecialKey F10;
99
100     /**
101      * The single static instance of <code>SpecialKey</code> which represents
102      * the 'F11' key.
103      */

104     public final static SpecialKey F11;
105
106     /**
107      * The single static instance of <code>SpecialKey</code> which represents
108      * the 'F12' key.
109      */

110     public final static SpecialKey F12;
111
112     /**
113      * The single static instance of <code>SpecialKey</code> which represents
114      * the 'F13' key.
115      */

116     public final static SpecialKey F13;
117
118     /**
119      * The single static instance of <code>SpecialKey</code> which represents
120      * the 'F14' key.
121      */

122     public final static SpecialKey F14;
123
124     /**
125      * The single static instance of <code>SpecialKey</code> which represents
126      * the 'F15' key.
127      */

128     public final static SpecialKey F15;
129
130     /**
131      * The single static instance of <code>SpecialKey</code> which represents
132      * the 'F2' key.
133      */

134     public final static SpecialKey F2;
135
136     /**
137      * The single static instance of <code>SpecialKey</code> which represents
138      * the 'F3' key.
139      */

140     public final static SpecialKey F3;
141
142     /**
143      * The single static instance of <code>SpecialKey</code> which represents
144      * the 'F4' key.
145      */

146     public final static SpecialKey F4;
147
148     /**
149      * The single static instance of <code>SpecialKey</code> which represents
150      * the 'F5' key.
151      */

152     public final static SpecialKey F5;
153
154     /**
155      * The single static instance of <code>SpecialKey</code> which represents
156      * the 'F6' key.
157      */

158     public final static SpecialKey F6;
159
160     /**
161      * The single static instance of <code>SpecialKey</code> which represents
162      * the 'F7' key.
163      */

164     public final static SpecialKey F7;
165
166     /**
167      * The single static instance of <code>SpecialKey</code> which represents
168      * the 'F8' key.
169      */

170     public final static SpecialKey F8;
171
172     /**
173      * The single static instance of <code>SpecialKey</code> which represents
174      * the 'F9' key.
175      */

176     public final static SpecialKey F9;
177
178     /**
179      * The single static instance of <code>SpecialKey</code> which represents
180      * the 'Home' key.
181      */

182     public final static SpecialKey HOME;
183
184     /**
185      * The single static instance of <code>SpecialKey</code> which represents
186      * the 'Insert' key.
187      */

188     public final static SpecialKey INSERT;
189
190     /**
191      * The single static instance of <code>SpecialKey</code> which represents
192      * the 'NumLock' key.
193      */

194     public final static SpecialKey NUM_LOCK;
195
196     /**
197      * The single static instance of <code>SpecialKey</code> which represents
198      * the '0' key on the numpad.
199      */

200     public final static SpecialKey NUMPAD_0;
201
202     /**
203      * The single static instance of <code>SpecialKey</code> which represents
204      * the '1' key on the numpad.
205      */

206     public final static SpecialKey NUMPAD_1;
207
208     /**
209      * The single static instance of <code>SpecialKey</code> which represents
210      * the '2' key on the numpad.
211      */

212     public final static SpecialKey NUMPAD_2;
213
214     /**
215      * The single static instance of <code>SpecialKey</code> which represents
216      * the '3' key on the numpad.
217      */

218     public final static SpecialKey NUMPAD_3;
219
220     /**
221      * The single static instance of <code>SpecialKey</code> which represents
222      * the '4' key on the numpad.
223      */

224     public final static SpecialKey NUMPAD_4;
225
226     /**
227      * The single static instance of <code>SpecialKey</code> which represents
228      * the '5' key on the numpad.
229      */

230     public final static SpecialKey NUMPAD_5;
231
232     /**
233      * The single static instance of <code>SpecialKey</code> which represents
234      * the '6' key on the numpad.
235      */

236     public final static SpecialKey NUMPAD_6;
237
238     /**
239      * The single static instance of <code>SpecialKey</code> which represents
240      * the '7' key on the numpad.
241      */

242     public final static SpecialKey NUMPAD_7;
243
244     /**
245      * The single static instance of <code>SpecialKey</code> which represents
246      * the '8' key on the numpad.
247      */

248     public final static SpecialKey NUMPAD_8;
249
250     /**
251      * The single static instance of <code>SpecialKey</code> which represents
252      * the '9' key on the numpad.
253      */

254     public final static SpecialKey NUMPAD_9;
255
256     /**
257      * The single static instance of <code>SpecialKey</code> which represents
258      * the 'Add' key on the numpad.
259      */

260     public final static SpecialKey NUMPAD_ADD;
261
262     /**
263      * The single static instance of <code>SpecialKey</code> which represents
264      * the 'Decimal' key on the numpad.
265      */

266     public final static SpecialKey NUMPAD_DECIMAL;
267
268     /**
269      * The single static instance of <code>SpecialKey</code> which represents
270      * the 'Divide' key on the numpad.
271      */

272     public final static SpecialKey NUMPAD_DIVIDE;
273
274     /**
275      * The single static instance of <code>SpecialKey</code> which represents
276      * the 'Enter' key on the numpad.
277      */

278     public final static SpecialKey NUMPAD_ENTER;
279
280     /**
281      * The single static instance of <code>SpecialKey</code> which represents
282      * the '=' key on the numpad.
283      */

284     public final static SpecialKey NUMPAD_EQUAL;
285
286     /**
287      * The single static instance of <code>SpecialKey</code> which represents
288      * the 'Multiply' key on the numpad.
289      */

290     public final static SpecialKey NUMPAD_MULTIPLY;
291
292     /**
293      * The single static instance of <code>SpecialKey</code> which represents
294      * the 'Subtract' key on the numpad.
295      */

296     public final static SpecialKey NUMPAD_SUBTRACT;
297
298     /**
299      * The single static instance of <code>SpecialKey</code> which represents
300      * the 'Page Down' key.
301      */

302     public final static SpecialKey PAGE_DOWN;
303
304     /**
305      * The single static instance of <code>SpecialKey</code> which represents
306      * the 'Page Up' key.
307      */

308     public final static SpecialKey PAGE_UP;
309
310     /**
311      * The single static instance of <code>SpecialKey</code> which represents
312      * the 'Pause' key.
313      */

314     public final static SpecialKey PAUSE;
315
316     /**
317      * The single static instance of <code>SpecialKey</code> which represents
318      * the 'Print Screen' key.
319      */

320     public final static SpecialKey PRINT_SCREEN;
321
322     /**
323      * The single static instance of <code>SpecialKey</code> which represents
324      * the 'Scroll Lock' key.
325      */

326     public final static SpecialKey SCROLL_LOCK;
327
328     static {
329         final IKeyLookup lookup = KeyLookupFactory.getDefault();
330         ARROW_DOWN = new SpecialKey(lookup
331                 .formalKeyLookup(IKeyLookup.ARROW_DOWN_NAME));
332         ARROW_LEFT = new SpecialKey(lookup
333                 .formalKeyLookup(IKeyLookup.ARROW_LEFT_NAME));
334         ARROW_RIGHT = new SpecialKey(lookup
335                 .formalKeyLookup(IKeyLookup.ARROW_RIGHT_NAME));
336         ARROW_UP = new SpecialKey(lookup
337                 .formalKeyLookup(IKeyLookup.ARROW_UP_NAME));
338         BREAK = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.BREAK_NAME));
339         CAPS_LOCK = new SpecialKey(lookup
340                 .formalKeyLookup(IKeyLookup.CAPS_LOCK_NAME));
341         END = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.END_NAME));
342         F1 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F1_NAME));
343         F2 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F2_NAME));
344         F3 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F3_NAME));
345         F4 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F4_NAME));
346         F5 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F5_NAME));
347         F6 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F6_NAME));
348         F7 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F7_NAME));
349         F8 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F8_NAME));
350         F9 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F9_NAME));
351         F10 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F10_NAME));
352         F11 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F11_NAME));
353         F12 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F12_NAME));
354         F13 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F13_NAME));
355         F14 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F14_NAME));
356         F15 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F15_NAME));
357         HOME = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.HOME_NAME));
358         INSERT = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.INSERT_NAME));
359         NUM_LOCK = new SpecialKey(lookup
360                 .formalKeyLookup(IKeyLookup.NUM_LOCK_NAME));
361         NUMPAD_0 = new SpecialKey(lookup
362                 .formalKeyLookup(IKeyLookup.NUMPAD_0_NAME));
363         NUMPAD_1 = new SpecialKey(lookup
364                 .formalKeyLookup(IKeyLookup.NUMPAD_1_NAME));
365         NUMPAD_2 = new SpecialKey(lookup
366                 .formalKeyLookup(IKeyLookup.NUMPAD_2_NAME));
367         NUMPAD_3 = new SpecialKey(lookup
368                 .formalKeyLookup(IKeyLookup.NUMPAD_3_NAME));
369         NUMPAD_4 = new SpecialKey(lookup
370                 .formalKeyLookup(IKeyLookup.NUMPAD_4_NAME));
371         NUMPAD_5 = new SpecialKey(lookup
372                 .formalKeyLookup(IKeyLookup.NUMPAD_5_NAME));
373         NUMPAD_6 = new SpecialKey(lookup
374                 .formalKeyLookup(IKeyLookup.NUMPAD_6_NAME));
375         NUMPAD_7 = new SpecialKey(lookup
376                 .formalKeyLookup(IKeyLookup.NUMPAD_7_NAME));
377         NUMPAD_8 = new SpecialKey(lookup
378                 .formalKeyLookup(IKeyLookup.NUMPAD_8_NAME));
379         NUMPAD_9 = new SpecialKey(lookup
380                 .formalKeyLookup(IKeyLookup.NUMPAD_9_NAME));
381         NUMPAD_ADD = new SpecialKey(lookup
382                 .formalKeyLookup(IKeyLookup.NUMPAD_ADD_NAME));
383         NUMPAD_DECIMAL = new SpecialKey(lookup
384                 .formalKeyLookup(IKeyLookup.NUMPAD_DECIMAL_NAME));
385         NUMPAD_DIVIDE = new SpecialKey(lookup
386                 .formalKeyLookup(IKeyLookup.NUMPAD_DIVIDE_NAME));
387         NUMPAD_ENTER = new SpecialKey(lookup
388                 .formalKeyLookup(IKeyLookup.NUMPAD_ENTER_NAME));
389         NUMPAD_EQUAL = new SpecialKey(lookup
390                 .formalKeyLookup(IKeyLookup.NUMPAD_EQUAL_NAME));
391         NUMPAD_MULTIPLY = new SpecialKey(lookup
392                 .formalKeyLookup(IKeyLookup.NUMPAD_MULTIPLY_NAME));
393         NUMPAD_SUBTRACT = new SpecialKey(lookup
394                 .formalKeyLookup(IKeyLookup.NUMPAD_SUBTRACT_NAME));
395         PAGE_DOWN = new SpecialKey(lookup
396                 .formalKeyLookup(IKeyLookup.PAGE_DOWN_NAME));
397         PAGE_UP = new SpecialKey(lookup
398                 .formalKeyLookup(IKeyLookup.PAGE_UP_NAME));
399         PAUSE = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.PAUSE_NAME));
400         PRINT_SCREEN = new SpecialKey(lookup
401                 .formalKeyLookup(IKeyLookup.PRINT_SCREEN_NAME));
402         SCROLL_LOCK = new SpecialKey(lookup
403                 .formalKeyLookup(IKeyLookup.SCROLL_LOCK_NAME));
404
405         specialKeysByName.put(SpecialKey.ARROW_DOWN.toString(),
406                 SpecialKey.ARROW_DOWN);
407         specialKeysByName.put(SpecialKey.ARROW_LEFT.toString(),
408                 SpecialKey.ARROW_LEFT);
409         specialKeysByName.put(SpecialKey.ARROW_RIGHT.toString(),
410                 SpecialKey.ARROW_RIGHT);
411         specialKeysByName.put(SpecialKey.ARROW_UP.toString(),
412                 SpecialKey.ARROW_UP);
413         specialKeysByName.put(SpecialKey.BREAK.toString(), SpecialKey.BREAK);
414         specialKeysByName.put(SpecialKey.CAPS_LOCK.toString(),
415                 SpecialKey.CAPS_LOCK);
416         specialKeysByName.put(SpecialKey.END.toString(), SpecialKey.END);
417         specialKeysByName.put(SpecialKey.F1.toString(), SpecialKey.F1);
418         specialKeysByName.put(SpecialKey.F10.toString(), SpecialKey.F10);
419         specialKeysByName.put(SpecialKey.F11.toString(), SpecialKey.F11);
420         specialKeysByName.put(SpecialKey.F12.toString(), SpecialKey.F12);
421         specialKeysByName.put(SpecialKey.F13.toString(), SpecialKey.F13);
422         specialKeysByName.put(SpecialKey.F14.toString(), SpecialKey.F14);
423         specialKeysByName.put(SpecialKey.F15.toString(), SpecialKey.F15);
424         specialKeysByName.put(SpecialKey.F2.toString(), SpecialKey.F2);
425         specialKeysByName.put(SpecialKey.F3.toString(), SpecialKey.F3);
426         specialKeysByName.put(SpecialKey.F4.toString(), SpecialKey.F4);
427         specialKeysByName.put(SpecialKey.F5.toString(), SpecialKey.F5);
428         specialKeysByName.put(SpecialKey.F6.toString(), SpecialKey.F6);
429         specialKeysByName.put(SpecialKey.F7.toString(), SpecialKey.F7);
430         specialKeysByName.put(SpecialKey.F8.toString(), SpecialKey.F8);
431         specialKeysByName.put(SpecialKey.F9.toString(), SpecialKey.F9);
432         specialKeysByName.put(SpecialKey.NUM_LOCK.toString(),
433                 SpecialKey.NUM_LOCK);
434         specialKeysByName.put(SpecialKey.NUMPAD_0.toString(),
435                 SpecialKey.NUMPAD_0);
436         specialKeysByName.put(SpecialKey.NUMPAD_1.toString(),
437                 SpecialKey.NUMPAD_1);
438         specialKeysByName.put(SpecialKey.NUMPAD_2.toString(),
439                 SpecialKey.NUMPAD_2);
440         specialKeysByName.put(SpecialKey.NUMPAD_3.toString(),
441                 SpecialKey.NUMPAD_3);
442         specialKeysByName.put(SpecialKey.NUMPAD_4.toString(),
443                 SpecialKey.NUMPAD_4);
444         specialKeysByName.put(SpecialKey.NUMPAD_5.toString(),
445                 SpecialKey.NUMPAD_5);
446         specialKeysByName.put(SpecialKey.NUMPAD_6.toString(),
447                 SpecialKey.NUMPAD_6);
448         specialKeysByName.put(SpecialKey.NUMPAD_7.toString(),
449                 SpecialKey.NUMPAD_7);
450         specialKeysByName.put(SpecialKey.NUMPAD_8.toString(),
451                 SpecialKey.NUMPAD_8);
452         specialKeysByName.put(SpecialKey.NUMPAD_9.toString(),
453                 SpecialKey.NUMPAD_9);
454         specialKeysByName.put(SpecialKey.NUMPAD_ADD.toString(),
455                 SpecialKey.NUMPAD_ADD);
456         specialKeysByName.put(SpecialKey.NUMPAD_DECIMAL.toString(),
457                 SpecialKey.NUMPAD_DECIMAL);
458         specialKeysByName.put(SpecialKey.NUMPAD_DIVIDE.toString(),
459                 SpecialKey.NUMPAD_DIVIDE);
460         specialKeysByName.put(SpecialKey.NUMPAD_ENTER.toString(),
461                 SpecialKey.NUMPAD_ENTER);
462         specialKeysByName.put(SpecialKey.NUMPAD_EQUAL.toString(),
463                 SpecialKey.NUMPAD_EQUAL);
464         specialKeysByName.put(SpecialKey.NUMPAD_MULTIPLY.toString(),
465                 SpecialKey.NUMPAD_MULTIPLY);
466         specialKeysByName.put(SpecialKey.NUMPAD_SUBTRACT.toString(),
467                 SpecialKey.NUMPAD_SUBTRACT);
468         specialKeysByName.put(SpecialKey.HOME.toString(), SpecialKey.HOME);
469         specialKeysByName.put(SpecialKey.INSERT.toString(), SpecialKey.INSERT);
470         specialKeysByName.put(SpecialKey.PAGE_DOWN.toString(),
471                 SpecialKey.PAGE_DOWN);
472         specialKeysByName
473                 .put(SpecialKey.PAGE_UP.toString(), SpecialKey.PAGE_UP);
474         specialKeysByName.put(SpecialKey.PAUSE.toString(), SpecialKey.PAUSE);
475         specialKeysByName.put(SpecialKey.PRINT_SCREEN.toString(),
476                 SpecialKey.PRINT_SCREEN);
477         specialKeysByName.put(SpecialKey.SCROLL_LOCK.toString(),
478                 SpecialKey.SCROLL_LOCK);
479     }
480
481     /**
482      * Constructs an instance of <code>SpecialKey</code> given a name.
483      *
484      * @param key
485      * The key to be wrapped.
486      */

487     private SpecialKey(final int key) {
488         super(key);
489     }
490 }
491
Popular Tags