Skip to content

Commit

Permalink
Remove Globals at SaveDatabaseAction
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor committed Aug 25, 2019
1 parent 012d9b0 commit 7f970bc
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public void output(String s) {
}

private void setupActions() {
SaveDatabaseAction saveAction = new SaveDatabaseAction(this, Globals.prefs);
SaveDatabaseAction saveAction = new SaveDatabaseAction(this, Globals.prefs, Globals.entryTypesManager);
CleanupAction cleanUpAction = new CleanupAction(this, Globals.prefs, Globals.TASK_EXECUTOR);

actions.put(Actions.UNDO, undoAction);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ private boolean confirmClose(BasePanel panel) {
if (response.isPresent() && response.get().equals(saveChanges)) {
// The user wants to save.
try {
SaveDatabaseAction saveAction = new SaveDatabaseAction(panel, Globals.prefs);
SaveDatabaseAction saveAction = new SaveDatabaseAction(panel, Globals.prefs, Globals.entryTypesManager);
if (saveAction.save()) {
// Saved, now exit.
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public AutosaveUIManager(BasePanel panel) {
@Subscribe
public void listen(@SuppressWarnings("unused") AutosaveEvent event) {
try {
new SaveDatabaseAction(panel, Globals.prefs).save();
new SaveDatabaseAction(panel, Globals.prefs, Globals.entryTypesManager).save();
} catch (Throwable e) {
LOGGER.error("Problem occured while saving.", e);
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;

import org.jabref.Globals;
import org.jabref.gui.BasePanel;
import org.jabref.gui.DialogService;
import org.jabref.gui.JabRefFrame;
Expand Down Expand Up @@ -56,12 +55,12 @@ public class SaveDatabaseAction {
private final JabRefPreferences prefs;
private final BibEntryTypesManager entryTypesManager;

public SaveDatabaseAction(BasePanel panel, JabRefPreferences prefs) {
public SaveDatabaseAction(BasePanel panel, JabRefPreferences prefs, BibEntryTypesManager entryTypesManager) {
this.panel = panel;
this.frame = panel.frame();
this.dialogService = frame.getDialogService();
this.prefs = prefs;
entryTypesManager = Globals.entryTypesManager;
this.entryTypesManager = entryTypesManager;
}

private boolean saveDatabase(Path file, boolean selectedOnly, Charset encoding, SavePreferences.DatabaseSaveType saveType) throws SaveException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private boolean openSharedDatabase(DBMSConnectionProperties connectionProperties

if (!folder.getValue().isEmpty()) {
try {
new SaveDatabaseAction(panel, Globals.prefs).saveAs(Paths.get(folder.getValue()));
new SaveDatabaseAction(panel, Globals.prefs, Globals.entryTypesManager).saveAs(Paths.get(folder.getValue()));
} catch (Throwable e) {
LOGGER.error("Error while saving the database", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.database.shared.DatabaseLocation;
import org.jabref.model.entry.BibEntryTypesManager;
import org.jabref.preferences.JabRefPreferences;

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

saveDatabaseAction = spy(new SaveDatabaseAction(basePanel, preferences));
saveDatabaseAction = spy(new SaveDatabaseAction(basePanel, preferences, mock(BibEntryTypesManager.class)));
}

@Test
Expand Down

0 comments on commit 7f970bc

Please sign in to comment.