Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nullpointer on import #5448

Merged
merged 3 commits into from
Oct 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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