Skip to content

Commit

Permalink
More refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-kolb committed Mar 15, 2020
1 parent b364396 commit 3f9922e
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 166 deletions.
6 changes: 3 additions & 3 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
import org.jabref.gui.copyfiles.CopyFilesAction;
import org.jabref.gui.customentrytypes.CustomizeEntryAction;
import org.jabref.gui.customizefields.SetupGeneralFieldsAction;
import org.jabref.gui.dialogs.AutosaveUIManager;
import org.jabref.gui.dialogs.AutosaveUiManager;
import org.jabref.gui.documentviewer.ShowDocumentViewerAction;
import org.jabref.gui.duplicationFinder.DuplicateSearch;
import org.jabref.gui.edit.CopyMoreAction;
Expand Down Expand Up @@ -1018,7 +1018,7 @@ public void addTab(BasePanel basePanel, boolean raisePanel) {

if (readyForAutosave(context)) {
AutosaveManager autosaver = AutosaveManager.start(context);
autosaver.registerListener(new AutosaveUIManager(basePanel));
autosaver.registerListener(new AutosaveUiManager(basePanel));
}

BackupManager.start(context, Globals.entryTypesManager, prefs);
Expand Down Expand Up @@ -1137,7 +1137,7 @@ private boolean confirmClose(BasePanel panel) {
// The user wants to save.
try {
SaveDatabaseAction saveAction = new SaveDatabaseAction(panel, Globals.prefs, Globals.entryTypesManager);
if (saveAction.save(panel.getBibDatabaseContext())) {
if (saveAction.save()) {
return true;
}
// The action was either canceled or unsuccessful.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,22 @@
import org.slf4j.LoggerFactory;

/**
* This class has an abstract UI role as it listens for an {@link AutosaveEvent}
* and saves the bib file associated with the given {@link BasePanel}.
* This class has an abstract UI role as it listens for an {@link AutosaveEvent} and saves the bib file associated with
* the given {@link BasePanel}.
*/
public class AutosaveUIManager {
public class AutosaveUiManager {
private static final Logger LOGGER = LoggerFactory.getLogger(AutosaveUiManager.class);

private static final Logger LOGGER = LoggerFactory.getLogger(AutosaveUIManager.class);
private final BasePanel panel;


public AutosaveUIManager(BasePanel panel) {
public AutosaveUiManager(BasePanel panel) {
this.panel = panel;
}

@Subscribe
public void listen(@SuppressWarnings("unused") AutosaveEvent event) {
try {
new SaveDatabaseAction(panel, Globals.prefs, Globals.entryTypesManager).save(panel.getBibDatabaseContext(), SaveDatabaseAction.SaveDatabaseMode.SILENT);
new SaveDatabaseAction(panel, Globals.prefs, Globals.entryTypesManager).save(SaveDatabaseAction.SaveDatabaseMode.SILENT);
} catch (Throwable e) {
LOGGER.error("Problem occurred while saving.", e);
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/jabref/gui/exporter/SaveAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
public class SaveAction extends SimpleCommand {

public enum SaveMethod { SAVE, SAVE_AS, SAVE_SELECTED }
public enum SaveMethod {SAVE, SAVE_AS, SAVE_SELECTED}

private final SaveMethod saveMethod;
private final JabRefFrame frame;
Expand All @@ -20,7 +20,6 @@ public SaveAction(SaveMethod saveMethod, JabRefFrame frame, StateManager stateMa
this.saveMethod = saveMethod;
this.frame = frame;


if (saveMethod == SaveMethod.SAVE_SELECTED) {
this.executable.bind(ActionHelper.needsEntriesSelected(stateManager));
} else {
Expand All @@ -37,7 +36,7 @@ public void execute() {

switch (saveMethod) {
case SAVE:
saveDatabaseAction.save(frame.getCurrentBasePanel().getBibDatabaseContext());
saveDatabaseAction.save();
break;
case SAVE_AS:
saveDatabaseAction.saveAs();
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/jabref/gui/exporter/SaveAllAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public void execute() {

for (BasePanel panel : frame.getBasePanelList()) {
SaveDatabaseAction saveDatabaseAction = new SaveDatabaseAction(panel, Globals.prefs, Globals.entryTypesManager);
boolean saveResult = saveDatabaseAction.save(panel.getBibDatabaseContext());
boolean saveResult = saveDatabaseAction.save();
if (!saveResult) {
dialogService.notify(Localization.lang("Could not save file."));
}
dialogService.notify(Localization.lang("Could not save file."));
}
}

dialogService.notify(Localization.lang("Save all finished."));
Expand Down
Loading

0 comments on commit 3f9922e

Please sign in to comment.