Skip to content

Commit b9f9720

Browse files
authored
Fix EntryType dialog not closed after generate button (#4390)
* 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
1 parent 44f7121 commit b9f9720

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/main/java/org/jabref/gui/EntryTypeView.java

+7
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ public EntryTypeView(BasePanel basePanel, DialogService dialogService, JabRefPre
7474

7575
btnGenerate.textProperty().bind(EasyBind.map(viewModel.searchingProperty(), searching -> (searching) ? Localization.lang("Searching...") : Localization.lang("Generate")));
7676
btnGenerate.disableProperty().bind(viewModel.searchingProperty());
77+
78+
EasyBind.subscribe(viewModel.searchSuccesfulProperty(), value -> {
79+
if (value) {
80+
setEntryTypeForReturnAndClose(null);
81+
}
82+
});
83+
7784
}
7885

7986
private void addEntriesToPane(FlowPane pane, Collection<? extends EntryType> entries) {

src/main/java/org/jabref/gui/EntryTypeViewModel.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class EntryTypeViewModel {
3636

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

5455
}
5556

57+
public BooleanProperty searchSuccesfulProperty() {
58+
return searchSuccesfulProperty;
59+
}
60+
5661
public BooleanProperty searchingProperty() {
5762
return searchingProperty;
5863
}
@@ -110,6 +115,7 @@ protected Optional<BibEntry> call() throws InterruptedException, FetcherExceptio
110115
}
111116

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

126132
searchingProperty.set(false);
133+
127134
fetcherWorker = new FetcherWorker();
135+
128136
});
129137

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

147-
// close();
148156
} else if (StringUtil.isBlank(idText.getValue())) {
149157
dialogService.showWarningDialogAndWait(Localization.lang("Empty search ID"), Localization.lang("The given search ID was empty."));
150158
}

0 commit comments

Comments
 (0)