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 import org.eclipse.swt.SWT; 20 21 38 public final class ModifierKey extends Key { 39 40 44 static SortedMap modifierKeysByName = new TreeMap (); 45 46 50 public final static ModifierKey ALT; 51 52 56 public final static ModifierKey COMMAND; 57 58 62 public final static ModifierKey CTRL; 63 64 67 private final static String M1_NAME = "M1"; 69 72 private final static String M2_NAME = "M2"; 74 77 private final static String M3_NAME = "M3"; 79 82 private final static String M4_NAME = "M4"; 84 88 public final static ModifierKey SHIFT; 89 90 static { 91 final IKeyLookup lookup = KeyLookupFactory.getDefault(); 92 ALT = new ModifierKey(lookup.getAlt()); 93 COMMAND = new ModifierKey(lookup.getCommand()); 94 CTRL = new ModifierKey(lookup.getCtrl()); 95 SHIFT = new ModifierKey(lookup.getShift()); 96 97 modifierKeysByName.put(ModifierKey.ALT.toString(), ModifierKey.ALT); 98 modifierKeysByName.put(ModifierKey.COMMAND.toString(), 99 ModifierKey.COMMAND); 100 modifierKeysByName.put(ModifierKey.CTRL.toString(), ModifierKey.CTRL); 101 modifierKeysByName.put(ModifierKey.SHIFT.toString(), ModifierKey.SHIFT); 102 modifierKeysByName 103 .put( 104 M1_NAME, 105 "carbon".equals(SWT.getPlatform()) ? ModifierKey.COMMAND : ModifierKey.CTRL); modifierKeysByName.put(M2_NAME, ModifierKey.SHIFT); 107 modifierKeysByName.put(M3_NAME, ModifierKey.ALT); 108 modifierKeysByName 109 .put( 110 M4_NAME, 111 "carbon".equals(SWT.getPlatform()) ? ModifierKey.CTRL : ModifierKey.COMMAND); } 113 114 120 private ModifierKey(final int key) { 121 super(key); 122 } 123 } 124 | Popular Tags |