/projects/eclipse_SDK-3.7.1/plugins/org.eclipse.ui.workbench.source_3.7.0.I20110519-0100/org/eclipse/ui/keys/SpecialKey.java

https://gitlab.com/essere.lab.public/qualitas.class-corpus · Java · 490 lines · 209 code · 55 blank · 226 comment · 0 complexity · 3b2db1b0b6e82b68ed1332484c1e4c89 MD5 · raw file

  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. package org.eclipse.ui.keys;
  12. import java.util.SortedMap;
  13. import java.util.TreeMap;
  14. import org.eclipse.jface.bindings.keys.IKeyLookup;
  15. import org.eclipse.jface.bindings.keys.KeyLookupFactory;
  16. /**
  17. * <p>
  18. * Instances of <code>SpecialKey</code> represent the keys on keyboard
  19. * recognized as neither modifier keys nor character keys. These are special
  20. * control keys specific to computers (e.g., "left arrow", "page down", "F10",
  21. * etc.). They do not include keys representing letters, numbers or punctuation
  22. * from a natural language, nor do they include any key that can be represented
  23. * by a Unicode character (e.g., "backspace").
  24. * </p>
  25. * <p>
  26. * <code>SpecialKey</code> objects are immutable. Clients are not permitted to
  27. * extend this class.
  28. * </p>
  29. *
  30. * @deprecated Please use org.eclipse.jface.bindings.keys.KeyStroke and
  31. * org.eclipse.jface.bindings.keys.KeyLookupFactory
  32. * @since 3.0
  33. */
  34. public final class SpecialKey extends NaturalKey {
  35. /**
  36. * An internal map used to lookup instances of <code>SpecialKey</code>
  37. * given the formal string representation of a special key.
  38. */
  39. static SortedMap specialKeysByName = new TreeMap();
  40. /**
  41. * The single static instance of <code>SpecialKey</code> which represents
  42. * the 'Arrow Down' key.
  43. */
  44. public final static SpecialKey ARROW_DOWN;
  45. /**
  46. * The single static instance of <code>SpecialKey</code> which represents
  47. * the 'Arrow Left' key.
  48. */
  49. public final static SpecialKey ARROW_LEFT;
  50. /**
  51. * The single static instance of <code>SpecialKey</code> which represents
  52. * the 'Arrow Right' key.
  53. */
  54. public final static SpecialKey ARROW_RIGHT;
  55. /**
  56. * The single static instance of <code>SpecialKey</code> which represents
  57. * the 'Arrow Up' key.
  58. */
  59. public final static SpecialKey ARROW_UP;
  60. /**
  61. * The single static instance of <code>SpecialKey</code> which represents
  62. * the 'Break' key.
  63. */
  64. public final static SpecialKey BREAK;
  65. /**
  66. * The single static instance of <code>SpecialKey</code> which represents
  67. * the 'Caps Lock' key.
  68. */
  69. public final static SpecialKey CAPS_LOCK;
  70. /**
  71. * The single static instance of <code>SpecialKey</code> which represents
  72. * the 'End' key.
  73. */
  74. public final static SpecialKey END;
  75. /**
  76. * The single static instance of <code>SpecialKey</code> which represents
  77. * the 'F1' key.
  78. */
  79. public final static SpecialKey F1;
  80. /**
  81. * The single static instance of <code>SpecialKey</code> which represents
  82. * the 'F10' key.
  83. */
  84. public final static SpecialKey F10;
  85. /**
  86. * The single static instance of <code>SpecialKey</code> which represents
  87. * the 'F11' key.
  88. */
  89. public final static SpecialKey F11;
  90. /**
  91. * The single static instance of <code>SpecialKey</code> which represents
  92. * the 'F12' key.
  93. */
  94. public final static SpecialKey F12;
  95. /**
  96. * The single static instance of <code>SpecialKey</code> which represents
  97. * the 'F13' key.
  98. */
  99. public final static SpecialKey F13;
  100. /**
  101. * The single static instance of <code>SpecialKey</code> which represents
  102. * the 'F14' key.
  103. */
  104. public final static SpecialKey F14;
  105. /**
  106. * The single static instance of <code>SpecialKey</code> which represents
  107. * the 'F15' key.
  108. */
  109. public final static SpecialKey F15;
  110. /**
  111. * The single static instance of <code>SpecialKey</code> which represents
  112. * the 'F2' key.
  113. */
  114. public final static SpecialKey F2;
  115. /**
  116. * The single static instance of <code>SpecialKey</code> which represents
  117. * the 'F3' key.
  118. */
  119. public final static SpecialKey F3;
  120. /**
  121. * The single static instance of <code>SpecialKey</code> which represents
  122. * the 'F4' key.
  123. */
  124. public final static SpecialKey F4;
  125. /**
  126. * The single static instance of <code>SpecialKey</code> which represents
  127. * the 'F5' key.
  128. */
  129. public final static SpecialKey F5;
  130. /**
  131. * The single static instance of <code>SpecialKey</code> which represents
  132. * the 'F6' key.
  133. */
  134. public final static SpecialKey F6;
  135. /**
  136. * The single static instance of <code>SpecialKey</code> which represents
  137. * the 'F7' key.
  138. */
  139. public final static SpecialKey F7;
  140. /**
  141. * The single static instance of <code>SpecialKey</code> which represents
  142. * the 'F8' key.
  143. */
  144. public final static SpecialKey F8;
  145. /**
  146. * The single static instance of <code>SpecialKey</code> which represents
  147. * the 'F9' key.
  148. */
  149. public final static SpecialKey F9;
  150. /**
  151. * The single static instance of <code>SpecialKey</code> which represents
  152. * the 'Home' key.
  153. */
  154. public final static SpecialKey HOME;
  155. /**
  156. * The single static instance of <code>SpecialKey</code> which represents
  157. * the 'Insert' key.
  158. */
  159. public final static SpecialKey INSERT;
  160. /**
  161. * The single static instance of <code>SpecialKey</code> which represents
  162. * the 'NumLock' key.
  163. */
  164. public final static SpecialKey NUM_LOCK;
  165. /**
  166. * The single static instance of <code>SpecialKey</code> which represents
  167. * the '0' key on the numpad.
  168. */
  169. public final static SpecialKey NUMPAD_0;
  170. /**
  171. * The single static instance of <code>SpecialKey</code> which represents
  172. * the '1' key on the numpad.
  173. */
  174. public final static SpecialKey NUMPAD_1;
  175. /**
  176. * The single static instance of <code>SpecialKey</code> which represents
  177. * the '2' key on the numpad.
  178. */
  179. public final static SpecialKey NUMPAD_2;
  180. /**
  181. * The single static instance of <code>SpecialKey</code> which represents
  182. * the '3' key on the numpad.
  183. */
  184. public final static SpecialKey NUMPAD_3;
  185. /**
  186. * The single static instance of <code>SpecialKey</code> which represents
  187. * the '4' key on the numpad.
  188. */
  189. public final static SpecialKey NUMPAD_4;
  190. /**
  191. * The single static instance of <code>SpecialKey</code> which represents
  192. * the '5' key on the numpad.
  193. */
  194. public final static SpecialKey NUMPAD_5;
  195. /**
  196. * The single static instance of <code>SpecialKey</code> which represents
  197. * the '6' key on the numpad.
  198. */
  199. public final static SpecialKey NUMPAD_6;
  200. /**
  201. * The single static instance of <code>SpecialKey</code> which represents
  202. * the '7' key on the numpad.
  203. */
  204. public final static SpecialKey NUMPAD_7;
  205. /**
  206. * The single static instance of <code>SpecialKey</code> which represents
  207. * the '8' key on the numpad.
  208. */
  209. public final static SpecialKey NUMPAD_8;
  210. /**
  211. * The single static instance of <code>SpecialKey</code> which represents
  212. * the '9' key on the numpad.
  213. */
  214. public final static SpecialKey NUMPAD_9;
  215. /**
  216. * The single static instance of <code>SpecialKey</code> which represents
  217. * the 'Add' key on the numpad.
  218. */
  219. public final static SpecialKey NUMPAD_ADD;
  220. /**
  221. * The single static instance of <code>SpecialKey</code> which represents
  222. * the 'Decimal' key on the numpad.
  223. */
  224. public final static SpecialKey NUMPAD_DECIMAL;
  225. /**
  226. * The single static instance of <code>SpecialKey</code> which represents
  227. * the 'Divide' key on the numpad.
  228. */
  229. public final static SpecialKey NUMPAD_DIVIDE;
  230. /**
  231. * The single static instance of <code>SpecialKey</code> which represents
  232. * the 'Enter' key on the numpad.
  233. */
  234. public final static SpecialKey NUMPAD_ENTER;
  235. /**
  236. * The single static instance of <code>SpecialKey</code> which represents
  237. * the '=' key on the numpad.
  238. */
  239. public final static SpecialKey NUMPAD_EQUAL;
  240. /**
  241. * The single static instance of <code>SpecialKey</code> which represents
  242. * the 'Multiply' key on the numpad.
  243. */
  244. public final static SpecialKey NUMPAD_MULTIPLY;
  245. /**
  246. * The single static instance of <code>SpecialKey</code> which represents
  247. * the 'Subtract' key on the numpad.
  248. */
  249. public final static SpecialKey NUMPAD_SUBTRACT;
  250. /**
  251. * The single static instance of <code>SpecialKey</code> which represents
  252. * the 'Page Down' key.
  253. */
  254. public final static SpecialKey PAGE_DOWN;
  255. /**
  256. * The single static instance of <code>SpecialKey</code> which represents
  257. * the 'Page Up' key.
  258. */
  259. public final static SpecialKey PAGE_UP;
  260. /**
  261. * The single static instance of <code>SpecialKey</code> which represents
  262. * the 'Pause' key.
  263. */
  264. public final static SpecialKey PAUSE;
  265. /**
  266. * The single static instance of <code>SpecialKey</code> which represents
  267. * the 'Print Screen' key.
  268. */
  269. public final static SpecialKey PRINT_SCREEN;
  270. /**
  271. * The single static instance of <code>SpecialKey</code> which represents
  272. * the 'Scroll Lock' key.
  273. */
  274. public final static SpecialKey SCROLL_LOCK;
  275. static {
  276. final IKeyLookup lookup = KeyLookupFactory.getDefault();
  277. ARROW_DOWN = new SpecialKey(lookup
  278. .formalKeyLookup(IKeyLookup.ARROW_DOWN_NAME));
  279. ARROW_LEFT = new SpecialKey(lookup
  280. .formalKeyLookup(IKeyLookup.ARROW_LEFT_NAME));
  281. ARROW_RIGHT = new SpecialKey(lookup
  282. .formalKeyLookup(IKeyLookup.ARROW_RIGHT_NAME));
  283. ARROW_UP = new SpecialKey(lookup
  284. .formalKeyLookup(IKeyLookup.ARROW_UP_NAME));
  285. BREAK = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.BREAK_NAME));
  286. CAPS_LOCK = new SpecialKey(lookup
  287. .formalKeyLookup(IKeyLookup.CAPS_LOCK_NAME));
  288. END = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.END_NAME));
  289. F1 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F1_NAME));
  290. F2 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F2_NAME));
  291. F3 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F3_NAME));
  292. F4 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F4_NAME));
  293. F5 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F5_NAME));
  294. F6 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F6_NAME));
  295. F7 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F7_NAME));
  296. F8 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F8_NAME));
  297. F9 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F9_NAME));
  298. F10 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F10_NAME));
  299. F11 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F11_NAME));
  300. F12 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F12_NAME));
  301. F13 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F13_NAME));
  302. F14 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F14_NAME));
  303. F15 = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.F15_NAME));
  304. HOME = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.HOME_NAME));
  305. INSERT = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.INSERT_NAME));
  306. NUM_LOCK = new SpecialKey(lookup
  307. .formalKeyLookup(IKeyLookup.NUM_LOCK_NAME));
  308. NUMPAD_0 = new SpecialKey(lookup
  309. .formalKeyLookup(IKeyLookup.NUMPAD_0_NAME));
  310. NUMPAD_1 = new SpecialKey(lookup
  311. .formalKeyLookup(IKeyLookup.NUMPAD_1_NAME));
  312. NUMPAD_2 = new SpecialKey(lookup
  313. .formalKeyLookup(IKeyLookup.NUMPAD_2_NAME));
  314. NUMPAD_3 = new SpecialKey(lookup
  315. .formalKeyLookup(IKeyLookup.NUMPAD_3_NAME));
  316. NUMPAD_4 = new SpecialKey(lookup
  317. .formalKeyLookup(IKeyLookup.NUMPAD_4_NAME));
  318. NUMPAD_5 = new SpecialKey(lookup
  319. .formalKeyLookup(IKeyLookup.NUMPAD_5_NAME));
  320. NUMPAD_6 = new SpecialKey(lookup
  321. .formalKeyLookup(IKeyLookup.NUMPAD_6_NAME));
  322. NUMPAD_7 = new SpecialKey(lookup
  323. .formalKeyLookup(IKeyLookup.NUMPAD_7_NAME));
  324. NUMPAD_8 = new SpecialKey(lookup
  325. .formalKeyLookup(IKeyLookup.NUMPAD_8_NAME));
  326. NUMPAD_9 = new SpecialKey(lookup
  327. .formalKeyLookup(IKeyLookup.NUMPAD_9_NAME));
  328. NUMPAD_ADD = new SpecialKey(lookup
  329. .formalKeyLookup(IKeyLookup.NUMPAD_ADD_NAME));
  330. NUMPAD_DECIMAL = new SpecialKey(lookup
  331. .formalKeyLookup(IKeyLookup.NUMPAD_DECIMAL_NAME));
  332. NUMPAD_DIVIDE = new SpecialKey(lookup
  333. .formalKeyLookup(IKeyLookup.NUMPAD_DIVIDE_NAME));
  334. NUMPAD_ENTER = new SpecialKey(lookup
  335. .formalKeyLookup(IKeyLookup.NUMPAD_ENTER_NAME));
  336. NUMPAD_EQUAL = new SpecialKey(lookup
  337. .formalKeyLookup(IKeyLookup.NUMPAD_EQUAL_NAME));
  338. NUMPAD_MULTIPLY = new SpecialKey(lookup
  339. .formalKeyLookup(IKeyLookup.NUMPAD_MULTIPLY_NAME));
  340. NUMPAD_SUBTRACT = new SpecialKey(lookup
  341. .formalKeyLookup(IKeyLookup.NUMPAD_SUBTRACT_NAME));
  342. PAGE_DOWN = new SpecialKey(lookup
  343. .formalKeyLookup(IKeyLookup.PAGE_DOWN_NAME));
  344. PAGE_UP = new SpecialKey(lookup
  345. .formalKeyLookup(IKeyLookup.PAGE_UP_NAME));
  346. PAUSE = new SpecialKey(lookup.formalKeyLookup(IKeyLookup.PAUSE_NAME));
  347. PRINT_SCREEN = new SpecialKey(lookup
  348. .formalKeyLookup(IKeyLookup.PRINT_SCREEN_NAME));
  349. SCROLL_LOCK = new SpecialKey(lookup
  350. .formalKeyLookup(IKeyLookup.SCROLL_LOCK_NAME));
  351. specialKeysByName.put(SpecialKey.ARROW_DOWN.toString(),
  352. SpecialKey.ARROW_DOWN);
  353. specialKeysByName.put(SpecialKey.ARROW_LEFT.toString(),
  354. SpecialKey.ARROW_LEFT);
  355. specialKeysByName.put(SpecialKey.ARROW_RIGHT.toString(),
  356. SpecialKey.ARROW_RIGHT);
  357. specialKeysByName.put(SpecialKey.ARROW_UP.toString(),
  358. SpecialKey.ARROW_UP);
  359. specialKeysByName.put(SpecialKey.BREAK.toString(), SpecialKey.BREAK);
  360. specialKeysByName.put(SpecialKey.CAPS_LOCK.toString(),
  361. SpecialKey.CAPS_LOCK);
  362. specialKeysByName.put(SpecialKey.END.toString(), SpecialKey.END);
  363. specialKeysByName.put(SpecialKey.F1.toString(), SpecialKey.F1);
  364. specialKeysByName.put(SpecialKey.F10.toString(), SpecialKey.F10);
  365. specialKeysByName.put(SpecialKey.F11.toString(), SpecialKey.F11);
  366. specialKeysByName.put(SpecialKey.F12.toString(), SpecialKey.F12);
  367. specialKeysByName.put(SpecialKey.F13.toString(), SpecialKey.F13);
  368. specialKeysByName.put(SpecialKey.F14.toString(), SpecialKey.F14);
  369. specialKeysByName.put(SpecialKey.F15.toString(), SpecialKey.F15);
  370. specialKeysByName.put(SpecialKey.F2.toString(), SpecialKey.F2);
  371. specialKeysByName.put(SpecialKey.F3.toString(), SpecialKey.F3);
  372. specialKeysByName.put(SpecialKey.F4.toString(), SpecialKey.F4);
  373. specialKeysByName.put(SpecialKey.F5.toString(), SpecialKey.F5);
  374. specialKeysByName.put(SpecialKey.F6.toString(), SpecialKey.F6);
  375. specialKeysByName.put(SpecialKey.F7.toString(), SpecialKey.F7);
  376. specialKeysByName.put(SpecialKey.F8.toString(), SpecialKey.F8);
  377. specialKeysByName.put(SpecialKey.F9.toString(), SpecialKey.F9);
  378. specialKeysByName.put(SpecialKey.NUM_LOCK.toString(),
  379. SpecialKey.NUM_LOCK);
  380. specialKeysByName.put(SpecialKey.NUMPAD_0.toString(),
  381. SpecialKey.NUMPAD_0);
  382. specialKeysByName.put(SpecialKey.NUMPAD_1.toString(),
  383. SpecialKey.NUMPAD_1);
  384. specialKeysByName.put(SpecialKey.NUMPAD_2.toString(),
  385. SpecialKey.NUMPAD_2);
  386. specialKeysByName.put(SpecialKey.NUMPAD_3.toString(),
  387. SpecialKey.NUMPAD_3);
  388. specialKeysByName.put(SpecialKey.NUMPAD_4.toString(),
  389. SpecialKey.NUMPAD_4);
  390. specialKeysByName.put(SpecialKey.NUMPAD_5.toString(),
  391. SpecialKey.NUMPAD_5);
  392. specialKeysByName.put(SpecialKey.NUMPAD_6.toString(),
  393. SpecialKey.NUMPAD_6);
  394. specialKeysByName.put(SpecialKey.NUMPAD_7.toString(),
  395. SpecialKey.NUMPAD_7);
  396. specialKeysByName.put(SpecialKey.NUMPAD_8.toString(),
  397. SpecialKey.NUMPAD_8);
  398. specialKeysByName.put(SpecialKey.NUMPAD_9.toString(),
  399. SpecialKey.NUMPAD_9);
  400. specialKeysByName.put(SpecialKey.NUMPAD_ADD.toString(),
  401. SpecialKey.NUMPAD_ADD);
  402. specialKeysByName.put(SpecialKey.NUMPAD_DECIMAL.toString(),
  403. SpecialKey.NUMPAD_DECIMAL);
  404. specialKeysByName.put(SpecialKey.NUMPAD_DIVIDE.toString(),
  405. SpecialKey.NUMPAD_DIVIDE);
  406. specialKeysByName.put(SpecialKey.NUMPAD_ENTER.toString(),
  407. SpecialKey.NUMPAD_ENTER);
  408. specialKeysByName.put(SpecialKey.NUMPAD_EQUAL.toString(),
  409. SpecialKey.NUMPAD_EQUAL);
  410. specialKeysByName.put(SpecialKey.NUMPAD_MULTIPLY.toString(),
  411. SpecialKey.NUMPAD_MULTIPLY);
  412. specialKeysByName.put(SpecialKey.NUMPAD_SUBTRACT.toString(),
  413. SpecialKey.NUMPAD_SUBTRACT);
  414. specialKeysByName.put(SpecialKey.HOME.toString(), SpecialKey.HOME);
  415. specialKeysByName.put(SpecialKey.INSERT.toString(), SpecialKey.INSERT);
  416. specialKeysByName.put(SpecialKey.PAGE_DOWN.toString(),
  417. SpecialKey.PAGE_DOWN);
  418. specialKeysByName
  419. .put(SpecialKey.PAGE_UP.toString(), SpecialKey.PAGE_UP);
  420. specialKeysByName.put(SpecialKey.PAUSE.toString(), SpecialKey.PAUSE);
  421. specialKeysByName.put(SpecialKey.PRINT_SCREEN.toString(),
  422. SpecialKey.PRINT_SCREEN);
  423. specialKeysByName.put(SpecialKey.SCROLL_LOCK.toString(),
  424. SpecialKey.SCROLL_LOCK);
  425. }
  426. /**
  427. * Constructs an instance of <code>SpecialKey</code> given a name.
  428. *
  429. * @param key
  430. * The key to be wrapped.
  431. */
  432. private SpecialKey(final int key) {
  433. super(key);
  434. }
  435. }