Ejemplo n.º 1
0
 /** Remove all types from the menu. Then cycle through all available values, and add them. */
 public static void populateSpecialFieldMenu(JMenu menu, SpecialField field, JabRefFrame frame) {
   menu.setText(field.getMenuString());
   menu.setIcon(((IconTheme.FontBasedIcon) field.getRepresentingIcon()).createSmallIcon());
   for (SpecialFieldValue val : field.getValues()) {
     menu.add(val.getMenuAction(frame));
   }
 }
Ejemplo n.º 2
0
 /** Remove all types from the menu. Then cycle through all available values, and add them. */
 public static void populateSpecialFieldMenu(JMenu menu, SpecialField field, JabRefFrame frame) {
   // menu.removeAll();
   menu.setText(field.getMenuString());
   menu.setIcon(field.getRepresentingIcon());
   for (SpecialFieldValue val : field.getValues()) {
     menu.add(val.getMenuAction(frame));
   }
 }
Ejemplo n.º 3
0
 /**
  * @param e - Field to be handled
  * @param value - may be null to state that field should be emptied
  * @param be - BibTeXEntry to be handled
  * @param ce - Filled with undo info (if necessary)
  * @param nullFieldIfValueIsTheSame - true: field is nulled if value is the same than the current
  *     value in be
  */
 public static void updateField(
     SpecialField e,
     String value,
     BibtexEntry be,
     NamedCompound ce,
     boolean nullFieldIfValueIsTheSame) {
   Util.updateField(be, e.getFieldName(), value, ce, nullFieldIfValueIsTheSame);
   // we cannot use "value" here as updateField has side effects: "nullFieldIfValueIsTheSame" nulls
   // the field if value is the same
   SpecialFieldsUtils.exportFieldToKeywords(e, be.getField(e.getFieldName()), be, ce);
 }
Ejemplo n.º 4
0
 private static void importKeywordsForField(
     ArrayList<String> keywordList, SpecialField c, BibtexEntry be, NamedCompound nc) {
   List<String> values = c.getKeyWords();
   String newValue = null;
   for (String val : values) {
     if (keywordList.contains(val)) {
       newValue = val;
       break;
     }
   }
   Util.updateField(be, c.getFieldName(), newValue, nc);
 }
Ejemplo n.º 5
0
  private static void exportFieldToKeywords(
      SpecialField e, String newValue, BibtexEntry be, NamedCompound ce) {
    if (!SpecialFieldsUtils.keywordSyncEnabled()) {
      return;
    }
    ArrayList<String> keywordList = Util.getSeparatedKeywords(be);
    List<String> values = e.getKeyWords();

    int foundPos = -1;

    // cleanup keywords
    for (Object value : values) {
      int pos = keywordList.indexOf(value);
      if (pos >= 0) {
        foundPos = pos;
        keywordList.remove(pos);
      }
    }

    if (newValue != null) {
      if (foundPos == -1) {
        keywordList.add(newValue);
      } else {
        keywordList.add(foundPos, newValue);
      }
    }
    Util.putKeywords(be, keywordList, ce);
  }
Ejemplo n.º 6
0
 private static void exportFieldToKeywords(SpecialField e, BibtexEntry be, NamedCompound ce) {
   SpecialFieldsUtils.exportFieldToKeywords(e, be.getField(e.getFieldName()), be, ce);
 }