Skip to content

Commit

Permalink
Added javadocs comments for JabRef#7870
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcstan committed Dec 11, 2021
1 parent d4dcc37 commit 11f3797
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/main/java/org/jabref/gui/EntryTypeViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,15 @@ public void runFetcherWorker() {
} else if (StringUtil.isBlank(idText.getValue())) {
dialogService.showWarningDialogAndWait(Localization.lang("Empty search ID"), Localization.lang("The given search ID was empty."));
} else if (result.isEmpty()) {
/**
* When the result return by the fetcher is empty, a dialog box with the following two options appear:
*(1)add entries manually
* (2) return to original dialog box
* @author Marcus Tan
* @since 2021-11-07
*/
String fetcher = selectedItemProperty().getValue().getName();
String searchId = idText.getValue();
// When DOI ID is not found, allow the user to either return to the dialog or
// add entry manually
boolean addEntryFlag = dialogService.showConfirmationDialogAndWait(Localization.lang("DOI not found"),
Localization.lang("Fetcher '%0' did not find an entry for id '%1'.", fetcher, searchId),
Localization.lang("Add entry manually"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public GenerateEntryFromIdAction(LibraryTab libraryTab, DialogService dialogServ
this.identifier = identifier;
this.taskExecutor = taskExecutor;
this.entryFromIdPopOver = entryFromIdPopOver;
/**
* stateManger injected for access by NewEntryAction
* @author Marcus Tan
* @since 2021-11-07
*/
this.stateManager = stateManager;
}

Expand All @@ -47,13 +52,18 @@ public void execute() {
backgroundTask.titleProperty().set(Localization.lang("Import by ID"));
backgroundTask.showToUser(true);
backgroundTask.onRunning(() -> dialogService.notify("%s".formatted(backgroundTask.messageProperty().get())));
/**
* Upon failure to import by ID, a dialog box with the following two options appear:
* (1)add entries manually
* (2) return to original dialog box
* @author Marcus Tan
* @since 2021-11-07
*/
backgroundTask.onFailure((e) -> {
// When unable to import by ID, present the user options to cancel or add entry manually
boolean addEntryFlag = dialogService.showConfirmationDialogAndWait(Localization.lang("Failed to import by ID"),
e.getMessage(),
Localization.lang("Add entry manually"));
if (addEntryFlag) {
// add entry manually
new NewEntryAction(libraryTab.frame(), StandardEntryType.Article, dialogService,
preferencesService, stateManager).execute();
}
Expand Down

0 comments on commit 11f3797

Please sign in to comment.