Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fileChooserRefactor
Browse files Browse the repository at this point in the history
* upstream/master:
  Updated Errorprone to 2.0.11 (JabRef#1636)
  More tests (JabRef#1635)
  Added LabelPatternPreferences (JabRef#1607)
  Fixed a minor issue and refactored MergeEntries (JabRef#1634)
  • Loading branch information
Siedlerchr committed Jul 28, 2016
2 parents 8ee55f3 + 296325c commit 395e0d3
Show file tree
Hide file tree
Showing 25 changed files with 419 additions and 220 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- Fixed [#636](https://github.com/JabRef/jabref/issues/636): DOI in export filters
- Fixed [#1527](https://github.com/JabRef/jabref/issues/1527): 'Get BibTeX data from DOI' Removes Marking
- Fixed [#1592](https://github.com/JabRef/jabref/issues/1592): LibreOffice: wrong numbers in citation labels
- The merge entry dialog showed wrong heading after merging from DOI
- Fixed [#1321](https://github.com/JabRef/jabref/issues/1321): LaTeX commands in fields not displayed in the list of references
- Date fields in the BibLatex standard are now always formatted in the correct way, independent of the preferences

Expand Down
6 changes: 0 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ plugins {
id 'me.champeau.gradle.jmh' version '0.3.0'
}

configurations.errorprone {
// 2.0.10 does not work on Windows while 2.0.9 does
// See https://github.com/google/error-prone/issues/432
resolutionStrategy.force 'com.google.errorprone:error_prone_core:2.0.9'
}

apply plugin: "java"
apply plugin: "application"
apply plugin: "project-report"
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/net/sf/jabref/JabRefMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import net.sf.jabref.logic.exporter.ExportFormats;
import net.sf.jabref.logic.journals.JournalAbbreviationLoader;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.labelpattern.LabelPatternPreferences;
import net.sf.jabref.logic.labelpattern.LabelPatternUtil;
import net.sf.jabref.logic.net.ProxyAuthenticator;
import net.sf.jabref.logic.net.ProxyPreferences;
import net.sf.jabref.logic.net.ProxyRegisterer;
Expand Down Expand Up @@ -72,6 +74,9 @@ private static void start(String[] args) {
// Read list(s) of journal names and abbreviations
Globals.journalAbbreviationLoader = new JournalAbbreviationLoader();

// Set key pattern based on preferences
LabelPatternUtil.updateDefaultPattern(LabelPatternPreferences.fromPreferences(Globals.prefs));

// Check for running JabRef
RemotePreferences remotePreferences = new RemotePreferences(Globals.prefs);
if (remotePreferences.useRemoteServer()) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/net/sf/jabref/cli/ArgumentProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import net.sf.jabref.logic.exporter.SavePreferences;
import net.sf.jabref.logic.exporter.SaveSession;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.labelpattern.LabelPatternPreferences;
import net.sf.jabref.logic.labelpattern.LabelPatternUtil;
import net.sf.jabref.logic.logging.JabRefLogger;
import net.sf.jabref.logic.search.DatabaseSearcher;
Expand Down Expand Up @@ -435,7 +436,8 @@ private void regenerateBibtexKeys(List<ParserResult> loaded) {
LOGGER.info(Localization.lang("Regenerating BibTeX keys according to metadata"));
for (BibEntry entry : database.getEntries()) {
// try to make a new label
LabelPatternUtil.makeLabel(metaData, database, entry, Globals.prefs);
LabelPatternUtil.makeLabel(metaData, database, entry,
LabelPatternPreferences.fromPreferences(Globals.prefs));
}
} else {
LOGGER.info(Localization.lang("No meta data present in BIB_file. Cannot regenerate BibTeX keys"));
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/net/sf/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
import net.sf.jabref.logic.exporter.SaveSession;
import net.sf.jabref.logic.l10n.Encodings;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.labelpattern.LabelPatternPreferences;
import net.sf.jabref.logic.labelpattern.LabelPatternUtil;
import net.sf.jabref.logic.layout.Layout;
import net.sf.jabref.logic.layout.LayoutFormatterPreferences;
Expand Down Expand Up @@ -578,7 +579,8 @@ public void run() {
// Finally, set the new keys:
for (BibEntry entry : entries) {
bes = entry;
LabelPatternUtil.makeLabel(bibDatabaseContext.getMetaData(), database, bes, Globals.prefs);
LabelPatternUtil.makeLabel(bibDatabaseContext.getMetaData(), database, bes,
LabelPatternPreferences.fromPreferences(Globals.prefs));
ce.addEdit(new UndoableKeyChange(database, bes, (String) oldvals.get(bes),
bes.getCiteKey()));
}
Expand Down Expand Up @@ -1992,7 +1994,8 @@ public void autoGenerateKeysBeforeSaving() {
for (BibEntry bes : database.getEntries()) {
String oldKey = bes.getCiteKey();
if ((oldKey == null) || oldKey.isEmpty()) {
LabelPatternUtil.makeLabel(bibDatabaseContext.getMetaData(), database, bes, Globals.prefs);
LabelPatternUtil.makeLabel(bibDatabaseContext.getMetaData(), database, bes,
LabelPatternPreferences.fromPreferences(Globals.prefs));
ce.addEdit(new UndoableKeyChange(database, bes, null, bes.getCiteKey()));
any = true;
}
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/net/sf/jabref/gui/EntryTypeList.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

import net.sf.jabref.Globals;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.labelpattern.LabelPatternUtil;
import net.sf.jabref.model.EntryTypes;
import net.sf.jabref.model.database.BibDatabaseMode;
import net.sf.jabref.model.entry.CustomEntryType;
import net.sf.jabref.model.entry.EntryType;
import net.sf.jabref.preferences.JabRefPreferences;

/**
* This class extends FieldSetComponent to provide some required functionality for the
Expand Down Expand Up @@ -70,7 +72,8 @@ protected void addField(String str) {
return;
}

String testString = LabelPatternUtil.checkLegalKey(s);
String testString = LabelPatternUtil.checkLegalKey(s,
Globals.prefs.getBoolean(JabRefPreferences.ENFORCE_LEGAL_BIBTEX_KEY));
if (!testString.equals(s) || (s.indexOf('&') >= 0)) {
// Report error and exit.
JOptionPane.showMessageDialog(this, Localization.lang("Entry type names are not allowed to contain white space or the following "
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/net/sf/jabref/gui/FieldSetComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@
import javax.swing.event.ListDataListener;
import javax.swing.event.ListSelectionListener;

import net.sf.jabref.Globals;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.labelpattern.LabelPatternUtil;
import net.sf.jabref.preferences.JabRefPreferences;

/**
* @author alver
Expand Down Expand Up @@ -249,7 +251,8 @@ protected void addField(String str) {
return;
}

String testString = LabelPatternUtil.checkLegalKey(s);
String testString = LabelPatternUtil.checkLegalKey(s,
Globals.prefs.getBoolean(JabRefPreferences.ENFORCE_LEGAL_BIBTEX_KEY));
if (!testString.equals(s) || (s.indexOf('&') >= 0)) {
// Report error and exit.
JOptionPane.showMessageDialog(this, Localization.lang("Field names are not allowed to contain white space or the following "
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/sf/jabref/gui/GenFieldsCustomizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ private void okActionPerformed() {
Localization.lang("Error"), JOptionPane.ERROR_MESSAGE);
return;
}
String testString = LabelPatternUtil.checkLegalKey(parts[1]);
String testString = LabelPatternUtil.checkLegalKey(parts[1],
Globals.prefs.getBoolean(JabRefPreferences.ENFORCE_LEGAL_BIBTEX_KEY));
if (!testString.equals(parts[1]) || (parts[1].indexOf('&') >= 0)) {
// Report error and exit.
JOptionPane.showMessageDialog(this, Localization.lang("Field names are not allowed to contain white space or the following "
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/net/sf/jabref/gui/ImportInspectionDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
import net.sf.jabref.logic.groups.GroupTreeNode;
import net.sf.jabref.logic.help.HelpFile;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.labelpattern.LabelPatternPreferences;
import net.sf.jabref.logic.labelpattern.LabelPatternUtil;
import net.sf.jabref.logic.util.UpdateField;
import net.sf.jabref.model.DuplicateCheck;
Expand Down Expand Up @@ -461,7 +462,8 @@ private void generateKeySelectedEntry() {
database.insertEntry(entry);

// Generate a unique key:
LabelPatternUtil.makeLabel(localMetaData, database, entry, Globals.prefs);
LabelPatternUtil.makeLabel(localMetaData, database, entry,
LabelPatternPreferences.fromPreferences(Globals.prefs));
// Remove the entry from the database again, since we only added it in
// order to
// make sure the key was unique:
Expand Down Expand Up @@ -502,7 +504,8 @@ private void generateKeys() {
entry.setId(IdGenerator.next());
database.insertEntry(entry);

LabelPatternUtil.makeLabel(localMetaData, database, entry, Globals.prefs);
LabelPatternUtil.makeLabel(localMetaData, database, entry,
LabelPatternPreferences.fromPreferences(Globals.prefs));
// Add the generated key to our list:
keys.add(entry.getCiteKey());
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
import net.sf.jabref.logic.bibtex.LatexFieldFormatterPreferences;
import net.sf.jabref.logic.help.HelpFile;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.labelpattern.LabelPatternPreferences;
import net.sf.jabref.logic.labelpattern.LabelPatternUtil;
import net.sf.jabref.logic.search.SearchQueryHighlightListener;
import net.sf.jabref.logic.util.date.TimeStamp;
Expand Down Expand Up @@ -1102,7 +1103,8 @@ public void actionPerformed(ActionEvent event) {
}

// Make sure the key is legal:
String cleaned = LabelPatternUtil.checkLegalKey(newValue);
String cleaned = LabelPatternUtil.checkLegalKey(newValue,
Globals.prefs.getBoolean(JabRefPreferences.ENFORCE_LEGAL_BIBTEX_KEY));
if ((cleaned == null) || cleaned.equals(newValue)) {
textField.setValidBackgroundColor();
} else {
Expand Down Expand Up @@ -1369,7 +1371,7 @@ public void actionPerformed(ActionEvent e) {
}

LabelPatternUtil.makeLabel(panel.getBibDatabaseContext().getMetaData(), panel.getDatabase(), entry,
Globals.prefs);
LabelPatternPreferences.fromPreferences(Globals.prefs));

// Store undo information:
panel.getUndoManager().addEdit(new UndoableKeyChange(panel.getDatabase(), entry, (String) oldValue, entry.getCiteKey()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import net.sf.jabref.gui.undo.UndoableKeyChange;
import net.sf.jabref.gui.worker.AbstractWorker;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.labelpattern.LabelPatternPreferences;
import net.sf.jabref.logic.labelpattern.LabelPatternUtil;
import net.sf.jabref.model.database.BibDatabase;
import net.sf.jabref.model.entry.BibEntry;
Expand Down Expand Up @@ -111,7 +112,7 @@ public void update() {
for (BibEntry entry : toGenerateFor) {
String oldKey = entry.getCiteKey();
LabelPatternUtil.makeLabel(panel.getBibDatabaseContext().getMetaData(), panel.getDatabase(), entry,
Globals.prefs);
LabelPatternPreferences.fromPreferences(Globals.prefs));
ce.addEdit(new UndoableKeyChange(panel.getDatabase(), entry, oldKey, entry.getCiteKey()));
}
ce.end();
Expand Down
Loading

0 comments on commit 395e0d3

Please sign in to comment.