Пример #1
0
  /** Store changes to table preferences. This method is called when the user clicks Ok. */
  @Override
  public void storeSettings() {

    prefs.putBoolean(JabRefPreferences.NAMES_AS_IS, namesAsIs.isSelected());
    prefs.putBoolean(JabRefPreferences.NAMES_FIRST_LAST, namesFf.isSelected());
    prefs.putBoolean(JabRefPreferences.NAMES_NATBIB, namesNatbib.isSelected());
    prefs.putBoolean(JabRefPreferences.NAMES_LAST_ONLY, lastNamesOnly.isSelected());
    prefs.putBoolean(JabRefPreferences.ABBR_AUTHOR_NAMES, abbrNames.isSelected());

    prefs.putInt(
        JabRefPreferences.AUTO_RESIZE_MODE,
        autoResizeMode.isSelected() ? JTable.AUTO_RESIZE_ALL_COLUMNS : JTable.AUTO_RESIZE_OFF);
    prefs.putBoolean(JabRefPreferences.PRIMARY_SORT_DESCENDING, priDesc.isSelected());
    prefs.putBoolean(JabRefPreferences.SECONDARY_SORT_DESCENDING, secDesc.isSelected());
    prefs.putBoolean(JabRefPreferences.TERTIARY_SORT_DESCENDING, terDesc.isSelected());
    prefs.put(JabRefPreferences.PRIMARY_SORT_FIELD, priField.getText().toLowerCase().trim());
    prefs.put(JabRefPreferences.SECONDARY_SORT_FIELD, secField.getText().toLowerCase().trim());
    prefs.put(JabRefPreferences.TERTIARY_SORT_FIELD, terField.getText().toLowerCase().trim());

    prefs.putBoolean(JabRefPreferences.FLOAT_MARKED_ENTRIES, floatMarked.isSelected());
    // updatefont

    String oldVal = prefs.get(JabRefPreferences.NUMERIC_FIELDS);
    String newVal = numericFields.getText().trim();
    if (newVal.isEmpty()) {
      newVal = null;
    }
    if (newVal != null && oldVal == null
        || newVal == null && oldVal != null
        || newVal != null && !newVal.equals(oldVal)) {
      prefs.put(JabRefPreferences.NUMERIC_FIELDS, newVal);
      BibtexFields.setNumericFieldsFromPrefs();
    }
  }
Пример #2
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);
    }
  }