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

Disable Write XMP Button in General tab of Entry-Editor when action is in progress #8728

Merged
merged 11 commits into from
May 30, 2022
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue where no citationkey was generated on import, pasting a doi or an entry on the main table. [8406](https://github.com/JabRef/jabref/issues/8406), [koppor#553](https://github.com/koppor/jabref/issues/553)
- We fixed an issue where accent search does not perform consistently. [#6815](https://github.com/JabRef/jabref/issues/6815)
- We fixed an issue where the incorrect entry was selected when "New Article" is pressed while search filters are active. [#8674](https://github.com/JabRef/jabref/issues/8674)
- We fixed an issue where "Write BibTeXEntry metadata to PDF" button remains enabled while writing to PDF is in-progress. [#8691](https://github.com/JabRef/jabref/issues/8691)

### Removed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ public void edit() {
});
}

public void writeMetadataToPdf() {
public void writeMetadataToPdf(Runnable preWrite, Runnable postWrite) {
BackgroundTask<Void> writeTask = BackgroundTask.wrap(() -> {
Optional<Path> file = linkedFile.findIn(databaseContext, preferences.getFilePreferences());
if (file.isEmpty()) {
Expand All @@ -440,7 +440,9 @@ public void writeMetadataToPdf() {
}
return null;
});

writeTask
.onRunning(preWrite)
.onFinished(postWrite);
taskExecutor.execute(writeTask);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;
import java.util.Optional;

import javafx.application.Platform;
import javafx.beans.binding.Bindings;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.ObservableList;
Expand Down Expand Up @@ -180,8 +181,10 @@ private Node createFileDisplay(LinkedFileViewModel linkedFile) {
Button writeMetadataToPdf = IconTheme.JabRefIcons.IMPORT.asButton();
writeMetadataToPdf.setTooltip(new Tooltip(Localization.lang("Write BibTeXEntry metadata to PDF.")));
writeMetadataToPdf.visibleProperty().bind(linkedFile.isOfflinePdfProperty());
writeMetadataToPdf.setOnAction(event -> linkedFile.writeMetadataToPdf());
writeMetadataToPdf.getStyleClass().setAll("icon-button");
Runnable disableButtonBeforeWriteStarts = () -> Platform.runLater(() -> writeMetadataToPdf.setDisable(true));
Runnable enableButtonAfterWriteCompletes = () -> Platform.runLater(() -> writeMetadataToPdf.setDisable(false));
writeMetadataToPdf.setOnAction(event -> linkedFile.writeMetadataToPdf(disableButtonBeforeWriteStarts, enableButtonAfterWriteCompletes));

Button parsePdfMetadata = IconTheme.JabRefIcons.FILE_SEARCH.asButton();
parsePdfMetadata.setTooltip(new Tooltip(Localization.lang("Parse Metadata from PDF.")));
Expand Down