@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);
  }
  @Test
  public void testBasicSearchParsing() {
    Globals.prefs = JabRefPreferences.getInstance();

    BibtexEntry be = makeBibtexEntry();
    ContainBasedSearchRule bsCaseSensitive = new ContainBasedSearchRule(true);
    ContainBasedSearchRule bsCaseInsensitive = new ContainBasedSearchRule(false);
    RegexBasedSearchRule bsCaseSensitiveRegexp = new RegexBasedSearchRule(true);
    RegexBasedSearchRule bsCaseInsensitiveRegexp = new RegexBasedSearchRule(false);

    String query = "marine 2001 shields";

    Assert.assertEquals(false, bsCaseSensitive.applyRule(query, be));
    Assert.assertEquals(true, bsCaseInsensitive.applyRule(query, be));
    Assert.assertEquals(false, bsCaseSensitiveRegexp.applyRule(query, be));
    Assert.assertEquals(true, bsCaseInsensitiveRegexp.applyRule(query, be));

    query = "\"marine larviculture\"";

    Assert.assertEquals(false, bsCaseSensitive.applyRule(query, be));
    Assert.assertEquals(false, bsCaseInsensitive.applyRule(query, be));
    Assert.assertEquals(false, bsCaseSensitiveRegexp.applyRule(query, be));
    Assert.assertEquals(false, bsCaseInsensitiveRegexp.applyRule(query, be));

    query = "\"marine [A-Za-z]* larviculture\"";

    Assert.assertEquals(false, bsCaseSensitive.applyRule(query, be));
    Assert.assertEquals(false, bsCaseInsensitive.applyRule(query, be));
    Assert.assertEquals(false, bsCaseSensitiveRegexp.applyRule(query, be));
    Assert.assertEquals(true, bsCaseInsensitiveRegexp.applyRule(query, be));
  }
Example #3
0
 private BibtexDatabase getDatabase() {
   Globals.prefs = JabRefPreferences.getInstance();
   File fileToLoad = new File(PATH_TO_TEST_BIBTEX);
   ParserResult pr = JabRef.openBibFile(fileToLoad.getPath(), true);
   BibtexDatabase filledDatabase = pr.getDatabase();
   return filledDatabase;
 }
Example #4
0
  public void testAutoCompleterFactory() {
    Globals.prefs = JabRefPreferences.getInstance();
    AbstractAutoCompleter autoCompleter = AutoCompleterFactory.getFor(AUTHOR_FIELD);
    assertTrue(autoCompleter instanceof NameFieldAutoCompleter);

    autoCompleter = AutoCompleterFactory.getFor(OTHER_FIELD);
    assertTrue(autoCompleter instanceof DefaultAutoCompleter);
  }
Example #5
0
  public void testNameFieldCompleter() {
    Globals.prefs = JabRefPreferences.getInstance();
    AbstractAutoCompleter autoCompleter = AutoCompleterFactory.getFor(AUTHOR_FIELD);
    for (BibtexEntry entry : getDatabase().getEntries()) {
      autoCompleter.addBibtexEntry(entry);
    }

    // tweak preferences to match test cases
    boolean oldAutocomplete = Globals.prefs.getBoolean("autoComplete");
    Globals.prefs.putBoolean("autoComplete", Boolean.TRUE);
    boolean oldAutoCompFF = Globals.prefs.getBoolean("autoCompLF");
    Globals.prefs.putBoolean("autoCompFF", Boolean.FALSE);
    boolean oldAutoCompLF = Globals.prefs.getBoolean("autoCompLF");
    Globals.prefs.putBoolean("autoCompLF", Boolean.FALSE);
    String oldACFM = Globals.prefs.get(JabRefPreferences.AUTOCOMPLETE_FIRSTNAME_MODE);
    Globals.prefs.put(
        JabRefPreferences.AUTOCOMPLETE_FIRSTNAME_MODE,
        JabRefPreferences.AUTOCOMPLETE_FIRSTNAME_MODE_BOTH);

    assertEquals("Kostakos, V.", autoCompleter.complete("Kostakos")[0]);
    assertEquals(2, autoCompleter.complete("Kostakos").length);
    assertEquals("Kostakos, V.", autoCompleter.complete("Kosta")[0]);
    assertEquals(2, autoCompleter.complete("Kosta").length);
    assertEquals("Kostakos, Vassilis", autoCompleter.complete("Kostakos, Va")[0]);
    assertEquals(1, autoCompleter.complete("Kostakos, Va").length);
    assertEquals("Vassilis Kostakos", autoCompleter.complete("Va")[0]);
    assertEquals(1, autoCompleter.complete("Va").length);
    assertEquals(0, autoCompleter.complete("osta").length);
    assertEquals(0, autoCompleter.complete("osta").length);

    assertEquals("Eric von Hippel", autoCompleter.complete("Eric")[0]);
    assertEquals(1, autoCompleter.complete("Eric").length);
    assertEquals("von Hippel, E.", autoCompleter.complete("von")[0]);
    assertEquals(2, autoCompleter.complete("von").length);

    assertEquals("Reagle, Jr., J. M.", autoCompleter.complete("Reagle")[0]);
    assertEquals(2, autoCompleter.complete("Reagle").length);
    assertEquals("Reagle, Jr., Joseph M.", autoCompleter.complete("Reagle, Jr., Jo")[0]);
    assertEquals(1, autoCompleter.complete("Reagle, Jr., Jo").length);
    assertEquals("Joseph M. Reagle, Jr.", autoCompleter.complete("Joseph")[0]);
    assertEquals(1, autoCompleter.complete("Joseph").length);

    assertEquals("van den Huevel, Jr., J. A.", autoCompleter.complete("van den")[0]);
    assertEquals(2, autoCompleter.complete("van den").length);
    assertEquals("Johan A van den Huevel, Jr.", autoCompleter.complete("Joh")[0]);
    assertEquals(1, autoCompleter.complete("Joh").length);

    assertEquals("Jr. Sherry, John F.", autoCompleter.complete("Jr. S")[0]);
    assertEquals(1, autoCompleter.complete("Jr.").length);
    assertEquals("Sherry, John F., J.", autoCompleter.complete("Sherry")[0]);
    assertEquals(2, autoCompleter.complete("Sherry").length);

    // restore settings
    Globals.prefs.putBoolean("autoComplete", oldAutocomplete);
    Globals.prefs.putBoolean("autoCompFF", oldAutoCompFF);
    Globals.prefs.putBoolean("autoCompLF", oldAutoCompLF);
    Globals.prefs.put(JabRefPreferences.AUTOCOMPLETE_FIRSTNAME_MODE, oldACFM);
  }
