Esempio n. 1
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);
    }
  }
Esempio n. 2
0
  public void setValues() {
    fileColumn.setSelected(_prefs.getBoolean("fileColumn"));
    pdfColumn.setSelected(_prefs.getBoolean("pdfColumn"));
    urlColumn.setSelected(_prefs.getBoolean("urlColumn"));
    preferUrl.setSelected(!_prefs.getBoolean("preferUrlDoi"));
    preferDoi.setSelected(_prefs.getBoolean("preferUrlDoi"));
    fileColumn.setSelected(_prefs.getBoolean("fileColumn"));
    arxivColumn.setSelected(_prefs.getBoolean("arxivColumn"));

    /** * begin: special fields ** */
    oldRankingColumn = _prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_RANKING);
    rankingColumn.setSelected(oldRankingColumn);

    oldCompcatRankingColumn = _prefs.getBoolean(SpecialFieldsUtils.PREF_RANKING_COMPACT);
    compactRankingColumn.setSelected(oldCompcatRankingColumn);

    oldQualityColumn = _prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_QUALITY);
    qualityColumn.setSelected(oldQualityColumn);

    oldPriorityColumn = _prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_PRIORITY);
    priorityColumn.setSelected(oldPriorityColumn);

    oldRelevanceColumn = _prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_RELEVANCE);
    relevanceColumn.setSelected(oldRelevanceColumn);

    oldSyncKeyWords = _prefs.getBoolean(SpecialFieldsUtils.PREF_AUTOSYNCSPECIALFIELDSTOKEYWORDS);
    syncKeywords.setSelected(oldSyncKeyWords);

    oldWriteSpecialFields = _prefs.getBoolean(SpecialFieldsUtils.PREF_SERIALIZESPECIALFIELDS);
    writeSpecialFields.setSelected(oldWriteSpecialFields);

    // has to be called as last to correctly enable/disable the other settings
    oldSpecialFieldsEnabled = _prefs.getBoolean(SpecialFieldsUtils.PREF_SPECIALFIELDSENABLED);
    specialFieldsEnabled.setSelected(!oldSpecialFieldsEnabled);
    specialFieldsEnabled.setSelected(
        oldSpecialFieldsEnabled); // Call twice to make sure the ChangeListener is triggered

    /** * end: special fields ** */
    oldShowOneLetterHeadingForIconColumns =
        _prefs.getBoolean(JabRefPreferences.SHOWONELETTERHEADINGFORICONCOLUMNS);
    showOneLetterHeadingForIconColumns.setSelected(oldShowOneLetterHeadingForIconColumns);

    tableRows.clear();
    String[] names = _prefs.getStringArray("columnNames"),
        lengths = _prefs.getStringArray("columnWidths");
    for (int i = 0; i < names.length; i++) {
      if (i < lengths.length) tableRows.add(new TableRow(names[i], Integer.parseInt(lengths[i])));
      else tableRows.add(new TableRow(names[i]));
    }
    rowCount = tableRows.size() + 5;
    ncWidth = _prefs.getInt("numberColWidth");
  }