Skip to content

Commit

Permalink
fix checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
Siedlerchr committed Sep 26, 2020
1 parent 0aba233 commit 3ea16a6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,7 @@ public void addTab(BasePanel basePanel, boolean raisePanel) {
basePanel.getUndoManager().registerListener(new UndoRedoEventManager());

BibDatabaseContext context = basePanel.getBibDatabaseContext();
GlobalSaveManager manager = GlobalSaveManager.create(basePanel, prefs, Globals.entryTypesManager);

if (readyForAutosave(context)) {
AutosaveManager autosaver = AutosaveManager.start(context);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/gui/dialogs/AutosaveUiManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* the given {@link BasePanel}.
*/
public class AutosaveUiManager {

private static final Logger LOGGER = LoggerFactory.getLogger(AutosaveUiManager.class);

private final BasePanel panel;
Expand All @@ -25,7 +26,7 @@ public AutosaveUiManager(BasePanel panel) {
@Subscribe
public void listen(@SuppressWarnings("unused") AutosaveEvent event) {
try {
SaveDatabaseAction saveAction = new SaveDatabaseAction(panel, Globals.prefs, Globals.entryTypesManager);
SaveDatabaseAction saveAction = new SaveDatabaseAction(panel, Globals.prefs, Globals.entryTypesManager);
saveAction.save(SaveDatabaseAction.SaveDatabaseMode.SILENT);
} catch (Throwable e) {
LOGGER.error("Problem occurred while saving.", e);
Expand Down
15 changes: 6 additions & 9 deletions src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.nio.charset.Charset;
import java.nio.file.Path;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -51,7 +50,6 @@
public class SaveDatabaseAction {

private static final Logger LOGGER = LoggerFactory.getLogger(SaveDatabaseAction.class);
private static Set<SaveDatabaseAction> runningInstances = new HashSet<>();

private final BasePanel panel;
private final JabRefFrame frame;
Expand Down Expand Up @@ -218,8 +216,8 @@ private boolean save(Path targetPath, SaveDatabaseMode mode) {
}

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

GlobalSaveManager manager = GlobalSaveManager.create(panel, preferences, entryTypesManager);

SavePreferences preferences = this.preferences.getSavePreferences()
.withEncoding(encoding)
.withSaveType(saveType);
Expand All @@ -229,7 +227,7 @@ private boolean saveDatabase(Path file, boolean selectedOnly, Charset encoding,
var future = manager.save(file, selectedOnly, encoding, saveType, panel.getBibDatabaseContext(), consumer);
Set<Character> characters;
try {
characters =future.get();
characters = future.get();
if (!characters.isEmpty()) {
saveWithDifferentEncoding(file, selectedOnly, preferences.getEncoding(), characters, saveType);
}
Expand All @@ -242,7 +240,6 @@ private boolean saveDatabase(Path file, boolean selectedOnly, Charset encoding,

}


private void saveWithDifferentEncoding(Path file, boolean selectedOnly, Charset encoding, Set<Character> encodingProblems, SavePreferences.DatabaseSaveType saveType) throws SaveException {
DialogPane pane = new DialogPane();
VBox vbox = new VBox();
Expand Down Expand Up @@ -271,10 +268,10 @@ private void saveWithDifferentEncoding(Path file, boolean selectedOnly, Charset

private boolean readyForAutosave(BibDatabaseContext context) {
return ((context.getLocation() == DatabaseLocation.SHARED) ||
((context.getLocation() == DatabaseLocation.LOCAL)
&& preferences.getBoolean(JabRefPreferences.LOCAL_AUTO_SAVE)))
&&
context.getDatabasePath().isPresent();
((context.getLocation() == DatabaseLocation.LOCAL)
&& preferences.getBoolean(JabRefPreferences.LOCAL_AUTO_SAVE)))
&&
context.getDatabasePath().isPresent();
}

private boolean readyForBackup(BibDatabaseContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private void shutdown() {

}

public Future<Set<Character>> save(Path file, boolean selectedOnly, Charset encoding, SavePreferences.DatabaseSaveType saveType, BibDatabaseContext context, Consumer<List<FieldChange>> consumeFieldChanges) throws SaveException {
public Future<Set<Character>> save(Path file, boolean selectedOnly, Charset encoding, SavePreferences.DatabaseSaveType saveType, BibDatabaseContext context, Consumer<List<FieldChange>> consumeFieldChanges) {
return throttler.scheduleTask(() -> saveThrotteld(file, selectedOnly, encoding, saveType, context, consumeFieldChanges));
}

Expand Down

0 comments on commit 3ea16a6

Please sign in to comment.