Пример #1
0
 /** Reads in the property file. */
 static {
   try {
     final String file = "/completions.properties";
     final InputStream is = TextPanel.class.getResourceAsStream(file);
     if (is == null) {
       Util.errln(file + " not found.");
     } else {
       try (final NewlineInput nli = new NewlineInput(is)) {
         for (String line; (line = nli.readLine()) != null; ) {
           final int i = line.indexOf('=');
           if (i == -1 || line.startsWith("#")) continue;
           final String key = line.substring(0, i), value = line.substring(i + 1);
           if (REPLACE.put(key, value.replace("\\n", "\n")) != null) {
             Util.errln(file + ": " + key + " was assigned twice");
           }
         }
       }
     }
   } catch (final IOException ex) {
     Util.errln(ex);
   }
 }
Пример #2
0
  /**
   * Returns a keystroke for the specified string.
   *
   * @param cmd command
   * @return keystroke
   */
  public static KeyStroke keyStroke(final GUICommand cmd) {
    final Object sc = cmd.shortcuts();
    if (sc == null) return null;

    final String scut;
    if (sc instanceof BaseXKeys[]) {
      final BaseXKeys[] scs = (BaseXKeys[]) sc;
      if (scs.length == 0) return null;
      scut = scs[0].shortCut();
    } else {
      scut = Util.info(sc, META);
    }
    final KeyStroke ks = KeyStroke.getKeyStroke(scut);
    if (ks == null) Util.errln("Could not assign shortcut: " + sc + " / " + scut);
    return ks;
  }