Esempio n. 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();
    }
  }
Esempio n. 2
0
  @Override
  public void setValues() {
    autoResizeMode.setSelected(
        prefs.getInt(JabRefPreferences.AUTO_RESIZE_MODE) == JTable.AUTO_RESIZE_ALL_COLUMNS);

    priField.setText(prefs.get(JabRefPreferences.PRIMARY_SORT_FIELD));
    secField.setText(prefs.get(JabRefPreferences.SECONDARY_SORT_FIELD));
    terField.setText(prefs.get(JabRefPreferences.TERTIARY_SORT_FIELD));
    priSort.setSelectedIndex(0);
    secSort.setSelectedIndex(0);
    terSort.setSelectedIndex(0);

    if (prefs.getBoolean(JabRefPreferences.NAMES_AS_IS)) {
      namesAsIs.setSelected(true);
    } else if (prefs.getBoolean(JabRefPreferences.NAMES_FIRST_LAST)) {
      namesFf.setSelected(true);
    } else if (prefs.getBoolean(JabRefPreferences.NAMES_NATBIB)) {
      namesNatbib.setSelected(true);
    } else {
      namesFl.setSelected(true);
    }
    if (prefs.getBoolean(JabRefPreferences.ABBR_AUTHOR_NAMES)) {
      abbrNames.setSelected(true);
    } else if (prefs.getBoolean(JabRefPreferences.NAMES_LAST_ONLY)) {
      lastNamesOnly.setSelected(true);
    } else {
      noAbbrNames.setSelected(true);
    }
    priDesc.setSelected(prefs.getBoolean(JabRefPreferences.PRIMARY_SORT_DESCENDING));
    secDesc.setSelected(prefs.getBoolean(JabRefPreferences.SECONDARY_SORT_DESCENDING));
    terDesc.setSelected(prefs.getBoolean(JabRefPreferences.TERTIARY_SORT_DESCENDING));

    floatMarked.setSelected(prefs.getBoolean(JabRefPreferences.FLOAT_MARKED_ENTRIES));

    abbrNames.setEnabled(!namesNatbib.isSelected());
    lastNamesOnly.setEnabled(!namesNatbib.isSelected());
    noAbbrNames.setEnabled(!namesNatbib.isSelected());

    String numF = prefs.get(JabRefPreferences.NUMERIC_FIELDS);
    if (numF == null) {
      numericFields.setText("");
    } else {
      numericFields.setText(numF);
    }
  }
  @Test
  public void testPreferencesImport() throws JabRefException {
    // the primary sort field has been changed to "editor" in this case
    File importFile = new File("src/test/resources/net/sf/jabref/customPreferences.xml");

    prefs.importPreferences(importFile.getAbsolutePath());

    String expected = "my proxy host";
    String actual = prefs.get(JabRefPreferences.PROXY_HOSTNAME);

    assertEquals(expected, actual);
  }
Esempio n. 4
0
  // .getResource is called at resourceOwner. This method is available at all Class objects
  public void setPage(String filename, Class<?> resourceOwner) {

    // Check for anchor
    int indexOf = filename.indexOf('#');
    String file;
    String anchorName = null;

    if (indexOf != -1) {
      file = filename.substring(0, indexOf);
      anchorName = filename.substring(indexOf + 1);
    } else {
      file = filename;
    }

    String middle = prefs.get(JabRefPreferences.LANGUAGE) + '/';

    URL old = getPage();

    // First check in specified language
    URL resource = resourceOwner.getResource(GUIGlobals.helpPre + middle + file);

    // If not available fallback to english
    if (resource == null) {
      resource = resourceOwner.getResource(GUIGlobals.helpPre + "en/" + file);
      LOGGER.info("No localization available for file '" + file + "'. Falling back to English.");
    }

    // If still not available print a warning
    if (resource == null) {
      // TODO show warning to user
      LOGGER.error("Could not find html-help for file '" + file + "'.");
      return;
    }

    setPageOnly(resource, anchorName);

    forw.removeAllElements();
    if (old != null) {
      history.push(old);
    }
  }
Esempio n. 5
0
 @Override
 public void setValues() {
   layout1.setText(prefs.get(JabRefPreferences.PREVIEW_0).replaceAll("__NEWLINE__", "\n"));
   layout2.setText(prefs.get(JabRefPreferences.PREVIEW_1).replaceAll("__NEWLINE__", "\n"));
   pdfPreview.setSelected(prefs.getBoolean(JabRefPreferences.PDF_PREVIEW));
 }