1 11 12 package org.eclipse.ui.keys; 13 14 import java.util.SortedMap ; 15 import java.util.TreeMap ; 16 17 import org.eclipse.jface.bindings.keys.IKeyLookup; 18 import org.eclipse.jface.bindings.keys.KeyLookupFactory; 19 20 34 public final class CharacterKey extends NaturalKey { 35 36 40 static SortedMap characterKeysByName = new TreeMap (); 41 42 46 public final static CharacterKey BS; 47 48 52 public final static CharacterKey CR; 53 54 58 public final static CharacterKey DEL; 59 60 64 public final static CharacterKey ESC; 65 66 70 public final static CharacterKey FF; 71 72 76 public final static CharacterKey LF; 77 78 82 public final static CharacterKey NUL; 83 84 88 public final static CharacterKey SPACE; 89 90 94 public final static CharacterKey TAB; 95 96 100 public final static CharacterKey VT; 101 102 114 public static final CharacterKey getInstance(final char character) { 115 return new CharacterKey(character); 116 } 117 118 static { 119 final IKeyLookup lookup = KeyLookupFactory.getDefault(); 120 BS = new CharacterKey(lookup.formalKeyLookup(IKeyLookup.BS_NAME)); 121 CR = new CharacterKey(lookup.formalKeyLookup(IKeyLookup.CR_NAME)); 122 DEL = new CharacterKey(lookup.formalKeyLookup(IKeyLookup.DEL_NAME)); 123 ESC = new CharacterKey(lookup.formalKeyLookup(IKeyLookup.ESC_NAME)); 124 FF = new CharacterKey(lookup.formalKeyLookup(IKeyLookup.FF_NAME)); 125 LF = new CharacterKey(lookup.formalKeyLookup(IKeyLookup.LF_NAME)); 126 NUL = new CharacterKey(lookup.formalKeyLookup(IKeyLookup.NUL_NAME)); 127 SPACE = new CharacterKey(lookup.formalKeyLookup(IKeyLookup.SPACE_NAME)); 128 TAB = new CharacterKey(lookup.formalKeyLookup(IKeyLookup.TAB_NAME)); 129 VT = new CharacterKey(lookup.formalKeyLookup(IKeyLookup.VT_NAME)); 130 131 characterKeysByName.put(IKeyLookup.BS_NAME, CharacterKey.BS); 132 characterKeysByName.put(IKeyLookup.BACKSPACE_NAME, CharacterKey.BS); 133 characterKeysByName.put(IKeyLookup.CR_NAME, CharacterKey.CR); 134 characterKeysByName.put(IKeyLookup.ENTER_NAME, CharacterKey.CR); 135 characterKeysByName.put(IKeyLookup.RETURN_NAME, CharacterKey.CR); 136 characterKeysByName.put(IKeyLookup.DEL_NAME, CharacterKey.DEL); 137 characterKeysByName.put(IKeyLookup.DELETE_NAME, CharacterKey.DEL); 138 characterKeysByName.put(IKeyLookup.ESC_NAME, CharacterKey.ESC); 139 characterKeysByName.put(IKeyLookup.ESCAPE_NAME, CharacterKey.ESC); 140 characterKeysByName.put(IKeyLookup.FF_NAME, CharacterKey.FF); 141 characterKeysByName.put(IKeyLookup.LF_NAME, CharacterKey.LF); 142 characterKeysByName.put(IKeyLookup.NUL_NAME, CharacterKey.NUL); 143 characterKeysByName.put(IKeyLookup.SPACE_NAME, CharacterKey.SPACE); 144 characterKeysByName.put(IKeyLookup.TAB_NAME, CharacterKey.TAB); 145 characterKeysByName.put(IKeyLookup.VT_NAME, CharacterKey.VT); 146 } 147 148 155 private CharacterKey(final int key) { 156 super(key); 157 } 158 159 164 public final char getCharacter() { 165 return (char) key; 166 } 167 } 168 | Popular Tags |