Example #6
0
  public BibtexParser(Reader in) {

    if (in == null) {
      throw new NullPointerException();
    }
    if (Globals.prefs == null) {
      Globals.prefs = JabRefPreferences.getInstance();
    }
    _in = new PushbackReader(in, LOOKAHEAD);
  }
  @Test
  @Ignore
  public void testInsertTestData() throws Exception {

    entry1 = new BibtexEntry();
    JabRefPreferences jabRefPreferences = JabRefPreferences.getInstance();
    ExternalFileType fileType = jabRefPreferences.getExternalFileTypeByExt("PDF");
    FileListEntry fileListEntry =
        new FileListEntry("", ImportDataTest.FILE_IN_DATABASE.getAbsolutePath(), fileType);

    FileListTableModel model = new FileListTableModel();
    model.addEntry(0, fileListEntry);

    entry1.setField("file", model.getStringRepresentation());

    database.insertEntry(entry1);

    // #################### SETUP END ##################### //

    UnlinkedFilesCrawler crawler = new UnlinkedFilesCrawler(database);
    CheckableTreeNode treeNode =
        crawler.searchDirectory(ImportDataTest.EXISTING_FOLDER, new EntryFromPDFCreator());

    Assert.assertNotNull(treeNode);

    /** Select all nodes manually. */
    @SuppressWarnings("unchecked")
    Enumeration<CheckableTreeNode> enumeration = treeNode.breadthFirstEnumeration();
    while (enumeration.hasMoreElements()) {
      CheckableTreeNode nextElement = enumeration.nextElement();
      nextElement.setSelected(true);
    }

    List<File> resultList = getFileListFromNode(treeNode);

    Assert.assertFalse(resultList.isEmpty());
    Assert.assertTrue(resultList.contains(ImportDataTest.FILE_NOT_IN_DATABASE));
    Assert.assertFalse(resultList.contains(ImportDataTest.FILE_IN_DATABASE));
  }
Example #8
0
  /**
   * @param panel (may be null) If not given no toolbar is shown on the right hand side.
   * @param databaseContext (may be null) Used for resolving pdf directories for links.
   * @param layoutFile (must be given) Used for layout
   */
  public PreviewPanel(BasePanel panel, BibDatabaseContext databaseContext, String layoutFile) {
    super(new BorderLayout(), true);

    this.databaseContext = Optional.ofNullable(databaseContext);
    this.layoutFile = Objects.requireNonNull(layoutFile);
    updateLayout();

    this.closeAction = new CloseAction();
    this.printAction = new PrintAction();
    this.copyPreviewAction = new CopyPreviewAction();

    this.basePanel = Optional.ofNullable(panel);

    createPreviewPane();

    if (panel != null) {
      // dropped files handler only created for main window
      // not for Windows as like the search results window
      this.previewPane.setTransferHandler(
          new PreviewPanelTransferHandler(
              panel.frame(), this, this.previewPane.getTransferHandler()));
    }

    // Set up scroll pane for preview pane
    scrollPane =
        new JScrollPane(
            previewPane,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setBorder(null);

    /*
     * If we have been given a panel and the preference option
     * previewPrintButton is set, show the tool bar
     */
    if (this.basePanel.isPresent()
        && JabRefPreferences.getInstance().getBoolean(JabRefPreferences.PREVIEW_PRINT_BUTTON)) {
      add(createToolBar(), BorderLayout.LINE_START);
    }

    add(scrollPane, BorderLayout.CENTER);

    this.createKeyBindings();
  }
Example #9
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);
    }
  }
