Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into newGlobalSearch
Browse files Browse the repository at this point in the history
* upstream/main:
  Switch to archive.org for site.icu-project.org
  Add Java Profiler
  Fix output when closing JabRef while indexing (#8043)
  Remove explicit XMP import for PDFs (#8040)
  Fix crosses
  Stop indexing on cancel (#8039)
  Write embedded bib in addition to XMP metadata (#8037)
  Cleanup preferences (#8036)
  Fix Search dark mode theme (#8028)
  Allow the search to return multiple entries. (#8038)
  Refactored GroupTree.fxml to plain java (#8035)
  • Loading branch information
Siedlerchr committed Aug 31, 2021
2 parents ccdcb46 + e78a8fa commit 715d068
Show file tree
Hide file tree
Showing 63 changed files with 794 additions and 314 deletions.
10 changes: 5 additions & 5 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ The title of the PR must not reference an issue, because GitHub does not support
- [x] done; [ ] not done / not applicable
-->

- [] Change in `CHANGELOG.md` described in a way that is understandable for the average user (if applicable)
- [] Tests created for changes (if applicable)
- [] Manually tested changed features in running JabRef (always required)
- [] Screenshots added in PR description (for UI changes)
- [] [Checked documentation](https://docs.jabref.org/): Is the information available and up to date? If not created an issue at <https://github.com/JabRef/user-documentation/issues> or, even better, submitted a pull request to the documentation repository.
- [ ] Change in `CHANGELOG.md` described in a way that is understandable for the average user (if applicable)
- [ ] Tests created for changes (if applicable)
- [ ] Manually tested changed features in running JabRef (always required)
- [ ] Screenshots added in PR description (for UI changes)
- [ ] [Checked documentation](https://docs.jabref.org/): Is the information available and up to date? If not, I created an issue at <https://github.com/JabRef/user-documentation/issues> or, even better, I submitted a pull request to the documentation repository.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We merged the barely used ImportSettingsTab and the CustomizationTab in the preferences into one single tab and moved the option to allow Integers in Edition Fields in Bibtex-Mode to the EntryEditor tab. [#7849](https://github.com/JabRef/jabref/pull/7849)
- We moved the export order in the preferences from `File` to `Import and Export`. [#7935](https://github.com/JabRef/jabref/pull/7935)
- We reworked the export order in the preferences and the save order in the library preferences. You can now set more than three sort criteria in your library preferences. [#7935](https://github.com/JabRef/jabref/pull/7935)
- The metadata-to-pdf actions now also embeds the bibfile to the PDF. [#8037](https://github.com/JabRef/jabref/pull/8037)

### Fixed

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,9 @@ For IntelliJ IDEA, just import the project via a Gradle Import by pointing at th

`gradlew test` executes all tests. We use [Github Actions](https://github.com/JabRef/jabref/actions) for executing the tests after each commit. For developing, it is sufficient to locally only run the associated test for the classes you changed. Github will report any other failure.

## Sponsoring

JabRef development is powered by YourKit Java Profiler [![YourKit Java Profiler](https://www.yourkit.com/images/yk_logo.png)](https://www.yourkit.com/java/profiler/)


[JabRef]: https://www.jabref.org
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Some entry titles are composed of multiple sentences, for example: "Whose Music?

* [Regular expression](https://docs.oracle.com/javase/tutorial/essential/regex/)
* [OpenNLP](https://opennlp.apache.org/)
* [ICU4J](http://site.icu-project.org/home)
* [ICU4J](https://web.archive.org/web/20210413013221/http://site.icu-project.org/home)

## Decision Outcome

Expand Down
78 changes: 55 additions & 23 deletions src/main/java/org/jabref/cli/ArgumentProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
import org.jabref.gui.externalfiletype.ExternalFileTypes;
import org.jabref.gui.undo.NamedCompound;
import org.jabref.logic.JabRefException;
import org.jabref.logic.bibtex.FieldWriterPreferences;
import org.jabref.logic.citationkeypattern.CitationKeyGenerator;
import org.jabref.logic.exporter.AtomicFileWriter;
import org.jabref.logic.exporter.BibDatabaseWriter;
import org.jabref.logic.exporter.BibtexDatabaseWriter;
import org.jabref.logic.exporter.EmbeddedBibFilePdfExporter;
import org.jabref.logic.exporter.Exporter;
import org.jabref.logic.exporter.ExporterFactory;
import org.jabref.logic.exporter.SavePreferences;
Expand Down Expand Up @@ -51,6 +53,7 @@
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.database.BibDatabaseMode;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibEntryTypesManager;
import org.jabref.model.strings.StringUtil;
import org.jabref.model.util.DummyFileUpdateMonitor;
import org.jabref.model.util.FileHelper;
Expand Down Expand Up @@ -224,13 +227,22 @@ private List<ParserResult> processArguments() {
automaticallySetFileLinks(loaded);
}

if (cli.isWriteXMPtoPdf()) {
if (cli.isWriteXMPtoPdf() && cli.isEmbeddBibfileInPdf() || cli.isWriteMetadatatoPdf() && (cli.isWriteXMPtoPdf() || cli.isEmbeddBibfileInPdf())) {
System.err.println("Give only one of [writeXMPtoPdf, embeddBibfileInPdf, writeMetadatatoPdf]");
}

if (cli.isWriteMetadatatoPdf() || cli.isWriteXMPtoPdf() || cli.isEmbeddBibfileInPdf()) {
if (!loaded.isEmpty()) {
writeXMPtoPdf(loaded,
cli.getWriteXMPtoPdf(),
writeMetadatatoPdf(loaded,
cli.getWriteMetadatatoPdf(),
preferencesService.getDefaultEncoding(),
preferencesService.getXmpPreferences(),
preferencesService.getFilePreferences());
preferencesService.getFilePreferences(),
preferencesService.getDefaultBibDatabaseMode(),
Globals.entryTypesManager,
preferencesService.getFieldWriterPreferences(),
cli.isWriteXMPtoPdf() || cli.isWriteMetadatatoPdf(),
cli.isEmbeddBibfileInPdf() || cli.isWriteMetadatatoPdf());
}
}

Expand Down Expand Up @@ -258,7 +270,7 @@ private List<ParserResult> processArguments() {
return loaded;
}

private void writeXMPtoPdf(List<ParserResult> loaded, String filesAndCitekeys, Charset encoding, XmpPreferences xmpPreferences, FilePreferences filePreferences) {
private void writeMetadatatoPdf(List<ParserResult> loaded, String filesAndCitekeys, Charset encoding, XmpPreferences xmpPreferences, FilePreferences filePreferences, BibDatabaseMode databaseMode, BibEntryTypesManager entryTypesManager, FieldWriterPreferences fieldWriterPreferences, boolean writeXMP, boolean embeddBibfile) {
if (loaded.isEmpty()) {
LOGGER.error("The write xmp option depends on a valid import option.");
return;
Expand All @@ -268,10 +280,11 @@ private void writeXMPtoPdf(List<ParserResult> loaded, String filesAndCitekeys, C
BibDatabase dataBase = pr.getDatabase();

XmpPdfExporter xmpPdfExporter = new XmpPdfExporter(xmpPreferences);
EmbeddedBibFilePdfExporter embeddedBibFilePdfExporter = new EmbeddedBibFilePdfExporter(databaseMode, entryTypesManager, fieldWriterPreferences);

if ("all".equals(filesAndCitekeys)) {
for (BibEntry entry : dataBase.getEntries()) {
writeXMPtoPDFsOfEntry(databaseContext, entry.getCitationKey().orElse("<no cite key defined>"), entry, encoding, filePreferences, xmpPdfExporter);
writeMetadatatoPDFsOfEntry(databaseContext, entry.getCitationKey().orElse("<no cite key defined>"), entry, encoding, filePreferences, xmpPdfExporter, embeddedBibFilePdfExporter, writeXMP, embeddBibfile);
}
return;
}
Expand All @@ -286,48 +299,66 @@ private void writeXMPtoPdf(List<ParserResult> loaded, String filesAndCitekeys, C
}
}

writeXMPtoPdfByCitekey(databaseContext, dataBase, citeKeys, encoding, filePreferences, xmpPdfExporter);
writeXMPtoPdfByFileNames(databaseContext, dataBase, pdfs, encoding, filePreferences, xmpPdfExporter);
writeMetadatatoPdfByCitekey(databaseContext, dataBase, citeKeys, encoding, filePreferences, xmpPdfExporter, embeddedBibFilePdfExporter, writeXMP, embeddBibfile);
writeMetadatatoPdfByFileNames(databaseContext, dataBase, pdfs, encoding, filePreferences, xmpPdfExporter, embeddedBibFilePdfExporter, writeXMP, embeddBibfile);

}

private void writeXMPtoPDFsOfEntry(BibDatabaseContext databaseContext, String citeKey, BibEntry entry, Charset encoding, FilePreferences filePreferences, XmpPdfExporter xmpPdfExporter) {
private void writeMetadatatoPDFsOfEntry(BibDatabaseContext databaseContext, String citeKey, BibEntry entry, Charset encoding, FilePreferences filePreferences, XmpPdfExporter xmpPdfExporter, EmbeddedBibFilePdfExporter embeddedBibFilePdfExporter, boolean writeXMP, boolean embeddBibfile) {
try {
if (xmpPdfExporter.exportToAllFilesOfEntry(databaseContext, encoding, filePreferences, entry, List.of(entry))) {
LOGGER.info(String.format("Successfully written XMP metadata on at least one linked file of %s", citeKey));
} else {
LOGGER.error(String.format("Cannot write XMP metadata on any linked files of %s. Make sure there is at least one linked file and the path is correct.", citeKey));
if (writeXMP) {
if (xmpPdfExporter.exportToAllFilesOfEntry(databaseContext, encoding, filePreferences, entry, List.of(entry))) {
System.out.println(String.format("Successfully written XMP metadata on at least one linked file of %s", citeKey));
} else {
System.err.println(String.format("Cannot write XMP metadata on any linked files of %s. Make sure there is at least one linked file and the path is correct.", citeKey));
}
}
if (embeddBibfile) {
if (embeddedBibFilePdfExporter.exportToAllFilesOfEntry(databaseContext, encoding, filePreferences, entry, List.of(entry))) {
System.out.println(String.format("Successfully embedded metadata on at least one linked file of %s", citeKey));
} else {
System.out.println(String.format("Cannot embedd metadata on any linked files of %s. Make sure there is at least one linked file and the path is correct.", citeKey));
}
}
} catch (Exception e) {
LOGGER.error(String.format("Failed writing XMP metadata on a linked file of %s.", citeKey));
LOGGER.error(String.format("Failed writing metadata on a linked file of %s.", citeKey));
}
}

private void writeXMPtoPdfByCitekey(BibDatabaseContext databaseContext, BibDatabase dataBase, Vector<String> citeKeys, Charset encoding, FilePreferences filePreferences, XmpPdfExporter xmpPdfExporter) {
private void writeMetadatatoPdfByCitekey(BibDatabaseContext databaseContext, BibDatabase dataBase, Vector<String> citeKeys, Charset encoding, FilePreferences filePreferences, XmpPdfExporter xmpPdfExporter, EmbeddedBibFilePdfExporter embeddedBibFilePdfExporter, boolean writeXMP, boolean embeddBibfile) {
for (String citeKey : citeKeys) {
List<BibEntry> bibEntryList = dataBase.getEntriesByCitationKey(citeKey);
if (bibEntryList.isEmpty()) {
LOGGER.error(String.format("Skipped - Cannot find %s in library.", citeKey));
System.err.println(String.format("Skipped - Cannot find %s in library.", citeKey));
continue;
}
for (BibEntry entry : bibEntryList) {
writeXMPtoPDFsOfEntry(databaseContext, citeKey, entry, encoding, filePreferences, xmpPdfExporter);
writeMetadatatoPDFsOfEntry(databaseContext, citeKey, entry, encoding, filePreferences, xmpPdfExporter, embeddedBibFilePdfExporter, writeXMP, embeddBibfile);
}
}
}

private void writeXMPtoPdfByFileNames(BibDatabaseContext databaseContext, BibDatabase dataBase, Vector<String> fileNames, Charset encoding, FilePreferences filePreferences, XmpPdfExporter xmpPdfExporter) {
private void writeMetadatatoPdfByFileNames(BibDatabaseContext databaseContext, BibDatabase dataBase, Vector<String> fileNames, Charset encoding, FilePreferences filePreferences, XmpPdfExporter xmpPdfExporter, EmbeddedBibFilePdfExporter embeddedBibFilePdfExporter, boolean writeXMP, boolean embeddBibfile) {
for (String fileName : fileNames) {
Path filePath = Path.of(fileName);
if (!filePath.isAbsolute()) {
filePath = FileHelper.find(fileName, databaseContext.getFileDirectories(filePreferences)).orElse(FileHelper.find(fileName, List.of(Path.of("").toAbsolutePath())).orElse(filePath));
}
if (Files.exists(filePath)) {
try {
if (xmpPdfExporter.exportToFileByPath(databaseContext, dataBase, encoding, filePreferences, filePath)) {
LOGGER.info(String.format("Successfully written XMP metadata of at least one entry to %s", fileName));
} else {
LOGGER.error(String.format("File %s is not linked to any entry in database.", fileName));
if (writeXMP) {
if (xmpPdfExporter.exportToFileByPath(databaseContext, dataBase, encoding, filePreferences, filePath)) {
System.out.println(String.format("Successfully written XMP metadata of at least one entry to %s", fileName));
} else {
System.out.println(String.format("File %s is not linked to any entry in database.", fileName));
}
}
if (embeddBibfile) {
if (embeddedBibFilePdfExporter.exportToFileByPath(databaseContext, dataBase, encoding, filePreferences, filePath)) {
System.out.println(String.format("Successfully embedded XMP metadata of at least one entry to %s", fileName));
} else {
System.out.println(String.format("File %s is not linked to any entry in database.", fileName));
}
}
} catch (IOException e) {
LOGGER.error("Error accessing file '{}'.", fileName);
Expand Down Expand Up @@ -567,7 +598,8 @@ private void importPreferences() {
preferencesService.getLayoutFormatterPreferences(Globals.journalAbbreviationRepository);
SavePreferences savePreferences = preferencesService.getSavePreferencesForExport();
XmpPreferences xmpPreferences = preferencesService.getXmpPreferences();
Globals.exportFactory = ExporterFactory.create(customExporters, layoutPreferences, savePreferences, xmpPreferences);
BibDatabaseMode bibDatabaseMode = preferencesService.getDefaultBibDatabaseMode();
Globals.exportFactory = ExporterFactory.create(customExporters, layoutPreferences, savePreferences, xmpPreferences, bibDatabaseMode, Globals.entryTypesManager);
} catch (JabRefException ex) {
LOGGER.error("Cannot import preferences", ex);
}
Expand Down
32 changes: 29 additions & 3 deletions src/main/java/org/jabref/cli/JabRefCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,18 @@ public boolean isWriteXMPtoPdf() {
return cl.hasOption("writeXMPtoPdf");
}

public String getWriteXMPtoPdf() {
return cl.getOptionValue("writeXMPtoPdf");
public boolean isEmbeddBibfileInPdf() {
return cl.hasOption("embeddBibfileInPdf");
}

public boolean isWriteMetadatatoPdf() {
return cl.hasOption("writeMetadatatoPdf");
}

public String getWriteMetadatatoPdf() {
return cl.hasOption("writeMetadatatoPdf") ? cl.getOptionValue("writeMetadatatoPdf") :
cl.hasOption("writeXMPtoPdf") ? cl.getOptionValue("writeXMPtoPdf") :
cl.hasOption("embeddBibfileInPdf") ? cl.getOptionValue("embeddBibfileInPdf") : null;
}

private static Options getOptions() {
Expand Down Expand Up @@ -251,13 +261,29 @@ private static Options getOptions() {
.build());

options.addOption(Option
.builder("w")
.builder()
.longOpt("writeXMPtoPdf")
.desc(String.format("%s: '%s'", Localization.lang("Write BibTeXEntry as XMP metadata to PDF."), "-w pathToMyOwnPaper.pdf"))
.hasArg()
.argName("CITEKEY1[,CITEKEY2][,CITEKEYn] | PDF1[,PDF2][,PDFn] | all")
.build());

options.addOption(Option
.builder()
.longOpt("embeddBibfileInPdf")
.desc(String.format("%s: '%s'", Localization.lang("Embedd BibTeXEntry in PDF."), "-w pathToMyOwnPaper.pdf"))
.hasArg()
.argName("CITEKEY1[,CITEKEY2][,CITEKEYn] | PDF1[,PDF2][,PDFn] | all")
.build());

options.addOption(Option
.builder("w")
.longOpt("writeMetadatatoPdf")
.desc(String.format("%s: '%s'", Localization.lang("Write BibTeXEntry as metadata to PDF."), "-w pathToMyOwnPaper.pdf"))
.hasArg()
.argName("CITEKEY1[,CITEKEY2][,CITEKEYn] | PDF1[,PDF2][,PDFn] | all")
.build());

return options;
}

Expand Down
11 changes: 7 additions & 4 deletions src/main/java/org/jabref/gui/Dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@
-fx-background-color: -fx-control-inner-background;
}

.table-row-cell: odd{
.table-row-cell:odd{
-fx-background-color:#272b38;
}

.table-row-cell: even{
.table-row-cell:even{
-fx-background-color: #212330;
}

Expand Down Expand Up @@ -108,12 +108,15 @@
-fx-background-color: -jr-background;
}


.mainToolbar .search-field .toggle-button .glyph-icon {
-fx-fill: -jr-search-text;
-fx-text-fill: -jr-search-text;
-fx-icon-color:-jr-search-text;
}

.mainToolbar .search-field .toggle-button:selected .glyph-icon {
-fx-fill: derive(-jr-search-text, 80%);
-fx-text-fill: derive(-jr-search-text, 80%);
-fx-fill: derive(-fx-light-text-color, 80%);
-fx-text-fill: derive(-fx-light-text-color, 80%);
-fx-icon-color: derive(-fx-light-text-color, 80%);
}
Loading

0 comments on commit 715d068

Please sign in to comment.