/** Stores new key bindings into Preferences, provided they actually differ from the old ones. */
 public void setNewKeyBindings(HashMap<String, String> newBindings) {
   if (!newBindings.equals(keyBinds)) {
     // This confirms that the bindings have actually changed.
     String[] bindNames = new String[newBindings.size()],
         bindings = new String[newBindings.size()];
     int index = 0;
     for (Iterator<String> i = newBindings.keySet().iterator(); i.hasNext(); ) {
       String nm = i.next();
       String bnd = newBindings.get(nm);
       bindNames[index] = nm;
       bindings[index] = bnd;
       index++;
     }
     putStringArray("bindNames", bindNames);
     putStringArray("bindings", bindings);
     keyBinds = newBindings;
   }
 }
 /** Stores all information about the entry type in preferences, with the tag given by number. */
 public void storeCustomEntryType(CustomEntryType tp, int number) {
   String nr = "" + number;
   put(CUSTOM_TYPE_NAME + nr, tp.getName());
   putStringArray(CUSTOM_TYPE_REQ + nr, tp.getRequiredFields());
   putStringArray(CUSTOM_TYPE_OPT + nr, tp.getOptionalFields());
 }
Example #3
0
  /** Store changes to table preferences. This method is called when the user clicks Ok. */
  public void storeSettings() {
    _prefs.putBoolean("fileColumn", fileColumn.isSelected());
    _prefs.putBoolean("pdfColumn", pdfColumn.isSelected());
    _prefs.putBoolean("urlColumn", urlColumn.isSelected());
    _prefs.putBoolean("preferUrlDoi", preferDoi.isSelected());
    _prefs.putBoolean("arxivColumn", arxivColumn.isSelected());

    _prefs.putBoolean(
        JabRefPreferences.SHOWONELETTERHEADINGFORICONCOLUMNS,
        showOneLetterHeadingForIconColumns.isSelected());

    /** * begin: special fields ** */
    boolean newSpecialFieldsEnabled = specialFieldsEnabled.isSelected(),
        newRankingColumn = rankingColumn.isSelected(),
        newCompactRankingColumn = compactRankingColumn.isSelected(),
        newQualityColumn = qualityColumn.isSelected(),
        newPriorityColumn = priorityColumn.isSelected(),
        newRelevanceColumn = relevanceColumn.isSelected(),
        newSyncKeyWords = syncKeywords.isSelected(),
        newWriteSpecialFields = writeSpecialFields.isSelected();

    boolean restartRequired = false;
    restartRequired =
        (oldSpecialFieldsEnabled != newSpecialFieldsEnabled)
            || (oldRankingColumn != newRankingColumn)
            || (oldCompcatRankingColumn != newCompactRankingColumn)
            || (oldQualityColumn != newQualityColumn)
            || (oldPriorityColumn != newPriorityColumn)
            || (oldRelevanceColumn != newRelevanceColumn)
            || (oldSyncKeyWords != newSyncKeyWords)
            || (oldWriteSpecialFields != newWriteSpecialFields);
    if (restartRequired) {
      JOptionPane.showMessageDialog(
          null,
          Globals.lang("You have changed settings for special fields.")
              .concat(" ")
              .concat(Globals.lang("You must restart JabRef for this to come into effect.")),
          Globals.lang("Changed special field settings"),
          JOptionPane.WARNING_MESSAGE);
    }

    // restart required implies that the settings have been changed
    // the seetings need to be stored
    if (restartRequired) {
      _prefs.putBoolean(SpecialFieldsUtils.PREF_SPECIALFIELDSENABLED, newSpecialFieldsEnabled);
      _prefs.putBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_RANKING, newRankingColumn);
      _prefs.putBoolean(SpecialFieldsUtils.PREF_RANKING_COMPACT, newCompactRankingColumn);
      _prefs.putBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_PRIORITY, newPriorityColumn);
      _prefs.putBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_QUALITY, newQualityColumn);
      _prefs.putBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_RELEVANCE, newRelevanceColumn);
      _prefs.putBoolean(SpecialFieldsUtils.PREF_AUTOSYNCSPECIALFIELDSTOKEYWORDS, newSyncKeyWords);
      _prefs.putBoolean(SpecialFieldsUtils.PREF_SERIALIZESPECIALFIELDS, newWriteSpecialFields);
    }

    /** * end: special fields ** */
    if (colSetup.isEditing()) {
      int col = colSetup.getEditingColumn(), row = colSetup.getEditingRow();
      colSetup.getCellEditor(row, col).stopCellEditing();
    }

    // _prefs.putStringArray("columnNames", getChoices());
    /*String[] cols = tableFields.getText().replaceAll("\\s+","")
        .replaceAll("\\n+","").toLowerCase().split(";");
    if (cols.length > 0) for (int i=0; i<cols.length; i++)
        cols[i] = cols[i].trim();
        else cols = null;*/

    // Now we need to make sense of the contents the user has made to the
    // table setup table.
    if (tableChanged) {
      // First we remove all rows with empty names.
      int i = 0;
      while (i < tableRows.size()) {
        if (tableRows.elementAt(i).name.equals("")) tableRows.removeElementAt(i);
        else i++;
      }
      // Then we make arrays
      String[] names = new String[tableRows.size()], widths = new String[tableRows.size()];
      int[] nWidths = new int[tableRows.size()];

      _prefs.putInt("numberColWidth", ncWidth);
      for (i = 0; i < tableRows.size(); i++) {
        TableRow tr = tableRows.elementAt(i);
        names[i] = tr.name.toLowerCase();
        nWidths[i] = tr.length;
        widths[i] = "" + tr.length;
        // Util.pr(names[i]+"   "+widths[i]);
      }

      // Finally, we store the new preferences.
      _prefs.putStringArray("columnNames", names);
      _prefs.putStringArray("columnWidths", widths);
    }
  }