Example #10
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);
    }
  }
Example #11
0
  public void setUp() throws Exception {

    Globals.prefs = JabRefPreferences.getInstance();
    oldUseRegExp = Globals.prefs.getBoolean(JabRefPreferences.USE_REG_EXP_SEARCH_KEY);
    oldAutoLinkExcatKeyOnly = Globals.prefs.getBoolean(JabRefPreferences.AUTOLINK_EXACT_KEY_ONLY);
    oldPdfDirectory = Globals.prefs.get("pdfDirectory");

    Globals.prefs.putBoolean(JabRefPreferences.USE_REG_EXP_SEARCH_KEY, false);
    Globals.prefs.putBoolean(JabRefPreferences.AUTOLINK_EXACT_KEY_ONLY, false);

    getBibtexEntry();
    assertNotNull(database);
    assertNotNull(entry);

    // Create file structure
    try {
      root = createTempDir("UtilFindFileTest");

      Globals.prefs.put("pdfDirectory", root.getPath());

      File subDir1 = new File(root, "Organization Science");
      subDir1.mkdir();

      File pdf1 = new File(subDir1, "HipKro03 - Hello.pdf");
      pdf1.createNewFile();

      File pdf1a = new File(root, "HipKro03 - Hello.pdf");
      pdf1a.createNewFile();

      File subDir2 = new File(root, "pdfs");
      subDir2.mkdir();

      File subsubDir1 = new File(subDir2, "sub");
      subsubDir1.mkdir();

      File pdf2 = new File(subsubDir1, "HipKro03-sub.pdf");
      pdf2.createNewFile();

      File dir2002 = new File(root, "2002");
      dir2002.mkdir();

      File dir2003 = new File(root, "2003");
      dir2003.mkdir();

      File pdf3 = new File(dir2003, "Paper by HipKro03.pdf");
      pdf3.createNewFile();

      File dirTest = new File(root, "test");
      dirTest.mkdir();

      File pdf4 = new File(dirTest, "HipKro03.pdf");
      pdf4.createNewFile();

      File pdf5 = new File(dirTest, ".TEST");
      pdf5.createNewFile();

      File pdf6 = new File(dirTest, "TEST[");
      pdf6.createNewFile();

      File pdf7 = new File(dirTest, "TE.ST");
      pdf7.createNewFile();

      File foo = new File(dirTest, "foo.dat");
      foo.createNewFile();

      File graphicsDir = new File(root, "graphicsDir");
      graphicsDir.mkdir();

      File graphicsSubDir = new File(graphicsDir, "subDir");
      graphicsSubDir.mkdir();

      File jpg = new File(graphicsSubDir, "HipKro03test.jpg");
      jpg.createNewFile();

      File png = new File(graphicsSubDir, "HipKro03test.png");
      png.createNewFile();

    } catch (Exception e) {
      throw new RuntimeException();
    }
  }
 @Before
 public void setUp() {
   prefs = JabRefPreferences.getInstance();
   backup = prefs;
 }
 @Before
 public void setUp() throws Exception {
   Globals.prefs = JabRefPreferences.getInstance();
   backup = Globals.prefs;
   Globals.prefs.putBoolean(JabRefPreferences.BIBLATEX_MODE, true);
 }
 @Before
 public void setUp() throws URISyntaxException {
   Globals.prefs = JabRefPreferences.getInstance();
   xmlFile = Paths.get(MsBibImporter.class.getResource(fileName + ".xml").toURI());
 }
Example #15
0
 @Before
 public void setPreferences() {
   Globals.prefs = JabRefPreferences.getInstance();
 }
Example #16
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));
 }
Example #17
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();
    }
  }
Example #18
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);
    }
  }
Example #19
0
 @Before
 public void setUp() throws Exception {
   if (Globals.prefs == null) {
     Globals.prefs = JabRefPreferences.getInstance();
   }
 }
 @Test
 public void getDefaultEncodingReturnsPreviouslyStoredEncoding() {
   prefs.setDefaultEncoding(StandardCharsets.UTF_16BE);
   assertEquals(StandardCharsets.UTF_16BE, prefs.getDefaultEncoding());
 }
Example #21
0
 @Override
 public void storeSettings() {
   prefs.put(JabRefPreferences.PREVIEW_0, layout1.getText().replaceAll("\n", "__NEWLINE__"));
   prefs.put(JabRefPreferences.PREVIEW_1, layout2.getText().replaceAll("\n", "__NEWLINE__"));
   prefs.putBoolean(JabRefPreferences.PDF_PREVIEW, pdfPreview.isSelected());
 }
 @After
 public void tearDown() {
   // clean up preferences to default state
   prefs.overwritePreferences(backup);
 }
Example #23
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");
  }