public LabelPattern getKeyPattern() {

    keyPattern = new LabelPattern(KEY_PATTERN);
    Preferences pre = Preferences.userNodeForPackage(net.sf.jabref.labelPattern.LabelPattern.class);
    try {
      String[] keys = pre.keys();
      if (keys.length > 0)
        for (int i = 0; i < keys.length; i++)
          keyPattern.addLabelPattern(keys[i], pre.get(keys[i], null));
    } catch (BackingStoreException ex) {
      Globals.logger("BackingStoreException in JabRefPreferences.getKeyPattern");
    }

    ///
    // keyPattern.addLabelPattern("article", "[author][year]");
    // putKeyPattern(keyPattern);
    ///

    return keyPattern;
  }
  public void putKeyPattern(LabelPattern pattern) {
    keyPattern = pattern;
    LabelPattern parent = pattern.getParent();
    if (parent == null) return;

    // Store overridden definitions to Preferences.
    Preferences pre = Preferences.userNodeForPackage(net.sf.jabref.labelPattern.LabelPattern.class);
    try {
      pre.clear(); // We remove all old entries.
    } catch (BackingStoreException ex) {
      Globals.logger("BackingStoreException in JabRefPreferences.putKeyPattern");
    }

    for (String s : pattern.keySet()) {
      if (!(pattern.get(s)).equals(parent.get(s)))
        pre.put(s, pattern.getValue(s).get(0).toString());
    }
  }