Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fixPdfContentImpo…
Browse files Browse the repository at this point in the history
…rter

# By David Méndez (47) and others
# Via GitHub (5) and David Méndez (3)
* upstream/master: (57 commits)
  fix wrong package (#5181)
  Remove logging message for non-existing nested files
  Bump applicationinsights-core from 2.4.0 to 2.4.1 (#5171)
  Bump archunit-junit5-engine from 0.10.2 to 0.11.0 (#5157)
  Bump applicationinsights-logging-log4j2 from 2.4.0 to 2.4.1 (#5172)
  Bump tika-core from 1.21 to 1.22 (#5166)
  Fix fail on testPerformExportForSingleEntry from DocBook5ExporterTest (#5168)
  Add a check for nested files and improve the code to skip lines (DefaultTexParser)
  Add latest changes to latexintegration (#5170)
  LaTeX integration latest changes (#5167)
  Move to extended enums for fields and entry types (#5148)
  Bump archunit-junit5-api from 0.10.2 to 0.11.0 (#5158)
  Revert temporal change
  Fix all issues from reviews of #5137
  Bump com.simonharrer.modernizer from 1.6.0-1 to 1.8.0-1 (#5154)
  Bump checkstyle from 8.22 to 8.23 (#5153)
  Add a new JabRefIcons.LATEX_CITATIONS
  Change toString() methods
  Update DefaultTexParser for explaining when and why it skips the citation matching
  Update TexParserResult for avoiding 'orElse(null)'
  ...

# Conflicts:
#	src/main/java/org/jabref/logic/importer/fileformat/PdfContentImporter.java
#	src/test/java/org/jabref/logic/importer/fileformat/PdfContentImporterTest.java
  • Loading branch information
Siedlerchr committed Aug 9, 2019
2 parents 9b44fa0 + 8782e5a commit 0a779be
Show file tree
Hide file tree
Showing 515 changed files with 9,269 additions and 9,880 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
## [Unreleased]

### Changed
- All fields are now properly sorted alphabetically (in the subgroups of required/optional fields) when the entry is written to the bib file.
- We fixed an issue where some importers used the field `pubstatus` instead of the standard BibTeX field `pubstate`.
- We changed the latex command removal for docbook exporter. [#3838](https://github.com/JabRef/jabref/issues/3838)
- We changed the location of some fields in the entry editor (you might need to reset your preferences for these changes to come into effect)
- Journal/Year/Month in biblatex mode -> Deprecated (if filled)
Expand Down Expand Up @@ -70,7 +72,8 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We moved the dropdown menu for selecting the push-application from the toolbar into the external application preferences. [#674](https://github.com/JabRef/jabref/issues/674)
- We removed the alphabetical ordering of the custom tabs and updated the error message when trying to create a general field with a name containing an illegal character. [#5019](https://github.com/JabRef/jabref/issues/5019)
- We added a context menu to the bib(la)tex-source-editor to copy'n'paste. [#5007](https://github.com/JabRef/jabref/pull/5007)
- We added a bibliographic references search, for finding references in several LaTeX files. This tool scans directories and shows which entries are used, how many times and where.
- We added a tool that allows searching for citations in LaTeX files. It scans directories and shows which entries are used, how many times and where.
- We added a 'LaTeX citations' tab to the entry editor, to search for citations to the active entry in the LaTeX file directory. It can be disabled in the preferences dialog.
- We added an option in preferences to allow for integers in field "edition" when running database in bibtex mode. [#4680](https://github.com/JabRef/jabref/issues/4680)


Expand Down
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ plugins {
id 'com.gradle.build-scan' version '2.3'
id 'com.install4j.gradle' version '7.0.12'
id 'com.github.johnrengelman.shadow' version '5.1.0'
id "com.simonharrer.modernizer" version '1.6.0-1'
id "com.simonharrer.modernizer" version '1.8.0-1'
id 'me.champeau.gradle.jmh' version '0.4.8'
id 'net.ltgt.errorprone' version '0.8.1'
id 'com.github.ben-manes.versions' version '0.21.0'
Expand Down Expand Up @@ -94,7 +94,7 @@ dependencies {
compile 'org.apache.pdfbox:fontbox:2.0.16'
compile 'org.apache.pdfbox:xmpbox:2.0.16'

compile group: 'org.apache.tika', name: 'tika-core', version: '1.21'
compile group: 'org.apache.tika', name: 'tika-core', version: '1.22'

// required for reading write-protected PDFs - see https://github.com/JabRef/jabref/pull/942#issuecomment-209252635
compile 'org.bouncycastle:bcprov-jdk15on:1.62'
Expand Down Expand Up @@ -154,8 +154,8 @@ dependencies {

errorproneJavac 'com.google.errorprone:javac:1.8.0-u20'

compile group: 'com.microsoft.azure', name: 'applicationinsights-core', version: '2.4.0'
compile group: 'com.microsoft.azure', name: 'applicationinsights-logging-log4j2', version: '2.4.0'
compile group: 'com.microsoft.azure', name: 'applicationinsights-core', version: '2.4.1'
compile group: 'com.microsoft.azure', name: 'applicationinsights-logging-log4j2', version: '2.4.1'

testImplementation 'org.junit.jupiter:junit-jupiter:5.5.1'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.5.1'
Expand All @@ -168,12 +168,12 @@ dependencies {
testCompile 'org.reflections:reflections:0.9.11'
testCompile 'org.xmlunit:xmlunit-core:2.6.3'
testCompile 'org.xmlunit:xmlunit-matchers:2.6.3'
testRuntime 'com.tngtech.archunit:archunit-junit5-engine:0.10.2'
testCompile 'com.tngtech.archunit:archunit-junit5-api:0.10.2'
testRuntime 'com.tngtech.archunit:archunit-junit5-engine:0.11.0'
testCompile 'com.tngtech.archunit:archunit-junit5-api:0.11.0'
testCompile "org.testfx:testfx-core:4.0.+"
testCompile "org.testfx:testfx-junit5:4.0.+"

checkstyle 'com.puppycrawl.tools:checkstyle:8.22'
checkstyle 'com.puppycrawl.tools:checkstyle:8.23'
xjc 'com.sun.xml.bind:jaxb-xjc:2.2.4-1'
jython 'org.python:jython-standalone:2.7.1'
}
Expand Down
19 changes: 11 additions & 8 deletions src/jmh/java/org/jabref/benchmarks/Benchmarks.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import org.jabref.model.database.BibDatabaseMode;
import org.jabref.model.database.BibDatabaseModeDetection;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibEntryTypesManager;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.field.UnknownField;
import org.jabref.model.groups.GroupHierarchyType;
import org.jabref.model.groups.KeywordGroup;
import org.jabref.model.groups.WordKeywordGroup;
Expand Down Expand Up @@ -54,12 +57,12 @@ public void init() throws Exception {
for (int i = 0; i < 1000; i++) {
BibEntry entry = new BibEntry();
entry.setCiteKey("id" + i);
entry.setField("title", "This is my title " + i);
entry.setField("author", "Firstname Lastname and FirstnameA LastnameA and FirstnameB LastnameB" + i);
entry.setField("journal", "Journal Title " + i);
entry.setField("keyword", "testkeyword");
entry.setField("year", "1" + i);
entry.setField("rnd", "2" + randomizer.nextInt());
entry.setField(StandardField.TITLE, "This is my title " + i);
entry.setField(StandardField.AUTHOR, "Firstname Lastname and FirstnameA LastnameA and FirstnameB LastnameB" + i);
entry.setField(StandardField.JOURNAL, "Journal Title " + i);
entry.setField(StandardField.KEYWORDS, "testkeyword");
entry.setField(StandardField.YEAR, "1" + i);
entry.setField(new UnknownField("rnd"), "2" + randomizer.nextInt());
database.insertEntry(entry);
}

Expand All @@ -72,7 +75,7 @@ public void init() throws Exception {

private StringWriter getOutputWriter() throws IOException {
StringWriter outputWriter = new StringWriter();
BibtexDatabaseWriter databaseWriter = new BibtexDatabaseWriter(outputWriter, mock(SavePreferences.class));
BibtexDatabaseWriter databaseWriter = new BibtexDatabaseWriter(outputWriter, mock(SavePreferences.class), new BibEntryTypesManager());
databaseWriter.savePartOfDatabase(
new BibDatabaseContext(database, new MetaData(), new Defaults()), database.getEntries());
return outputWriter;
Expand Down Expand Up @@ -128,7 +131,7 @@ public String htmlToLatexConversion() {

@Benchmark
public boolean keywordGroupContains() {
KeywordGroup group = new WordKeywordGroup("testGroup", GroupHierarchyType.INDEPENDENT, "keyword", "testkeyword", false, ',', false);
KeywordGroup group = new WordKeywordGroup("testGroup", GroupHierarchyType.INDEPENDENT, StandardField.KEYWORDS, "testkeyword", false, ',', false);
return group.containsAll(database.getEntries());
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/jabref/Globals.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.jabref.logic.protectedterms.ProtectedTermsLoader;
import org.jabref.logic.remote.server.RemoteListenerServerLifecycle;
import org.jabref.logic.util.BuildInfo;
import org.jabref.model.entry.BibEntryTypesManager;
import org.jabref.model.util.FileUpdateMonitor;
import org.jabref.preferences.JabRefPreferences;

Expand Down Expand Up @@ -61,6 +62,7 @@ public class Globals {
public static StateManager stateManager = new StateManager();
public static ExporterFactory exportFactory;
public static CountingUndoManager undoManager = new CountingUndoManager();
public static BibEntryTypesManager entryTypesManager = new BibEntryTypesManager();
// Key binding preferences
private static KeyBindingRepository keyBindingRepository;
private static DefaultFileUpdateMonitor fileUpdateMonitor;
Expand Down
13 changes: 2 additions & 11 deletions src/main/java/org/jabref/JabRefMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
import org.jabref.logic.util.JavaVersion;
import org.jabref.logic.util.OS;
import org.jabref.migrations.PreferencesMigrations;
import org.jabref.model.EntryTypes;
import org.jabref.model.database.BibDatabaseMode;
import org.jabref.model.entry.InternalBibtexFields;
import org.jabref.preferences.JabRefPreferences;

import org.slf4j.Logger;
Expand Down Expand Up @@ -153,21 +151,14 @@ private static boolean handleMultipleAppInstances(String[] args) {
}

private static void applyPreferences(JabRefPreferences preferences) {
// Update handling of special fields based on preferences
InternalBibtexFields.updateSpecialFields(Globals.prefs.getBoolean(JabRefPreferences.SERIALIZESPECIALFIELDS));
// Update name of the time stamp field based on preferences
InternalBibtexFields.updateTimeStampField(Globals.prefs.getTimestampPreferences().getTimestampField());
// Update which fields should be treated as numeric, based on preferences:
InternalBibtexFields.setNumericFields(Globals.prefs.getStringList(JabRefPreferences.NUMERIC_FIELDS));

// Read list(s) of journal names and abbreviations
Globals.journalAbbreviationLoader = new JournalAbbreviationLoader();

// Build list of Import and Export formats
Globals.IMPORT_FORMAT_READER.resetImportFormats(Globals.prefs.getImportFormatPreferences(),
Globals.prefs.getXMPPreferences(), Globals.getFileUpdateMonitor());
EntryTypes.loadCustomEntryTypes(preferences.loadCustomEntryTypes(BibDatabaseMode.BIBTEX),
preferences.loadCustomEntryTypes(BibDatabaseMode.BIBLATEX));
Globals.entryTypesManager.addCustomizedEntryTypes(preferences.loadBibEntryTypes(BibDatabaseMode.BIBTEX),
preferences.loadBibEntryTypes(BibDatabaseMode.BIBLATEX));
Globals.exportFactory = Globals.prefs.getExporterFactory(Globals.journalAbbreviationLoader);

// Initialize protected terms loader
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/jabref/cli/ArgumentProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import org.jabref.logic.util.OS;
import org.jabref.logic.xmp.XmpPreferences;
import org.jabref.model.Defaults;
import org.jabref.model.EntryTypes;
import org.jabref.model.database.BibDatabase;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.database.BibDatabaseMode;
Expand Down Expand Up @@ -391,7 +390,7 @@ private void saveDatabase(BibDatabase newBase, String subName) {
System.out.println(Localization.lang("Saving") + ": " + subName);
SavePreferences prefs = Globals.prefs.loadForSaveFromPreferences();
AtomicFileWriter fileWriter = new AtomicFileWriter(Paths.get(subName), prefs.getEncoding());
BibDatabaseWriter databaseWriter = new BibtexDatabaseWriter(fileWriter, prefs);
BibDatabaseWriter databaseWriter = new BibtexDatabaseWriter(fileWriter, prefs, Globals.entryTypesManager);
Defaults defaults = new Defaults(Globals.prefs.getDefaultBibDatabaseMode());
databaseWriter.saveDatabase(new BibDatabaseContext(newBase, defaults));

Expand Down Expand Up @@ -458,8 +457,8 @@ private void exportFile(List<ParserResult> loaded, String[] data) {
private void importPreferences() {
try {
Globals.prefs.importPreferences(cli.getPreferencesImport());
EntryTypes.loadCustomEntryTypes(Globals.prefs.loadCustomEntryTypes(BibDatabaseMode.BIBTEX),
Globals.prefs.loadCustomEntryTypes(BibDatabaseMode.BIBLATEX));
Globals.entryTypesManager.addCustomizedEntryTypes(Globals.prefs.loadBibEntryTypes(BibDatabaseMode.BIBTEX),
Globals.prefs.loadBibEntryTypes(BibDatabaseMode.BIBLATEX));
List<TemplateExporter> customExporters = Globals.prefs.getCustomExportFormats(Globals.journalAbbreviationLoader);
LayoutFormatterPreferences layoutPreferences = Globals.prefs
.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/cli/CrossrefFetcherEvaluator.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.jabref.logic.importer.fileformat.BibtexParser;
import org.jabref.model.database.BibDatabase;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.FieldName;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.identifier.DOI;
import org.jabref.preferences.JabRefPreferences;

Expand Down Expand Up @@ -53,7 +53,7 @@ public static void main(String[] args) throws IOException, InterruptedException

@Override
public void run() {
Optional<DOI> origDOI = entry.getField(FieldName.DOI).flatMap(DOI::parse);
Optional<DOI> origDOI = entry.getField(StandardField.DOI).flatMap(DOI::parse);
if (origDOI.isPresent()) {
dois.incrementAndGet();
try {
Expand Down
39 changes: 20 additions & 19 deletions src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,14 @@
import org.jabref.model.database.shared.DatabaseLocation;
import org.jabref.model.database.shared.DatabaseSynchronizer;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.FieldName;
import org.jabref.model.entry.InternalBibtexFields;
import org.jabref.model.entry.LinkedFile;
import org.jabref.model.entry.event.EntryChangedEvent;
import org.jabref.model.entry.event.EntryEventSource;
import org.jabref.model.entry.specialfields.SpecialField;
import org.jabref.model.entry.specialfields.SpecialFieldValue;
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.field.FieldFactory;
import org.jabref.model.entry.field.SpecialField;
import org.jabref.model.entry.field.SpecialFieldValue;
import org.jabref.model.entry.field.StandardField;
import org.jabref.preferences.JabRefPreferences;
import org.jabref.preferences.PreviewPreferences;

Expand Down Expand Up @@ -182,7 +183,7 @@ public BasePanel(JabRefFrame frame, BasePanelPreferences preferences, BibDatabas

this.getDatabase().registerListener(new UpdateTimestampListener(Globals.prefs));

this.entryEditor = new EntryEditor(this, preferences.getEntryEditorPreferences(), Globals.getFileUpdateMonitor(), dialogService, externalFileTypes, Globals.TASK_EXECUTOR, Globals.stateManager);
this.entryEditor = new EntryEditor(this, externalFileTypes);

this.preview = new PreviewPanel(getBibDatabaseContext(), this, dialogService, externalFileTypes, Globals.getKeyPrefs(), preferences.getPreviewPreferences());
}
Expand Down Expand Up @@ -573,13 +574,13 @@ private void openExternalFile() {
}
JabRefExecutorService.INSTANCE.execute(() -> {
final BibEntry entry = selectedEntries.get(0);
if (!entry.hasField(FieldName.FILE)) {
if (!entry.hasField(StandardField.FILE)) {
// no bibtex field
new SearchAndOpenFile(entry, BasePanel.this).searchAndOpen();
return;
}
FileListTableModel fileListTableModel = new FileListTableModel();
entry.getField(FieldName.FILE).ifPresent(fileListTableModel::setContent);
entry.getField(StandardField.FILE).ifPresent(fileListTableModel::setContent);
if (fileListTableModel.getRowCount() == 0) {
// content in BibTeX field is not readable
new SearchAndOpenFile(entry, BasePanel.this).searchAndOpen();
Expand Down Expand Up @@ -637,7 +638,7 @@ public void insertEntry(final BibEntry bibEntry) {

// Create an UndoableInsertEntry object.
getUndoManager().addEdit(new UndoableInsertEntry(bibDatabaseContext.getDatabase(), bibEntry));
output(Localization.lang("Added new '%0' entry.", bibEntry.getType()));
output(Localization.lang("Added new '%0' entry.", bibEntry.getType().getDisplayName()));

markBaseChanged(); // The database just changed.
if (Globals.prefs.getBoolean(JabRefPreferences.AUTO_OPEN_FORM)) {
Expand All @@ -650,11 +651,11 @@ public void insertEntry(final BibEntry bibEntry) {
}
}

public void editEntryAndFocusField(BibEntry entry, String fieldName) {
public void editEntryAndFocusField(BibEntry entry, Field field) {
showAndEdit(entry);
Platform.runLater(() -> {
// Focus field and entry in main table (async to give entry editor time to load)
entryEditor.setFocusToField(fieldName);
entryEditor.setFocusToField(field);
clearAndSelect(entry);
});
}
Expand Down Expand Up @@ -808,7 +809,7 @@ public void updateSearchManager() {
}

private void instantiateSearchAutoCompleter() {
searchAutoCompleter = new PersonNameSuggestionProvider(InternalBibtexFields.getPersonNameFields());
searchAutoCompleter = new PersonNameSuggestionProvider(FieldFactory.getPersonNameFields());
for (BibEntry entry : bibDatabaseContext.getDatabase().getEntries()) {
searchAutoCompleter.indexEntry(entry);
}
Expand Down Expand Up @@ -1300,11 +1301,11 @@ private class OpenURLAction implements BaseAction {
public void action() {
final List<BibEntry> bes = mainTable.getSelectedEntries();
if (bes.size() == 1) {
String field = FieldName.DOI;
Optional<String> link = bes.get(0).getField(FieldName.DOI);
if (bes.get(0).hasField(FieldName.URL)) {
link = bes.get(0).getField(FieldName.URL);
field = FieldName.URL;
Field field = StandardField.DOI;
Optional<String> link = bes.get(0).getField(StandardField.DOI);
if (bes.get(0).hasField(StandardField.URL)) {
link = bes.get(0).getField(StandardField.URL);
field = StandardField.URL;
}
if (link.isPresent()) {
try {
Expand All @@ -1320,9 +1321,9 @@ public void action() {
List<LinkedFile> files = bes.get(0).getFiles();

Optional<LinkedFile> linkedFile = files.stream()
.filter(file -> (FieldName.URL.equalsIgnoreCase(file.getFileType())
|| FieldName.PS.equalsIgnoreCase(file.getFileType())
|| FieldName.PDF.equalsIgnoreCase(file.getFileType())))
.filter(file -> (StandardField.URL.getName().equalsIgnoreCase(file.getFileType())
|| StandardField.PS.getName().equalsIgnoreCase(file.getFileType())
|| StandardField.PDF.getName().equalsIgnoreCase(file.getFileType())))
.findFirst();

if (linkedFile.isPresent()) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/ClipBoardManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void setContent(String string) {

public void setContent(List<BibEntry> entries) throws IOException {
final ClipboardContent content = new ClipboardContent();
BibEntryWriter writer = new BibEntryWriter(new LatexFieldFormatter(Globals.prefs.getLatexFieldFormatterPreferences()), false);
BibEntryWriter writer = new BibEntryWriter(new LatexFieldFormatter(Globals.prefs.getLatexFieldFormatterPreferences()), Globals.entryTypesManager);
String serializedEntries = writer.serializeAll(entries, BibDatabaseMode.BIBTEX);
content.put(DragAndDropDataFormats.ENTRIES, serializedEntries);
content.putString(serializedEntries);
Expand Down
Loading

0 comments on commit 0a779be

Please sign in to comment.