Skip to content

Commit

Permalink
Fix nullpointer on import (#5448)
Browse files Browse the repository at this point in the history
* Enable action "Import into current library" only if an open library exists #5447

* Add CHANGELOG entry #5447

* Fix checkstyle issue
  • Loading branch information
b0n541 authored and tobiasdiez committed Oct 15, 2019
1 parent d2ddff5 commit 3bad538
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed a problem where the "editor" information has been duplicated during saving a .bib-Database. [#5359](https://github.com/JabRef/jabref/issues/5359)
- We re-introduced the feature to switch between different preview styles. [#5221](https://github.com/JabRef/jabref/issues/5221)
- We fixed various issues (including [#5263](https://github.com/JabRef/jabref/issues/5263)) related to copying entries to the clipboard

- We fixed an exception which occurred when trying to import entries without an open library. [#5447](https://github.com/JabRef/jabref/issues/5447)



Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,8 @@ private MenuBar createMenu() {

factory.createSubMenu(StandardActions.IMPORT,
factory.createMenuItem(StandardActions.MERGE_DATABASE, new OldDatabaseCommandWrapper(Actions.MERGE_DATABASE, this, stateManager)), // TODO: merge with import
factory.createMenuItem(StandardActions.IMPORT_INTO_CURRENT_LIBRARY, new ImportCommand(this, false)),
factory.createMenuItem(StandardActions.IMPORT_INTO_NEW_LIBRARY, new ImportCommand(this, true))),
factory.createMenuItem(StandardActions.IMPORT_INTO_CURRENT_LIBRARY, new ImportCommand(this, false, stateManager)),
factory.createMenuItem(StandardActions.IMPORT_INTO_NEW_LIBRARY, new ImportCommand(this, true, stateManager))),

factory.createSubMenu(StandardActions.EXPORT,
factory.createMenuItem(StandardActions.EXPORT_ALL, new ExportCommand(this, false, Globals.prefs)),
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/org/jabref/gui/importer/ImportCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
import org.jabref.Globals;
import org.jabref.gui.DialogService;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.SimpleCommand;
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.gui.util.FileFilterConverter;
import org.jabref.logic.importer.Importer;
import org.jabref.logic.l10n.Localization;
import org.jabref.preferences.JabRefPreferences;

import static org.jabref.gui.actions.ActionHelper.needsDatabase;

/**
* Perform import operation
*/
Expand All @@ -30,9 +33,14 @@ public class ImportCommand extends SimpleCommand {
/**
* @param openInNew Indicate whether the entries should import into a new database or into the currently open one.
*/
public ImportCommand(JabRefFrame frame, boolean openInNew) {
public ImportCommand(JabRefFrame frame, boolean openInNew, StateManager stateManager) {
this.frame = frame;
this.openInNew = openInNew;

if (!openInNew) {
this.executable.bind(needsDatabase(stateManager));
}

this.dialogService = frame.getDialogService();
}

Expand Down

0 comments on commit 3bad538

Please sign in to comment.