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 EntryType dialog not closed after generate button #4390

Merged
merged 4 commits into from
Oct 22, 2018
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
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);
Siedlerchr marked this conversation as resolved.
Show resolved Hide resolved

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