Skip to content

Commit

Permalink
Fix EntryType dialog not closed after generate button (#4390)
Browse files Browse the repository at this point in the history
* Fix EntryType dialog not closed after generate button

When generating an entry from an DOI or similar, the entry was inserted, but the dialog not closed.

* remove obsolete comment

* fix checkstyle
  • Loading branch information
Siedlerchr authored Oct 22, 2018
1 parent 44f7121 commit b9f9720
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/main/java/org/jabref/gui/EntryTypeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ public EntryTypeView(BasePanel basePanel, DialogService dialogService, JabRefPre

btnGenerate.textProperty().bind(EasyBind.map(viewModel.searchingProperty(), searching -> (searching) ? Localization.lang("Searching...") : Localization.lang("Generate")));
btnGenerate.disableProperty().bind(viewModel.searchingProperty());

EasyBind.subscribe(viewModel.searchSuccesfulProperty(), value -> {
if (value) {
setEntryTypeForReturnAndClose(null);
}
});

}

private void addEntriesToPane(FlowPane pane, Collection<? extends EntryType> entries) {
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/org/jabref/gui/EntryTypeViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class EntryTypeViewModel {

private final JabRefPreferences prefs;
private final BooleanProperty searchingProperty = new SimpleBooleanProperty();
private final BooleanProperty searchSuccesfulProperty = new SimpleBooleanProperty();
private final ObjectProperty<IdBasedFetcher> selectedItemProperty = new SimpleObjectProperty<>();
private final ListProperty<IdBasedFetcher> fetchers = new SimpleListProperty<>(FXCollections.observableArrayList());
private final StringProperty idText = new SimpleStringProperty();
Expand All @@ -53,6 +54,10 @@ public EntryTypeViewModel(JabRefPreferences preferences, BasePanel basePanel, Di

}

public BooleanProperty searchSuccesfulProperty() {
return searchSuccesfulProperty;
}

public BooleanProperty searchingProperty() {
return searchingProperty;
}
Expand Down Expand Up @@ -110,6 +115,7 @@ protected Optional<BibEntry> call() throws InterruptedException, FetcherExceptio
}

public void runFetcherWorker() {
searchSuccesfulProperty.set(false);
fetcherWorker.run();
fetcherWorker.setOnFailed(event -> {
Throwable exception = fetcherWorker.getException();
Expand All @@ -124,7 +130,9 @@ public void runFetcherWorker() {
LOGGER.error(String.format("Exception during fetching when using fetcher '%s' with entry id '%s'.", searchId, fetcher), exception);

searchingProperty.set(false);

fetcherWorker = new FetcherWorker();

});

fetcherWorker.setOnSucceeded(evt -> {
Expand All @@ -143,8 +151,8 @@ public void runFetcherWorker() {
new BibtexKeyGenerator(basePanel.getBibDatabaseContext(), prefs.getBibtexKeyPatternPreferences()).generateAndSetKey(bibEntry);
basePanel.insertEntry(bibEntry);
}
searchSuccesfulProperty.set(true);

// close();
} else if (StringUtil.isBlank(idText.getValue())) {
dialogService.showWarningDialogAndWait(Localization.lang("Empty search ID"), Localization.lang("The given search ID was empty."));
}
Expand Down

0 comments on commit b9f9720

Please sign in to comment.