1 11 12 package org.eclipse.jface.bindings.keys.formatting; 13 14 import org.eclipse.jface.bindings.keys.IKeyLookup; 15 import org.eclipse.jface.bindings.keys.KeyLookupFactory; 16 import org.eclipse.jface.bindings.keys.KeySequence; 17 import org.eclipse.jface.bindings.keys.KeyStroke; 18 19 27 public final class FormalKeyFormatter extends AbstractKeyFormatter { 28 29 34 public String format(final int key) { 35 final IKeyLookup lookup = KeyLookupFactory.getDefault(); 36 return lookup.formalNameLookup(key); 37 } 38 39 44 protected String getKeyDelimiter() { 45 return KeyStroke.KEY_DELIMITER; 46 } 47 48 53 protected String getKeyStrokeDelimiter() { 54 return KeySequence.KEY_STROKE_DELIMITER; 55 } 56 57 62 protected int[] sortModifierKeys(final int modifierKeys) { 63 final IKeyLookup lookup = KeyLookupFactory.getDefault(); 64 final int[] sortedKeys = new int[4]; 65 int index = 0; 66 67 if ((modifierKeys & lookup.getAlt()) != 0) { 68 sortedKeys[index++] = lookup.getAlt(); 69 } 70 if ((modifierKeys & lookup.getCommand()) != 0) { 71 sortedKeys[index++] = lookup.getCommand(); 72 } 73 if ((modifierKeys & lookup.getCtrl()) != 0) { 74 sortedKeys[index++] = lookup.getCtrl(); 75 } 76 if ((modifierKeys & lookup.getShift()) != 0) { 77 sortedKeys[index++] = lookup.getShift(); 78 } 79 80 return sortedKeys; 81 } 82 } 83 | Popular Tags |