Skip to content

Commit

Permalink
Fixed missing trigger for linked file operations (JabRef#7548)
Browse files Browse the repository at this point in the history
* Fixed missing trigger

* CHANGELOG.md

* Extracted StateManager
  • Loading branch information
calixtus authored Mar 18, 2021
1 parent 753d1ee commit 303018f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue where the password for a shared SQL database was only remembered if it was the same as the username [#6869](https://github.com/JabRef/jabref/issues/6869)
- We fixed an issue where some custom exports did not use the new authors formatter and therefore did not export authors correctly [#7356](https://github.com/JabRef/jabref/issues/7356)
- We fixed an issue where alt+keyboard shortcuts do not work [#6994](https://github.com/JabRef/jabref/issues/6994)
- We fixed an issue about the file link editor did not allow to change the file name according to the default pattern after changing an entry. [#7525](https://github.com/JabRef/jabref/issues/7525)
- We fixed an issue where the file path is invisible in dark theme. [#7382](https://github.com/JabRef/jabref/issues/7382)
- We fixed an issue where the secondary sorting is not working for some special fields. [#7015](https://github.com/JabRef/jabref/issues/7015)
- We fixed an issue where changing the font size makes the font size field too small. [#7085](https://github.com/JabRef/jabref/issues/7085)
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Optional;

import javafx.beans.binding.Bindings;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.ObservableList;
import javafx.css.PseudoClass;
import javafx.fxml.FXML;
Expand Down Expand Up @@ -48,6 +49,7 @@

import com.airhacks.afterburner.views.ViewLoader;
import com.tobiasdiez.easybind.EasyBind;
import com.tobiasdiez.easybind.optional.ObservableOptionalValue;

public class LinkedFilesEditor extends HBox implements FieldEditorFX {

Expand All @@ -59,6 +61,8 @@ public class LinkedFilesEditor extends HBox implements FieldEditorFX {
private final UiThreadObservableList<LinkedFileViewModel> decoratedModelList;
private final PreferencesService preferencesService;

private ObservableOptionalValue<BibEntry> bibEntry = EasyBind.wrapNullable(new SimpleObjectProperty<>());

public LinkedFilesEditor(Field field,
DialogService dialogService,
BibDatabaseContext databaseContext,
Expand Down Expand Up @@ -207,6 +211,7 @@ public LinkedFilesEditorViewModel getViewModel() {

@Override
public void bindToEntry(BibEntry entry) {
bibEntry = EasyBind.wrapNullable(new SimpleObjectProperty<>(entry));
viewModel.bindToEntry(entry);
}

Expand Down Expand Up @@ -281,19 +286,19 @@ public ContextAction(StandardActions command, LinkedFileViewModel linkedFile, Pr
() -> !linkedFile.getFile().isOnlineLink()
&& linkedFile.getFile().findIn(databaseContext, preferencesService.getFilePreferences()).isPresent()
&& !linkedFile.isGeneratedNameSameAsOriginal(),
linkedFile.getFile().linkProperty());
linkedFile.getFile().linkProperty(), bibEntry.getValue().map(BibEntry::getFieldsObservable).orElse(null));
case MOVE_FILE_TO_FOLDER -> Bindings.createBooleanBinding(
() -> !linkedFile.getFile().isOnlineLink()
&& linkedFile.getFile().findIn(databaseContext, preferencesService.getFilePreferences()).isPresent()
&& !linkedFile.isGeneratedPathSameAsOriginal(),
linkedFile.getFile().linkProperty());
linkedFile.getFile().linkProperty(), bibEntry.getValue().map(BibEntry::getFieldsObservable).orElse(null));
case DOWNLOAD_FILE -> Bindings.createBooleanBinding(
() -> linkedFile.getFile().isOnlineLink(),
linkedFile.getFile().linkProperty());
linkedFile.getFile().linkProperty(), bibEntry.getValue().map(BibEntry::getFieldsObservable).orElse(null));
case OPEN_FILE, OPEN_FOLDER, RENAME_FILE_TO_NAME, DELETE_FILE -> Bindings.createBooleanBinding(
() -> !linkedFile.getFile().isOnlineLink()
&& linkedFile.getFile().findIn(databaseContext, preferencesService.getFilePreferences()).isPresent(),
linkedFile.getFile().linkProperty());
linkedFile.getFile().linkProperty(), bibEntry.getValue().map(BibEntry::getFieldsObservable).orElse(null));
default -> BindingsHelper.constantOf(true);
});
}
Expand Down

0 comments on commit 303018f

Please sign in to comment.