Skip to content

Commit dccf476

Browse files
committed
Merge remote-tracking branch 'upstream/master' into fixgroupsmove
* upstream/master: Add eprint cleanup (#4445) respect preference state (#4468) Set auto-update checkbox enable/disable when reading preferences (#4446) Improve MathSciNet fetcher and add ISBN fetcher to entry editor toolbar (#4444) New translations JabRef_en.properties (German) (#4455)
2 parents 2bdaba6 + 144522d commit dccf476

22 files changed

+451
-305
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
1616
- We changed the behavior of the field formatting dialog such that the `bibtexkey` is not changed when formatting all fields or all text fields.
1717
- We added a "Move file to file directory and rename file" option for simultaneously moving and renaming of document file. [#4166](https://github.com/JabRef/jabref/issues/4166)
1818
- Use integrated graphics card instead of discrete on macOS [#4070](https://github.com/JabRef/jabref/issues/4070)
19+
- We added a cleanup operation that detects an arXiv identifier in the note, journal or url field and moves it to the `eprint` field.
20+
Because of this change, the last-used cleanup operations were reset.
1921
- We changed the minimum required version of Java to 1.8.0_171, as this is the latest release for which the automatic Java update works. [4093](https://github.com/JabRef/jabref/issues/4093)
2022
- The special fields like `Printed` and `Read status` now show gray icons when the row is hovered.
2123
- We added a button in the tab header which allows you to close the database with one click. https://github.com/JabRef/jabref/issues/494
@@ -28,6 +30,8 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
2830
- We changed the default keyboard shortcuts for moving between entries when the entry editor is active to ̀<kbd>alt</kbd> + <kbd>up/down</kbd>.
2931
- Opening a new file now prompts the directory of the currently selected file, instead of the directory of the last opened file.
3032
- Window state is saved on close and restored on start.
33+
- We made the MathSciNet fetcher more reliable.
34+
- We added the ISBN fetcher to the list of fetcher available under "Update with bibliographic information from the web" in the entry editor toolbar.
3135
- Files without a defined external file type are now directly opened with the default application of the operating system
3236
- We streamlined the process to rename and move files by removing the confirmation dialogs.
3337
- We removed the redundant new lines of markings and wrapped the summary in the File annotation tab. [#3823](https://github.com/JabRef/jabref/issues/3823)

src/main/java/org/jabref/gui/actions/CleanupAction.java

+23-26
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import org.jabref.gui.undo.NamedCompound;
1111
import org.jabref.gui.undo.UndoableFieldChange;
1212
import org.jabref.gui.util.BackgroundTask;
13-
import org.jabref.gui.util.DefaultTaskExecutor;
1413
import org.jabref.logic.cleanup.CleanupPreset;
1514
import org.jabref.logic.cleanup.CleanupWorker;
1615
import org.jabref.logic.l10n.Localization;
@@ -23,11 +22,6 @@ public class CleanupAction implements BaseAction {
2322
private final BasePanel panel;
2423
private final DialogService dialogService;
2524

26-
/**
27-
* Global variable to count unsuccessful renames
28-
*/
29-
private int unsuccessfulRenames;
30-
3125
private boolean isCanceled;
3226
private int modifiedEntriesCount;
3327
private final JabRefPreferences preferences;
@@ -44,13 +38,31 @@ public void action() {
4438
if (isCanceled) {
4539
return;
4640
}
47-
CleanupDialog cleanupDialog = new CleanupDialog(panel.getBibDatabaseContext(), preferences.getCleanupPreset());
41+
CleanupDialog cleanupDialog = new CleanupDialog(panel.getBibDatabaseContext(), preferences.getCleanupPreset(), preferences.getFilePreferences());
4842

4943
Optional<CleanupPreset> chosenPreset = cleanupDialog.showAndWait();
50-
chosenPreset.ifPresent(cleanupPreset ->
51-
BackgroundTask.wrap(() -> cleanup(cleanupPreset))
52-
.onSuccess(x -> showResults())
53-
.executeWith(Globals.TASK_EXECUTOR));
44+
45+
if (chosenPreset.isPresent()) {
46+
if (chosenPreset.get().isRenamePDFActive() && preferences.getBoolean(JabRefPreferences.ASK_AUTO_NAMING_PDFS_AGAIN)) {
47+
boolean confirmed = dialogService.showConfirmationDialogWithOptOutAndWait(Localization.lang("Autogenerate PDF Names"),
48+
Localization.lang("Auto-generating PDF-Names does not support undo. Continue?"),
49+
Localization.lang("Autogenerate PDF Names"),
50+
Localization.lang("Cancel"),
51+
Localization.lang("Disable this confirmation dialog"),
52+
optOut -> Globals.prefs.putBoolean(JabRefPreferences.ASK_AUTO_NAMING_PDFS_AGAIN, !optOut));
53+
54+
if (!confirmed) {
55+
isCanceled = true;
56+
return;
57+
}
58+
}
59+
60+
preferences.setCleanupPreset(chosenPreset.get());
61+
62+
BackgroundTask.wrap(() -> cleanup(chosenPreset.get()))
63+
.onSuccess(result -> showResults())
64+
.executeWith(Globals.TASK_EXECUTOR);
65+
}
5466
}
5567

5668
public void init() {
@@ -111,21 +123,6 @@ private void showResults() {
111123
private void cleanup(CleanupPreset cleanupPreset) {
112124
preferences.setCleanupPreset(cleanupPreset);
113125

114-
if (cleanupPreset.isRenamePDF() && preferences.getBoolean(JabRefPreferences.ASK_AUTO_NAMING_PDFS_AGAIN)) {
115-
116-
boolean confirmed = DefaultTaskExecutor.runInJavaFXThread(() -> dialogService.showConfirmationDialogWithOptOutAndWait(Localization.lang("Autogenerate PDF Names"),
117-
Localization.lang("Auto-generating PDF-Names does not support undo. Continue?"),
118-
Localization.lang("Autogenerate PDF Names"),
119-
Localization.lang("Cancel"),
120-
Localization.lang("Disable this confirmation dialog"),
121-
optOut -> Globals.prefs.putBoolean(JabRefPreferences.ASK_AUTO_NAMING_PDFS_AGAIN, !optOut)));
122-
123-
if (!confirmed) {
124-
isCanceled = true;
125-
return;
126-
}
127-
}
128-
129126
for (BibEntry entry : panel.getSelectedEntries()) {
130127
// undo granularity is on entry level
131128
NamedCompound ce = new NamedCompound(Localization.lang("Cleanup entry"));

src/main/java/org/jabref/gui/cleanup/CleanupDialog.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
import org.jabref.logic.cleanup.CleanupPreset;
77
import org.jabref.logic.l10n.Localization;
88
import org.jabref.model.database.BibDatabaseContext;
9+
import org.jabref.model.metadata.FilePreferences;
910

1011
public class CleanupDialog extends BaseDialog<CleanupPreset> {
1112

12-
public CleanupDialog(BibDatabaseContext databaseContext, CleanupPreset initialPreset) {
13+
public CleanupDialog(BibDatabaseContext databaseContext, CleanupPreset initialPreset, FilePreferences filePreferences) {
1314
setTitle(Localization.lang("Cleanup entries"));
1415
getDialogPane().setPrefSize(600, 600);
1516
getDialogPane().getButtonTypes().setAll(ButtonType.OK, ButtonType.CANCEL);
1617

17-
CleanupPresetPanel presetPanel = new CleanupPresetPanel(databaseContext, initialPreset);
18+
CleanupPresetPanel presetPanel = new CleanupPresetPanel(databaseContext, initialPreset, filePreferences);
1819
getDialogPane().setContent(presetPanel);
1920
setResultConverter(button -> {
2021
if (button == ButtonType.OK) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<?import javafx.geometry.Insets?>
4+
<?import javafx.scene.control.CheckBox?>
5+
<?import javafx.scene.control.Label?>
6+
<?import javafx.scene.layout.VBox?>
7+
<fx:root xmlns:fx="http://javafx.com/fxml/1" spacing="10.0" type="VBox" xmlns="http://javafx.com/javafx/8.0.121"
8+
fx:controller="org.jabref.gui.cleanup.CleanupPresetPanel">
9+
10+
<CheckBox fx:id="cleanUpDOI" text="%Move DOIs from note and URL field to DOI field and remove http prefix"/>
11+
<CheckBox fx:id="cleanUpEprint"
12+
text="%Move preprint information from 'URL' and 'journal' field to the 'eprint' field"/>
13+
<CheckBox fx:id="cleanUpISSN" text="%Reformat ISSN"/>
14+
<CheckBox fx:id="cleanUpUpgradeExternalLinks"/>
15+
<CheckBox fx:id="cleanUpMovePDF"/>
16+
<CheckBox fx:id="cleanUpMakePathsRelative" text="%Make paths of linked files relative (if possible)"/>
17+
<CheckBox fx:id="cleanUpRenamePDF" text="%Rename PDFs to given filename format pattern"/>
18+
<VBox spacing="5.0">
19+
<Label fx:id="cleanupRenamePDFLabel"/>
20+
<CheckBox fx:id="cleanUpRenamePDFonlyRelativePaths" text="%Rename only PDFs having a relative path"/>
21+
<VBox.margin>
22+
<Insets left="40.0"/>
23+
</VBox.margin>
24+
</VBox>
25+
26+
<CheckBox fx:id="cleanUpBiblatex"
27+
text="%Convert to biblatex format (for example, move the value of the 'journal' field to 'journaltitle')"/>
28+
<CheckBox fx:id="cleanUpBibtex"
29+
text="%Convert to BibTeX format (for example, move the value of the 'journaltitle' field to 'journal')"/>
30+
31+
<VBox fx:id="formatterContainer"/>
32+
33+
</fx:root>

src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.java

+58-80
Original file line numberDiff line numberDiff line change
@@ -6,124 +6,103 @@
66
import java.util.Optional;
77
import java.util.Set;
88

9-
import javafx.scene.Group;
9+
import javafx.fxml.FXML;
1010
import javafx.scene.control.CheckBox;
1111
import javafx.scene.control.Label;
12-
import javafx.scene.control.ScrollPane;
13-
import javafx.scene.layout.GridPane;
12+
import javafx.scene.layout.VBox;
1413

15-
import org.jabref.Globals;
1614
import org.jabref.logic.cleanup.CleanupPreset;
1715
import org.jabref.logic.cleanup.Cleanups;
1816
import org.jabref.logic.l10n.Localization;
1917
import org.jabref.model.database.BibDatabaseContext;
2018
import org.jabref.model.entry.FieldName;
21-
import org.jabref.preferences.JabRefPreferences;
19+
import org.jabref.model.metadata.FilePreferences;
2220

23-
public class CleanupPresetPanel extends ScrollPane {
21+
import com.airhacks.afterburner.views.ViewLoader;
22+
23+
public class CleanupPresetPanel extends VBox {
2424

2525
private final BibDatabaseContext databaseContext;
26-
private CheckBox cleanUpDOI;
27-
private CheckBox cleanUpISSN;
28-
private CheckBox cleanUpMovePDF;
29-
private CheckBox cleanUpMakePathsRelative;
30-
private CheckBox cleanUpRenamePDF;
31-
private CheckBox cleanUpRenamePDFonlyRelativePaths;
32-
private CheckBox cleanUpUpgradeExternalLinks;
33-
private CheckBox cleanUpBiblatex;
34-
private CheckBox cleanUpBibtex;
26+
@FXML private Label cleanupRenamePDFLabel;
27+
@FXML private CheckBox cleanUpDOI;
28+
@FXML private CheckBox cleanUpEprint;
29+
@FXML private CheckBox cleanUpISSN;
30+
@FXML private CheckBox cleanUpMovePDF;
31+
@FXML private CheckBox cleanUpMakePathsRelative;
32+
@FXML private CheckBox cleanUpRenamePDF;
33+
@FXML private CheckBox cleanUpRenamePDFonlyRelativePaths;
34+
@FXML private CheckBox cleanUpUpgradeExternalLinks;
35+
@FXML private CheckBox cleanUpBiblatex;
36+
@FXML private CheckBox cleanUpBibtex;
37+
@FXML private VBox formatterContainer;
3538
private FieldFormatterCleanupsPanel cleanUpFormatters;
3639

37-
private CleanupPreset cleanupPreset;
38-
39-
public CleanupPresetPanel(BibDatabaseContext databaseContext, CleanupPreset cleanupPreset) {
40-
this.cleanupPreset = Objects.requireNonNull(cleanupPreset);
40+
public CleanupPresetPanel(BibDatabaseContext databaseContext, CleanupPreset cleanupPreset, FilePreferences filePreferences) {
4141
this.databaseContext = Objects.requireNonNull(databaseContext);
42-
init();
42+
43+
// Load FXML
44+
ViewLoader.view(this)
45+
.root(this)
46+
.load();
47+
48+
init(cleanupPreset, filePreferences);
4349
}
4450

45-
private void init() {
46-
cleanUpDOI = new CheckBox(
47-
Localization.lang("Move DOIs from note and URL field to DOI field and remove http prefix"));
48-
cleanUpISSN = new CheckBox(Localization.lang("Reformat ISSN"));
49-
Optional<Path> firstExistingDir = databaseContext
50-
.getFirstExistingFileDir(JabRefPreferences.getInstance().getFilePreferences());
51+
private void init(CleanupPreset cleanupPreset, FilePreferences filePreferences) {
52+
Optional<Path> firstExistingDir = databaseContext.getFirstExistingFileDir(filePreferences);
5153
if (firstExistingDir.isPresent()) {
52-
cleanUpMovePDF = new CheckBox(Localization.lang("Move linked files to default file directory %0",
53-
firstExistingDir.get().toString()));
54+
cleanUpMovePDF.setText(Localization.lang("Move linked files to default file directory %0", firstExistingDir.get().toString()));
5455
} else {
55-
cleanUpMovePDF = new CheckBox(Localization.lang("Move linked files to default file directory %0", "..."));
56-
cleanUpMovePDF.setDisable(true);
56+
cleanUpMovePDF.setText(Localization.lang("Move linked files to default file directory %0", "..."));
57+
5758
// Since the directory does not exist, we cannot move it to there. So, this option is not checked - regardless of the presets stored in the preferences.
59+
cleanUpMovePDF.setDisable(true);
5860
cleanUpMovePDF.setSelected(false);
5961
}
60-
cleanUpMakePathsRelative = new CheckBox(
61-
Localization.lang("Make paths of linked files relative (if possible)"));
62-
cleanUpRenamePDF = new CheckBox(Localization.lang("Rename PDFs to given filename format pattern"));
63-
cleanUpRenamePDF.selectedProperty().addListener(
64-
event -> cleanUpRenamePDFonlyRelativePaths.setDisable(!cleanUpRenamePDF.isSelected()));
65-
cleanUpRenamePDFonlyRelativePaths = new CheckBox(Localization.lang("Rename only PDFs having a relative path"));
66-
cleanUpUpgradeExternalLinks = new CheckBox(
67-
Localization.lang("Upgrade external PDF/PS links to use the '%0' field.", FieldName.FILE));
68-
cleanUpBiblatex = new CheckBox(Localization.lang(
69-
"Convert to biblatex format (for example, move the value of the 'journal' field to 'journaltitle')"));
70-
cleanUpBibtex = new CheckBox(Localization.lang(
71-
"Convert to BibTeX format (for example, move the value of the 'journaltitle' field to 'journal')"));
72-
Group biblatexConversion = new Group(); // Only make "to Biblatex" or "to BibTeX" selectable
73-
biblatexConversion.getChildren().add(cleanUpBiblatex);
74-
biblatexConversion.getChildren().add(cleanUpBibtex);
75-
76-
cleanUpFormatters = new FieldFormatterCleanupsPanel(Localization.lang("Run field formatter:"),
77-
Cleanups.DEFAULT_SAVE_ACTIONS);
7862

79-
updateDisplay(cleanupPreset);
63+
cleanUpRenamePDFonlyRelativePaths.disableProperty().bind(cleanUpRenamePDF.selectedProperty().not());
8064

81-
GridPane container = new GridPane();
82-
container.add(cleanUpDOI, 0, 0);
83-
container.add(cleanUpUpgradeExternalLinks, 0, 1);
84-
container.add(cleanUpMovePDF, 0, 2);
85-
container.add(cleanUpMakePathsRelative, 0, 3);
86-
container.add(cleanUpRenamePDF, 0, 4);
87-
String currentPattern = Localization.lang("Filename format pattern").concat(": ");
88-
currentPattern = currentPattern.concat(Globals.prefs.get(JabRefPreferences.IMPORT_FILENAMEPATTERN));
89-
container.add(new Label(currentPattern), 0, 5);
90-
container.add(cleanUpRenamePDFonlyRelativePaths, 0, 6);
91-
container.add(cleanUpBibtex, 0, 7);
92-
container.add(cleanUpBiblatex, 0, 8);
93-
container.add(cleanUpISSN, 0, 9);
94-
container.add(cleanUpFormatters, 0, 10);
95-
96-
setContent(container);
97-
setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
65+
cleanUpUpgradeExternalLinks.setText(Localization.lang("Upgrade external PDF/PS links to use the '%0' field.", FieldName.FILE));
66+
67+
cleanUpFormatters = new FieldFormatterCleanupsPanel(Localization.lang("Run field formatter:"), Cleanups.DEFAULT_SAVE_ACTIONS);
68+
formatterContainer.getChildren().setAll(cleanUpFormatters);
69+
70+
String currentPattern = Localization.lang("Filename format pattern")
71+
.concat(": ")
72+
.concat(filePreferences.getFileNamePattern());
73+
cleanupRenamePDFLabel.setText(currentPattern);
74+
75+
updateDisplay(cleanupPreset);
9876
}
9977

10078
private void updateDisplay(CleanupPreset preset) {
101-
cleanUpDOI.setSelected(preset.isCleanUpDOI());
79+
cleanUpDOI.setSelected(preset.isActive(CleanupPreset.CleanupStep.CLEAN_UP_DOI));
80+
cleanUpEprint.setSelected(preset.isActive(CleanupPreset.CleanupStep.CLEANUP_EPRINT));
10281
if (!cleanUpMovePDF.isDisabled()) {
103-
cleanUpMovePDF.setSelected(preset.isMovePDF());
82+
cleanUpMovePDF.setSelected(preset.isActive(CleanupPreset.CleanupStep.MOVE_PDF));
10483
}
105-
cleanUpMakePathsRelative.setSelected(preset.isMakePathsRelative());
106-
cleanUpRenamePDF.setSelected(preset.isRenamePDF());
107-
cleanUpRenamePDFonlyRelativePaths.setSelected(preset.isRenamePdfOnlyRelativePaths());
108-
cleanUpRenamePDFonlyRelativePaths.setDisable(!cleanUpRenamePDF.isSelected());
109-
cleanUpUpgradeExternalLinks.setSelected(preset.isCleanUpUpgradeExternalLinks());
110-
cleanUpBiblatex.setSelected(preset.isConvertToBiblatex());
111-
cleanUpBibtex.setSelected(preset.isConvertToBibtex());
112-
cleanUpISSN.setSelected(preset.isCleanUpISSN());
84+
cleanUpMakePathsRelative.setSelected(preset.isActive(CleanupPreset.CleanupStep.MAKE_PATHS_RELATIVE));
85+
cleanUpRenamePDF.setSelected(preset.isRenamePDFActive());
86+
cleanUpRenamePDFonlyRelativePaths.setSelected(preset.isActive(CleanupPreset.CleanupStep.RENAME_PDF_ONLY_RELATIVE_PATHS));
87+
cleanUpUpgradeExternalLinks.setSelected(preset.isActive(CleanupPreset.CleanupStep.CLEAN_UP_UPGRADE_EXTERNAL_LINKS));
88+
cleanUpBiblatex.setSelected(preset.isActive(CleanupPreset.CleanupStep.CONVERT_TO_BIBLATEX));
89+
cleanUpBibtex.setSelected(preset.isActive(CleanupPreset.CleanupStep.CONVERT_TO_BIBTEX));
90+
cleanUpISSN.setSelected(preset.isActive(CleanupPreset.CleanupStep.CLEAN_UP_ISSN));
11391
cleanUpFormatters.setValues(preset.getFormatterCleanups());
11492
}
11593

11694
public CleanupPreset getCleanupPreset() {
117-
11895
Set<CleanupPreset.CleanupStep> activeJobs = EnumSet.noneOf(CleanupPreset.CleanupStep.class);
11996

12097
if (cleanUpMovePDF.isSelected()) {
12198
activeJobs.add(CleanupPreset.CleanupStep.MOVE_PDF);
12299
}
123-
124100
if (cleanUpDOI.isSelected()) {
125101
activeJobs.add(CleanupPreset.CleanupStep.CLEAN_UP_DOI);
126102
}
103+
if (cleanUpEprint.isSelected()) {
104+
activeJobs.add(CleanupPreset.CleanupStep.CLEANUP_EPRINT);
105+
}
127106
if (cleanUpISSN.isSelected()) {
128107
activeJobs.add(CleanupPreset.CleanupStep.CLEAN_UP_ISSN);
129108
}
@@ -149,7 +128,6 @@ public CleanupPreset getCleanupPreset() {
149128

150129
activeJobs.add(CleanupPreset.CleanupStep.FIX_FILE_LINKS);
151130

152-
cleanupPreset = new CleanupPreset(activeJobs, cleanUpFormatters.getFormatterCleanups());
153-
return cleanupPreset;
131+
return new CleanupPreset(activeJobs, cleanUpFormatters.getFormatterCleanups());
154132
}
155133
}

src/main/java/org/jabref/gui/cleanup/FieldFormatterCleanupsPanel.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private void buildLayout() {
103103
actionsList = new ListView<>(actions);
104104
actionsList.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
105105
new ViewModelListCellFactory<FieldFormatterCleanup>()
106-
.withText(action -> action.getFormatter().getName())
106+
.withText(action -> action.getField() + ": " + action.getFormatter().getName())
107107
.withTooltip(action -> action.getFormatter().getDescription())
108108
.install(actionsList);
109109
add(actionsList, 1, 1, 3, 1);

0 commit comments

Comments
 (0)