Skip to content

Commit 7f970bc

Browse files
committed
Remove Globals at SaveDatabaseAction
1 parent 012d9b0 commit 7f970bc

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

Diff for: src/main/java/org/jabref/gui/BasePanel.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public void output(String s) {
240240
}
241241

242242
private void setupActions() {
243-
SaveDatabaseAction saveAction = new SaveDatabaseAction(this, Globals.prefs);
243+
SaveDatabaseAction saveAction = new SaveDatabaseAction(this, Globals.prefs, Globals.entryTypesManager);
244244
CleanupAction cleanUpAction = new CleanupAction(this, Globals.prefs, Globals.TASK_EXECUTOR);
245245

246246
actions.put(Actions.UNDO, undoAction);

Diff for: src/main/java/org/jabref/gui/JabRefFrame.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ private boolean confirmClose(BasePanel panel) {
11191119
if (response.isPresent() && response.get().equals(saveChanges)) {
11201120
// The user wants to save.
11211121
try {
1122-
SaveDatabaseAction saveAction = new SaveDatabaseAction(panel, Globals.prefs);
1122+
SaveDatabaseAction saveAction = new SaveDatabaseAction(panel, Globals.prefs, Globals.entryTypesManager);
11231123
if (saveAction.save()) {
11241124
// Saved, now exit.
11251125
return true;

Diff for: src/main/java/org/jabref/gui/dialogs/AutosaveUIManager.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public AutosaveUIManager(BasePanel panel) {
2626
@Subscribe
2727
public void listen(@SuppressWarnings("unused") AutosaveEvent event) {
2828
try {
29-
new SaveDatabaseAction(panel, Globals.prefs).save();
29+
new SaveDatabaseAction(panel, Globals.prefs, Globals.entryTypesManager).save();
3030
} catch (Throwable e) {
3131
LOGGER.error("Problem occured while saving.", e);
3232
}

Diff for: src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import javafx.scene.layout.VBox;
1515
import javafx.scene.text.Text;
1616

17-
import org.jabref.Globals;
1817
import org.jabref.gui.BasePanel;
1918
import org.jabref.gui.DialogService;
2019
import org.jabref.gui.JabRefFrame;
@@ -56,12 +55,12 @@ public class SaveDatabaseAction {
5655
private final JabRefPreferences prefs;
5756
private final BibEntryTypesManager entryTypesManager;
5857

59-
public SaveDatabaseAction(BasePanel panel, JabRefPreferences prefs) {
58+
public SaveDatabaseAction(BasePanel panel, JabRefPreferences prefs, BibEntryTypesManager entryTypesManager) {
6059
this.panel = panel;
6160
this.frame = panel.frame();
6261
this.dialogService = frame.getDialogService();
6362
this.prefs = prefs;
64-
entryTypesManager = Globals.entryTypesManager;
63+
this.entryTypesManager = entryTypesManager;
6564
}
6665

6766
private boolean saveDatabase(Path file, boolean selectedOnly, Charset encoding, SavePreferences.DatabaseSaveType saveType) throws SaveException {

Diff for: src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private boolean openSharedDatabase(DBMSConnectionProperties connectionProperties
164164

165165
if (!folder.getValue().isEmpty()) {
166166
try {
167-
new SaveDatabaseAction(panel, Globals.prefs).saveAs(Paths.get(folder.getValue()));
167+
new SaveDatabaseAction(panel, Globals.prefs, Globals.entryTypesManager).saveAs(Paths.get(folder.getValue()));
168168
} catch (Throwable e) {
169169
LOGGER.error("Error while saving the database", e);
170170
}

Diff for: src/test/java/org/jabref/gui/exporter/SaveDatabaseActionTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.jabref.gui.util.FileDialogConfiguration;
1111
import org.jabref.model.database.BibDatabaseContext;
1212
import org.jabref.model.database.shared.DatabaseLocation;
13+
import org.jabref.model.entry.BibEntryTypesManager;
1314
import org.jabref.preferences.JabRefPreferences;
1415

1516
import org.junit.jupiter.api.BeforeEach;
@@ -43,7 +44,7 @@ public void setUp() {
4344
when(basePanel.getBibDatabaseContext()).thenReturn(dbContext);
4445
when(jabRefFrame.getDialogService()).thenReturn(dialogService);
4546

46-
saveDatabaseAction = spy(new SaveDatabaseAction(basePanel, preferences));
47+
saveDatabaseAction = spy(new SaveDatabaseAction(basePanel, preferences, mock(BibEntryTypesManager.class)));
4748
}
4849

4950
@Test

0 commit comments

Comments
 (0)