1 11 12 package org.eclipse.ui.internal.keys; 13 14 import java.util.Comparator ; 15 import java.util.ResourceBundle ; 16 17 import org.eclipse.ui.internal.util.Util; 18 import org.eclipse.ui.keys.Key; 19 import org.eclipse.ui.keys.KeySequence; 20 import org.eclipse.ui.keys.KeyStroke; 21 import org.eclipse.ui.keys.ModifierKey; 22 23 29 public class EmacsKeyFormatter extends AbstractKeyFormatter { 30 31 35 private static final Comparator EMACS_MODIFIER_KEY_COMPARATOR = new AlphabeticModifierKeyComparator(); 36 37 41 private final static ResourceBundle RESOURCE_BUNDLE = ResourceBundle 42 .getBundle(EmacsKeyFormatter.class.getName()); 43 44 52 public String format(Key key) { 53 if (key instanceof ModifierKey) { 54 String formattedName = Util.translateString(RESOURCE_BUNDLE, key 55 .toString(), null, false, false); 56 if (formattedName != null) { 57 return formattedName; 58 } 59 } 60 61 return super.format(key).toLowerCase(); 62 } 63 64 69 protected String getKeyDelimiter() { 70 return Util.translateString(RESOURCE_BUNDLE, KEY_DELIMITER_KEY, 71 KeyStroke.KEY_DELIMITER, false, false); 72 } 73 74 79 protected String getKeyStrokeDelimiter() { 80 return Util.translateString(RESOURCE_BUNDLE, KEY_STROKE_DELIMITER_KEY, 81 KeySequence.KEY_STROKE_DELIMITER, false, false); 82 } 83 84 89 protected Comparator getModifierKeyComparator() { 90 return EMACS_MODIFIER_KEY_COMPARATOR; 91 } 92 93 } 94 | Popular Tags |