Skip to content

Commit 715d068

Browse files
committed
Merge remote-tracking branch 'upstream/main' into newGlobalSearch
* 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)
2 parents ccdcb46 + e78a8fa commit 715d068

File tree

63 files changed

+794
-314
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+794
-314
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ The title of the PR must not reference an issue, because GitHub does not support
1111
- [x] done; [ ] not done / not applicable
1212
-->
1313

14-
- [] Change in `CHANGELOG.md` described in a way that is understandable for the average user (if applicable)
15-
- [] Tests created for changes (if applicable)
16-
- [] Manually tested changed features in running JabRef (always required)
17-
- [] Screenshots added in PR description (for UI changes)
18-
- [] [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.
14+
- [ ] Change in `CHANGELOG.md` described in a way that is understandable for the average user (if applicable)
15+
- [ ] Tests created for changes (if applicable)
16+
- [ ] Manually tested changed features in running JabRef (always required)
17+
- [ ] Screenshots added in PR description (for UI changes)
18+
- [ ] [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.

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
2727
- 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)
2828
- We moved the export order in the preferences from `File` to `Import and Export`. [#7935](https://github.com/JabRef/jabref/pull/7935)
2929
- 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)
30+
- The metadata-to-pdf actions now also embeds the bibfile to the PDF. [#8037](https://github.com/JabRef/jabref/pull/8037)
3031

3132
### Fixed
3233

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,9 @@ For IntelliJ IDEA, just import the project via a Gradle Import by pointing at th
9696

9797
`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.
9898

99+
## Sponsoring
100+
101+
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/)
102+
103+
99104
[JabRef]: https://www.jabref.org

docs/adr/0018-use-regular-expression-to-split-multiple-sentence-titles.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Some entry titles are composed of multiple sentences, for example: "Whose Music?
88

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

1313
## Decision Outcome
1414

src/main/java/org/jabref/cli/ArgumentProcessor.java

+55-23
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818
import org.jabref.gui.externalfiletype.ExternalFileTypes;
1919
import org.jabref.gui.undo.NamedCompound;
2020
import org.jabref.logic.JabRefException;
21+
import org.jabref.logic.bibtex.FieldWriterPreferences;
2122
import org.jabref.logic.citationkeypattern.CitationKeyGenerator;
2223
import org.jabref.logic.exporter.AtomicFileWriter;
2324
import org.jabref.logic.exporter.BibDatabaseWriter;
2425
import org.jabref.logic.exporter.BibtexDatabaseWriter;
26+
import org.jabref.logic.exporter.EmbeddedBibFilePdfExporter;
2527
import org.jabref.logic.exporter.Exporter;
2628
import org.jabref.logic.exporter.ExporterFactory;
2729
import org.jabref.logic.exporter.SavePreferences;
@@ -51,6 +53,7 @@
5153
import org.jabref.model.database.BibDatabaseContext;
5254
import org.jabref.model.database.BibDatabaseMode;
5355
import org.jabref.model.entry.BibEntry;
56+
import org.jabref.model.entry.BibEntryTypesManager;
5457
import org.jabref.model.strings.StringUtil;
5558
import org.jabref.model.util.DummyFileUpdateMonitor;
5659
import org.jabref.model.util.FileHelper;
@@ -224,13 +227,22 @@ private List<ParserResult> processArguments() {
224227
automaticallySetFileLinks(loaded);
225228
}
226229

227-
if (cli.isWriteXMPtoPdf()) {
230+
if (cli.isWriteXMPtoPdf() && cli.isEmbeddBibfileInPdf() || cli.isWriteMetadatatoPdf() && (cli.isWriteXMPtoPdf() || cli.isEmbeddBibfileInPdf())) {
231+
System.err.println("Give only one of [writeXMPtoPdf, embeddBibfileInPdf, writeMetadatatoPdf]");
232+
}
233+
234+
if (cli.isWriteMetadatatoPdf() || cli.isWriteXMPtoPdf() || cli.isEmbeddBibfileInPdf()) {
228235
if (!loaded.isEmpty()) {
229-
writeXMPtoPdf(loaded,
230-
cli.getWriteXMPtoPdf(),
236+
writeMetadatatoPdf(loaded,
237+
cli.getWriteMetadatatoPdf(),
231238
preferencesService.getDefaultEncoding(),
232239
preferencesService.getXmpPreferences(),
233-
preferencesService.getFilePreferences());
240+
preferencesService.getFilePreferences(),
241+
preferencesService.getDefaultBibDatabaseMode(),
242+
Globals.entryTypesManager,
243+
preferencesService.getFieldWriterPreferences(),
244+
cli.isWriteXMPtoPdf() || cli.isWriteMetadatatoPdf(),
245+
cli.isEmbeddBibfileInPdf() || cli.isWriteMetadatatoPdf());
234246
}
235247
}
236248

@@ -258,7 +270,7 @@ private List<ParserResult> processArguments() {
258270
return loaded;
259271
}
260272

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

270282
XmpPdfExporter xmpPdfExporter = new XmpPdfExporter(xmpPreferences);
283+
EmbeddedBibFilePdfExporter embeddedBibFilePdfExporter = new EmbeddedBibFilePdfExporter(databaseMode, entryTypesManager, fieldWriterPreferences);
271284

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

289-
writeXMPtoPdfByCitekey(databaseContext, dataBase, citeKeys, encoding, filePreferences, xmpPdfExporter);
290-
writeXMPtoPdfByFileNames(databaseContext, dataBase, pdfs, encoding, filePreferences, xmpPdfExporter);
302+
writeMetadatatoPdfByCitekey(databaseContext, dataBase, citeKeys, encoding, filePreferences, xmpPdfExporter, embeddedBibFilePdfExporter, writeXMP, embeddBibfile);
303+
writeMetadatatoPdfByFileNames(databaseContext, dataBase, pdfs, encoding, filePreferences, xmpPdfExporter, embeddedBibFilePdfExporter, writeXMP, embeddBibfile);
291304

292305
}
293306

294-
private void writeXMPtoPDFsOfEntry(BibDatabaseContext databaseContext, String citeKey, BibEntry entry, Charset encoding, FilePreferences filePreferences, XmpPdfExporter xmpPdfExporter) {
307+
private void writeMetadatatoPDFsOfEntry(BibDatabaseContext databaseContext, String citeKey, BibEntry entry, Charset encoding, FilePreferences filePreferences, XmpPdfExporter xmpPdfExporter, EmbeddedBibFilePdfExporter embeddedBibFilePdfExporter, boolean writeXMP, boolean embeddBibfile) {
295308
try {
296-
if (xmpPdfExporter.exportToAllFilesOfEntry(databaseContext, encoding, filePreferences, entry, List.of(entry))) {
297-
LOGGER.info(String.format("Successfully written XMP metadata on at least one linked file of %s", citeKey));
298-
} else {
299-
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));
309+
if (writeXMP) {
310+
if (xmpPdfExporter.exportToAllFilesOfEntry(databaseContext, encoding, filePreferences, entry, List.of(entry))) {
311+
System.out.println(String.format("Successfully written XMP metadata on at least one linked file of %s", citeKey));
312+
} else {
313+
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));
314+
}
315+
}
316+
if (embeddBibfile) {
317+
if (embeddedBibFilePdfExporter.exportToAllFilesOfEntry(databaseContext, encoding, filePreferences, entry, List.of(entry))) {
318+
System.out.println(String.format("Successfully embedded metadata on at least one linked file of %s", citeKey));
319+
} else {
320+
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));
321+
}
300322
}
301323
} catch (Exception e) {
302-
LOGGER.error(String.format("Failed writing XMP metadata on a linked file of %s.", citeKey));
324+
LOGGER.error(String.format("Failed writing metadata on a linked file of %s.", citeKey));
303325
}
304326
}
305327

306-
private void writeXMPtoPdfByCitekey(BibDatabaseContext databaseContext, BibDatabase dataBase, Vector<String> citeKeys, Charset encoding, FilePreferences filePreferences, XmpPdfExporter xmpPdfExporter) {
328+
private void writeMetadatatoPdfByCitekey(BibDatabaseContext databaseContext, BibDatabase dataBase, Vector<String> citeKeys, Charset encoding, FilePreferences filePreferences, XmpPdfExporter xmpPdfExporter, EmbeddedBibFilePdfExporter embeddedBibFilePdfExporter, boolean writeXMP, boolean embeddBibfile) {
307329
for (String citeKey : citeKeys) {
308330
List<BibEntry> bibEntryList = dataBase.getEntriesByCitationKey(citeKey);
309331
if (bibEntryList.isEmpty()) {
310-
LOGGER.error(String.format("Skipped - Cannot find %s in library.", citeKey));
332+
System.err.println(String.format("Skipped - Cannot find %s in library.", citeKey));
311333
continue;
312334
}
313335
for (BibEntry entry : bibEntryList) {
314-
writeXMPtoPDFsOfEntry(databaseContext, citeKey, entry, encoding, filePreferences, xmpPdfExporter);
336+
writeMetadatatoPDFsOfEntry(databaseContext, citeKey, entry, encoding, filePreferences, xmpPdfExporter, embeddedBibFilePdfExporter, writeXMP, embeddBibfile);
315337
}
316338
}
317339
}
318340

319-
private void writeXMPtoPdfByFileNames(BibDatabaseContext databaseContext, BibDatabase dataBase, Vector<String> fileNames, Charset encoding, FilePreferences filePreferences, XmpPdfExporter xmpPdfExporter) {
341+
private void writeMetadatatoPdfByFileNames(BibDatabaseContext databaseContext, BibDatabase dataBase, Vector<String> fileNames, Charset encoding, FilePreferences filePreferences, XmpPdfExporter xmpPdfExporter, EmbeddedBibFilePdfExporter embeddedBibFilePdfExporter, boolean writeXMP, boolean embeddBibfile) {
320342
for (String fileName : fileNames) {
321343
Path filePath = Path.of(fileName);
322344
if (!filePath.isAbsolute()) {
323345
filePath = FileHelper.find(fileName, databaseContext.getFileDirectories(filePreferences)).orElse(FileHelper.find(fileName, List.of(Path.of("").toAbsolutePath())).orElse(filePath));
324346
}
325347
if (Files.exists(filePath)) {
326348
try {
327-
if (xmpPdfExporter.exportToFileByPath(databaseContext, dataBase, encoding, filePreferences, filePath)) {
328-
LOGGER.info(String.format("Successfully written XMP metadata of at least one entry to %s", fileName));
329-
} else {
330-
LOGGER.error(String.format("File %s is not linked to any entry in database.", fileName));
349+
if (writeXMP) {
350+
if (xmpPdfExporter.exportToFileByPath(databaseContext, dataBase, encoding, filePreferences, filePath)) {
351+
System.out.println(String.format("Successfully written XMP metadata of at least one entry to %s", fileName));
352+
} else {
353+
System.out.println(String.format("File %s is not linked to any entry in database.", fileName));
354+
}
355+
}
356+
if (embeddBibfile) {
357+
if (embeddedBibFilePdfExporter.exportToFileByPath(databaseContext, dataBase, encoding, filePreferences, filePath)) {
358+
System.out.println(String.format("Successfully embedded XMP metadata of at least one entry to %s", fileName));
359+
} else {
360+
System.out.println(String.format("File %s is not linked to any entry in database.", fileName));
361+
}
331362
}
332363
} catch (IOException e) {
333364
LOGGER.error("Error accessing file '{}'.", fileName);
@@ -567,7 +598,8 @@ private void importPreferences() {
567598
preferencesService.getLayoutFormatterPreferences(Globals.journalAbbreviationRepository);
568599
SavePreferences savePreferences = preferencesService.getSavePreferencesForExport();
569600
XmpPreferences xmpPreferences = preferencesService.getXmpPreferences();
570-
Globals.exportFactory = ExporterFactory.create(customExporters, layoutPreferences, savePreferences, xmpPreferences);
601+
BibDatabaseMode bibDatabaseMode = preferencesService.getDefaultBibDatabaseMode();
602+
Globals.exportFactory = ExporterFactory.create(customExporters, layoutPreferences, savePreferences, xmpPreferences, bibDatabaseMode, Globals.entryTypesManager);
571603
} catch (JabRefException ex) {
572604
LOGGER.error("Cannot import preferences", ex);
573605
}

src/main/java/org/jabref/cli/JabRefCLI.java

+29-3
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,18 @@ public boolean isWriteXMPtoPdf() {
151151
return cl.hasOption("writeXMPtoPdf");
152152
}
153153

154-
public String getWriteXMPtoPdf() {
155-
return cl.getOptionValue("writeXMPtoPdf");
154+
public boolean isEmbeddBibfileInPdf() {
155+
return cl.hasOption("embeddBibfileInPdf");
156+
}
157+
158+
public boolean isWriteMetadatatoPdf() {
159+
return cl.hasOption("writeMetadatatoPdf");
160+
}
161+
162+
public String getWriteMetadatatoPdf() {
163+
return cl.hasOption("writeMetadatatoPdf") ? cl.getOptionValue("writeMetadatatoPdf") :
164+
cl.hasOption("writeXMPtoPdf") ? cl.getOptionValue("writeXMPtoPdf") :
165+
cl.hasOption("embeddBibfileInPdf") ? cl.getOptionValue("embeddBibfileInPdf") : null;
156166
}
157167

158168
private static Options getOptions() {
@@ -251,13 +261,29 @@ private static Options getOptions() {
251261
.build());
252262

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

271+
options.addOption(Option
272+
.builder()
273+
.longOpt("embeddBibfileInPdf")
274+
.desc(String.format("%s: '%s'", Localization.lang("Embedd BibTeXEntry in PDF."), "-w pathToMyOwnPaper.pdf"))
275+
.hasArg()
276+
.argName("CITEKEY1[,CITEKEY2][,CITEKEYn] | PDF1[,PDF2][,PDFn] | all")
277+
.build());
278+
279+
options.addOption(Option
280+
.builder("w")
281+
.longOpt("writeMetadatatoPdf")
282+
.desc(String.format("%s: '%s'", Localization.lang("Write BibTeXEntry as metadata to PDF."), "-w pathToMyOwnPaper.pdf"))
283+
.hasArg()
284+
.argName("CITEKEY1[,CITEKEY2][,CITEKEYn] | PDF1[,PDF2][,PDFn] | all")
285+
.build());
286+
261287
return options;
262288
}
263289

src/main/java/org/jabref/gui/Dark.css

+7-4
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@
6666
-fx-background-color: -fx-control-inner-background;
6767
}
6868

69-
.table-row-cell: odd{
69+
.table-row-cell:odd{
7070
-fx-background-color:#272b38;
7171
}
7272

73-
.table-row-cell: even{
73+
.table-row-cell:even{
7474
-fx-background-color: #212330;
7575
}
7676

@@ -108,12 +108,15 @@
108108
-fx-background-color: -jr-background;
109109
}
110110

111+
111112
.mainToolbar .search-field .toggle-button .glyph-icon {
112113
-fx-fill: -jr-search-text;
113114
-fx-text-fill: -jr-search-text;
115+
-fx-icon-color:-jr-search-text;
114116
}
115117

116118
.mainToolbar .search-field .toggle-button:selected .glyph-icon {
117-
-fx-fill: derive(-jr-search-text, 80%);
118-
-fx-text-fill: derive(-jr-search-text, 80%);
119+
-fx-fill: derive(-fx-light-text-color, 80%);
120+
-fx-text-fill: derive(-fx-light-text-color, 80%);
121+
-fx-icon-color: derive(-fx-light-text-color, 80%);
119122
}

0 commit comments

Comments
 (0)