001: /*******************************************************************************
002: * Copyright (c) 2000, 2005 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.keys;
011:
012: import java.util.SortedMap;
013: import java.util.TreeMap;
014:
015: import org.eclipse.jface.bindings.keys.IKeyLookup;
016: import org.eclipse.jface.bindings.keys.KeyLookupFactory;
017:
018: /**
019: * <p>
020: * Instances of <code>SpecialKey</code> represent the keys on keyboard
021: * recognized as neither modifier keys nor character keys. These are special
022: * control keys specific to computers (e.g., "left arrow", "page down", "F10",
023: * etc.). They do not include keys representing letters, numbers or punctuation
024: * from a natural language, nor do they include any key that can be represented
025: * by a Unicode character (e.g., "backspace").
026: * </p>
027: * <p>
028: * <code>SpecialKey</code> objects are immutable. Clients are not permitted to
029: * extend this class.
030: * </p>
031: *
032: * @deprecated Please use org.eclipse.jface.bindings.keys.KeyStroke and
033: * org.eclipse.jface.bindings.keys.KeyLookupFactory
034: * @since 3.0
035: */
036: public final class SpecialKey extends NaturalKey {
037:
038: /**
039: * An internal map used to lookup instances of <code>SpecialKey</code>
040: * given the formal string representation of a special key.
041: */
042: static SortedMap specialKeysByName = new TreeMap();
043:
044: /**
045: * The single static instance of <code>SpecialKey</code> which represents
046: * the 'Arrow Down' key.
047: */
048: public final static SpecialKey ARROW_DOWN;
049:
050: /**
051: * The single static instance of <code>SpecialKey</code> which represents
052: * the 'Arrow Left' key.
053: */
054: public final static SpecialKey ARROW_LEFT;
055:
056: /**
057: * The single static instance of <code>SpecialKey</code> which represents
058: * the 'Arrow Right' key.
059: */
060: public final static SpecialKey ARROW_RIGHT;
061:
062: /**
063: * The single static instance of <code>SpecialKey</code> which represents
064: * the 'Arrow Up' key.
065: */
066: public final static SpecialKey ARROW_UP;
067:
068: /**
069: * The single static instance of <code>SpecialKey</code> which represents
070: * the 'Break' key.
071: */
072: public final static SpecialKey BREAK;
073:
074: /**
075: * The single static instance of <code>SpecialKey</code> which represents
076: * the 'Caps Lock' key.
077: */
078: public final static SpecialKey CAPS_LOCK;
079:
080: /**
081: * The single static instance of <code>SpecialKey</code> which represents
082: * the 'End' key.
083: */
084: public final static SpecialKey END;
085:
086: /**
087: * The single static instance of <code>SpecialKey</code> which represents
088: * the 'F1' key.
089: */
090: public final static SpecialKey F1;
091:
092: /**
093: * The single static instance of <code>SpecialKey</code> which represents
094: * the 'F10' key.
095: */
096: public final static SpecialKey F10;
097:
098: /**
099: * The single static instance of <code>SpecialKey</code> which represents
100: * the 'F11' key.
101: */
102: public final static SpecialKey F11;
103:
104: /**
105: * The single static instance of <code>SpecialKey</code> which represents
106: * the 'F12' key.
107: */
108: public final static SpecialKey F12;
109:
110: /**
111: * The single static instance of <code>SpecialKey</code> which represents
112: * the 'F13' key.
113: */
114: public final static SpecialKey F13;
115:
116: /**
117: * The single static instance of <code>SpecialKey</code> which represents
118: * the 'F14' key.
119: */
120: public final static SpecialKey F14;
121:
122: /**
123: * The single static instance of <code>SpecialKey</code> which represents
124: * the 'F15' key.
125: */
126: public final static SpecialKey F15;
127:
128: /**
129: * The single static instance of <code>SpecialKey</code> which represents
130: * the 'F2' key.
131: */
132: public final static SpecialKey F2;
133:
134: /**
135: * The single static instance of <code>SpecialKey</code> which represents
136: * the 'F3' key.
137: */
138: public final static SpecialKey F3;
139:
140: /**
141: * The single static instance of <code>SpecialKey</code> which represents
142: * the 'F4' key.
143: */
144: public final static SpecialKey F4;
145:
146: /**
147: * The single static instance of <code>SpecialKey</code> which represents
148: * the 'F5' key.
149: */
150: public final static SpecialKey F5;
151:
152: /**
153: * The single static instance of <code>SpecialKey</code> which represents
154: * the 'F6' key.
155: */
156: public final static SpecialKey F6;
157:
158: /**
159: * The single static instance of <code>SpecialKey</code> which represents
160: * the 'F7' key.
161: */
162: public final static SpecialKey F7;
163:
164: /**
165: * The single static instance of <code>SpecialKey</code> which represents
166: * the 'F8' key.
167: */
168: public final static SpecialKey F8;
169:
170: /**
171: * The single static instance of <code>SpecialKey</code> which represents
172: * the 'F9' key.
173: */
174: public final static SpecialKey F9;
175:
176: /**
177: * The single static instance of <code>SpecialKey</code> which represents
178: * the 'Home' key.
179: */
180: public final static SpecialKey HOME;
181:
182: /**
183: * The single static instance of <code>SpecialKey</code> which represents
184: * the 'Insert' key.
185: */
186: public final static SpecialKey INSERT;
187:
188: /**
189: * The single static instance of <code>SpecialKey</code> which represents
190: * the 'NumLock' key.
191: */
192: public final static SpecialKey NUM_LOCK;
193:
194: /**
195: * The single static instance of <code>SpecialKey</code> which represents
196: * the '0' key on the numpad.
197: */
198: public final static SpecialKey NUMPAD_0;
199:
200: /**
201: * The single static instance of <code>SpecialKey</code> which represents
202: * the '1' key on the numpad.
203: */
204: public final static SpecialKey NUMPAD_1;
205:
206: /**
207: * The single static instance of <code>SpecialKey</code> which represents
208: * the '2' key on the numpad.
209: */
210: public final static SpecialKey NUMPAD_2;
211:
212: /**
213: * The single static instance of <code>SpecialKey</code> which represents
214: * the '3' key on the numpad.
215: */
216: public final static SpecialKey NUMPAD_3;
217:
218: /**
219: * The single static instance of <code>SpecialKey</code> which represents
220: * the '4' key on the numpad.
221: */
222: public final static SpecialKey NUMPAD_4;
223:
224: /**
225: * The single static instance of <code>SpecialKey</code> which represents
226: * the '5' key on the numpad.
227: */
228: public final static SpecialKey NUMPAD_5;
229:
230: /**
231: * The single static instance of <code>SpecialKey</code> which represents
232: * the '6' key on the numpad.
233: */
234: public final static SpecialKey NUMPAD_6;
235:
236: /**
237: * The single static instance of <code>SpecialKey</code> which represents
238: * the '7' key on the numpad.
239: */
240: public final static SpecialKey NUMPAD_7;
241:
242: /**
243: * The single static instance of <code>SpecialKey</code> which represents
244: * the '8' key on the numpad.
245: */
246: public final static SpecialKey NUMPAD_8;
247:
248: /**
249: * The single static instance of <code>SpecialKey</code> which represents
250: * the '9' key on the numpad.
251: */
252: public final static SpecialKey NUMPAD_9;
253:
254: /**
255: * The single static instance of <code>SpecialKey</code> which represents
256: * the 'Add' key on the numpad.
257: */
258: public final static SpecialKey NUMPAD_ADD;
259:
260: /**
261: * The single static instance of <code>SpecialKey</code> which represents
262: * the 'Decimal' key on the numpad.
263: */
264: public final static SpecialKey NUMPAD_DECIMAL;
265:
266: /**
267: * The single static instance of <code>SpecialKey</code> which represents
268: * the 'Divide' key on the numpad.
269: */
270: public final static SpecialKey NUMPAD_DIVIDE;
271:
272: /**
273: * The single static instance of <code>SpecialKey</code> which represents
274: * the 'Enter' key on the numpad.
275: */
276: public final static SpecialKey NUMPAD_ENTER;
277:
278: /**
279: * The single static instance of <code>SpecialKey</code> which represents
280: * the '=' key on the numpad.
281: */
282: public final static SpecialKey NUMPAD_EQUAL;
283:
284: /**
285: * The single static instance of <code>SpecialKey</code> which represents
286: * the 'Multiply' key on the numpad.
287: */
288: public final static SpecialKey NUMPAD_MULTIPLY;
289:
290: /**
291: * The single static instance of <code>SpecialKey</code> which represents
292: * the 'Subtract' key on the numpad.
293: */
294: public final static SpecialKey NUMPAD_SUBTRACT;
295:
296: /**
297: * The single static instance of <code>SpecialKey</code> which represents
298: * the 'Page Down' key.
299: */
300: public final static SpecialKey PAGE_DOWN;
301:
302: /**
303: * The single static instance of <code>SpecialKey</code> which represents
304: * the 'Page Up' key.
305: */
306: public final static SpecialKey PAGE_UP;
307:
308: /**
309: * The single static instance of <code>SpecialKey</code> which represents
310: * the 'Pause' key.
311: */
312: public final static SpecialKey PAUSE;
313:
314: /**
315: * The single static instance of <code>SpecialKey</code> which represents
316: * the 'Print Screen' key.
317: */
318: public final static SpecialKey PRINT_SCREEN;
319:
320: /**
321: * The single static instance of <code>SpecialKey</code> which represents
322: * the 'Scroll Lock' key.
323: */
324: public final static SpecialKey SCROLL_LOCK;
325:
326: static {
327: final IKeyLookup lookup = KeyLookupFactory.getDefault();
328: ARROW_DOWN = new SpecialKey(lookup
329: .formalKeyLookup(IKeyLookup.ARROW_DOWN_NAME));
330: ARROW_LEFT = new SpecialKey(lookup
331: .formalKeyLookup(IKeyLookup.ARROW_LEFT_NAME));
332: ARROW_RIGHT = new SpecialKey(lookup
333: .formalKeyLookup(IKeyLookup.ARROW_RIGHT_NAME));
334: ARROW_UP = new SpecialKey(lookup
335: .formalKeyLookup(IKeyLookup.ARROW_UP_NAME));
336: BREAK = new SpecialKey(lookup
337: .formalKeyLookup(IKeyLookup.BREAK_NAME));
338: CAPS_LOCK = new SpecialKey(lookup
339: .formalKeyLookup(IKeyLookup.CAPS_LOCK_NAME));
340: END = new SpecialKey(lookup
341: .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
352: .formalKeyLookup(IKeyLookup.F10_NAME));
353: F11 = new SpecialKey(lookup
354: .formalKeyLookup(IKeyLookup.F11_NAME));
355: F12 = new SpecialKey(lookup
356: .formalKeyLookup(IKeyLookup.F12_NAME));
357: F13 = new SpecialKey(lookup
358: .formalKeyLookup(IKeyLookup.F13_NAME));
359: F14 = new SpecialKey(lookup
360: .formalKeyLookup(IKeyLookup.F14_NAME));
361: F15 = new SpecialKey(lookup
362: .formalKeyLookup(IKeyLookup.F15_NAME));
363: HOME = new SpecialKey(lookup
364: .formalKeyLookup(IKeyLookup.HOME_NAME));
365: INSERT = new SpecialKey(lookup
366: .formalKeyLookup(IKeyLookup.INSERT_NAME));
367: NUM_LOCK = new SpecialKey(lookup
368: .formalKeyLookup(IKeyLookup.NUM_LOCK_NAME));
369: NUMPAD_0 = new SpecialKey(lookup
370: .formalKeyLookup(IKeyLookup.NUMPAD_0_NAME));
371: NUMPAD_1 = new SpecialKey(lookup
372: .formalKeyLookup(IKeyLookup.NUMPAD_1_NAME));
373: NUMPAD_2 = new SpecialKey(lookup
374: .formalKeyLookup(IKeyLookup.NUMPAD_2_NAME));
375: NUMPAD_3 = new SpecialKey(lookup
376: .formalKeyLookup(IKeyLookup.NUMPAD_3_NAME));
377: NUMPAD_4 = new SpecialKey(lookup
378: .formalKeyLookup(IKeyLookup.NUMPAD_4_NAME));
379: NUMPAD_5 = new SpecialKey(lookup
380: .formalKeyLookup(IKeyLookup.NUMPAD_5_NAME));
381: NUMPAD_6 = new SpecialKey(lookup
382: .formalKeyLookup(IKeyLookup.NUMPAD_6_NAME));
383: NUMPAD_7 = new SpecialKey(lookup
384: .formalKeyLookup(IKeyLookup.NUMPAD_7_NAME));
385: NUMPAD_8 = new SpecialKey(lookup
386: .formalKeyLookup(IKeyLookup.NUMPAD_8_NAME));
387: NUMPAD_9 = new SpecialKey(lookup
388: .formalKeyLookup(IKeyLookup.NUMPAD_9_NAME));
389: NUMPAD_ADD = new SpecialKey(lookup
390: .formalKeyLookup(IKeyLookup.NUMPAD_ADD_NAME));
391: NUMPAD_DECIMAL = new SpecialKey(lookup
392: .formalKeyLookup(IKeyLookup.NUMPAD_DECIMAL_NAME));
393: NUMPAD_DIVIDE = new SpecialKey(lookup
394: .formalKeyLookup(IKeyLookup.NUMPAD_DIVIDE_NAME));
395: NUMPAD_ENTER = new SpecialKey(lookup
396: .formalKeyLookup(IKeyLookup.NUMPAD_ENTER_NAME));
397: NUMPAD_EQUAL = new SpecialKey(lookup
398: .formalKeyLookup(IKeyLookup.NUMPAD_EQUAL_NAME));
399: NUMPAD_MULTIPLY = new SpecialKey(lookup
400: .formalKeyLookup(IKeyLookup.NUMPAD_MULTIPLY_NAME));
401: NUMPAD_SUBTRACT = new SpecialKey(lookup
402: .formalKeyLookup(IKeyLookup.NUMPAD_SUBTRACT_NAME));
403: PAGE_DOWN = new SpecialKey(lookup
404: .formalKeyLookup(IKeyLookup.PAGE_DOWN_NAME));
405: PAGE_UP = new SpecialKey(lookup
406: .formalKeyLookup(IKeyLookup.PAGE_UP_NAME));
407: PAUSE = new SpecialKey(lookup
408: .formalKeyLookup(IKeyLookup.PAUSE_NAME));
409: PRINT_SCREEN = new SpecialKey(lookup
410: .formalKeyLookup(IKeyLookup.PRINT_SCREEN_NAME));
411: SCROLL_LOCK = new SpecialKey(lookup
412: .formalKeyLookup(IKeyLookup.SCROLL_LOCK_NAME));
413:
414: specialKeysByName.put(SpecialKey.ARROW_DOWN.toString(),
415: SpecialKey.ARROW_DOWN);
416: specialKeysByName.put(SpecialKey.ARROW_LEFT.toString(),
417: SpecialKey.ARROW_LEFT);
418: specialKeysByName.put(SpecialKey.ARROW_RIGHT.toString(),
419: SpecialKey.ARROW_RIGHT);
420: specialKeysByName.put(SpecialKey.ARROW_UP.toString(),
421: SpecialKey.ARROW_UP);
422: specialKeysByName.put(SpecialKey.BREAK.toString(),
423: SpecialKey.BREAK);
424: specialKeysByName.put(SpecialKey.CAPS_LOCK.toString(),
425: SpecialKey.CAPS_LOCK);
426: specialKeysByName
427: .put(SpecialKey.END.toString(), SpecialKey.END);
428: specialKeysByName.put(SpecialKey.F1.toString(), SpecialKey.F1);
429: specialKeysByName
430: .put(SpecialKey.F10.toString(), SpecialKey.F10);
431: specialKeysByName
432: .put(SpecialKey.F11.toString(), SpecialKey.F11);
433: specialKeysByName
434: .put(SpecialKey.F12.toString(), SpecialKey.F12);
435: specialKeysByName
436: .put(SpecialKey.F13.toString(), SpecialKey.F13);
437: specialKeysByName
438: .put(SpecialKey.F14.toString(), SpecialKey.F14);
439: specialKeysByName
440: .put(SpecialKey.F15.toString(), SpecialKey.F15);
441: specialKeysByName.put(SpecialKey.F2.toString(), SpecialKey.F2);
442: specialKeysByName.put(SpecialKey.F3.toString(), SpecialKey.F3);
443: specialKeysByName.put(SpecialKey.F4.toString(), SpecialKey.F4);
444: specialKeysByName.put(SpecialKey.F5.toString(), SpecialKey.F5);
445: specialKeysByName.put(SpecialKey.F6.toString(), SpecialKey.F6);
446: specialKeysByName.put(SpecialKey.F7.toString(), SpecialKey.F7);
447: specialKeysByName.put(SpecialKey.F8.toString(), SpecialKey.F8);
448: specialKeysByName.put(SpecialKey.F9.toString(), SpecialKey.F9);
449: specialKeysByName.put(SpecialKey.NUM_LOCK.toString(),
450: SpecialKey.NUM_LOCK);
451: specialKeysByName.put(SpecialKey.NUMPAD_0.toString(),
452: SpecialKey.NUMPAD_0);
453: specialKeysByName.put(SpecialKey.NUMPAD_1.toString(),
454: SpecialKey.NUMPAD_1);
455: specialKeysByName.put(SpecialKey.NUMPAD_2.toString(),
456: SpecialKey.NUMPAD_2);
457: specialKeysByName.put(SpecialKey.NUMPAD_3.toString(),
458: SpecialKey.NUMPAD_3);
459: specialKeysByName.put(SpecialKey.NUMPAD_4.toString(),
460: SpecialKey.NUMPAD_4);
461: specialKeysByName.put(SpecialKey.NUMPAD_5.toString(),
462: SpecialKey.NUMPAD_5);
463: specialKeysByName.put(SpecialKey.NUMPAD_6.toString(),
464: SpecialKey.NUMPAD_6);
465: specialKeysByName.put(SpecialKey.NUMPAD_7.toString(),
466: SpecialKey.NUMPAD_7);
467: specialKeysByName.put(SpecialKey.NUMPAD_8.toString(),
468: SpecialKey.NUMPAD_8);
469: specialKeysByName.put(SpecialKey.NUMPAD_9.toString(),
470: SpecialKey.NUMPAD_9);
471: specialKeysByName.put(SpecialKey.NUMPAD_ADD.toString(),
472: SpecialKey.NUMPAD_ADD);
473: specialKeysByName.put(SpecialKey.NUMPAD_DECIMAL.toString(),
474: SpecialKey.NUMPAD_DECIMAL);
475: specialKeysByName.put(SpecialKey.NUMPAD_DIVIDE.toString(),
476: SpecialKey.NUMPAD_DIVIDE);
477: specialKeysByName.put(SpecialKey.NUMPAD_ENTER.toString(),
478: SpecialKey.NUMPAD_ENTER);
479: specialKeysByName.put(SpecialKey.NUMPAD_EQUAL.toString(),
480: SpecialKey.NUMPAD_EQUAL);
481: specialKeysByName.put(SpecialKey.NUMPAD_MULTIPLY.toString(),
482: SpecialKey.NUMPAD_MULTIPLY);
483: specialKeysByName.put(SpecialKey.NUMPAD_SUBTRACT.toString(),
484: SpecialKey.NUMPAD_SUBTRACT);
485: specialKeysByName.put(SpecialKey.HOME.toString(),
486: SpecialKey.HOME);
487: specialKeysByName.put(SpecialKey.INSERT.toString(),
488: SpecialKey.INSERT);
489: specialKeysByName.put(SpecialKey.PAGE_DOWN.toString(),
490: SpecialKey.PAGE_DOWN);
491: specialKeysByName.put(SpecialKey.PAGE_UP.toString(),
492: SpecialKey.PAGE_UP);
493: specialKeysByName.put(SpecialKey.PAUSE.toString(),
494: SpecialKey.PAUSE);
495: specialKeysByName.put(SpecialKey.PRINT_SCREEN.toString(),
496: SpecialKey.PRINT_SCREEN);
497: specialKeysByName.put(SpecialKey.SCROLL_LOCK.toString(),
498: SpecialKey.SCROLL_LOCK);
499: }
500:
501: /**
502: * Constructs an instance of <code>SpecialKey</code> given a name.
503: *
504: * @param key
505: * The key to be wrapped.
506: */
507: private SpecialKey(final int key) {
508: super(key);
509: }
510: }
|