Skip to content

Commit

Permalink
feature JabRef#3607 final version
Browse files Browse the repository at this point in the history
- auto removed
- link button moved to the left
- lowered opacity for automatically found files, unchanged for added
  • Loading branch information
LukasGutenberg committed Mar 8, 2021
1 parent 41c825f commit 6f9f5cb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class LinkedFileViewModel extends AbstractViewModel {
private final XmpPreferences xmpPreferences;
private final LinkedFileHandler linkedFileHandler;
private final ExternalFileTypes externalFileTypes;
private final DoubleProperty opacityProperty = new SimpleDoubleProperty(1.0);

private final Validator fileExistsValidator;

Expand Down Expand Up @@ -508,4 +509,12 @@ public LinkedFile getFile() {
public ValidationStatus fileExistsValidationStatus() {
return fileExistsValidator.getValidationStatus();
}

public DoubleProperty opacityProperty() {
return opacityProperty;
}

public void setOpacityProperty(double v) {
opacityProperty.setValue(v);
}
}
17 changes: 8 additions & 9 deletions src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ private static Node createFileDisplay(LinkedFileViewModel linkedFile) {
Node icon = linkedFile.getTypeIcon().getGraphicNode();
icon.setOnMouseClicked(event -> linkedFile.open());
Text link = new Text();
link.opacityProperty().bind(linkedFile.opacityProperty());
link.textProperty().bind(linkedFile.linkProperty());
link.getStyleClass().setAll("file-row-text");
Text desc = new Text();
Expand All @@ -150,20 +151,18 @@ private static Node createFileDisplay(LinkedFileViewModel linkedFile) {
progressIndicator.progressProperty().bind(linkedFile.downloadProgressProperty());
progressIndicator.visibleProperty().bind(linkedFile.downloadOngoingProperty());

Text auto = new Text();
auto.visibleProperty().bind(linkedFile.isAutomaticallyFoundProperty());
auto.managedProperty().bind(linkedFile.isAutomaticallyFoundProperty());
auto.setText(Localization.lang("(Auto)"));
auto.getStyleClass().setAll("file-row-text");

HBox info = new HBox(8);
info.setStyle("-fx-padding: 0.5em 0 0.5em 0;"); // To align with buttons below which also have 0.5em padding
info.getChildren().setAll(icon, auto, link, desc, progressIndicator);
info.getChildren().setAll(icon, link, desc, progressIndicator);

Button acceptAutoLinkedFile = IconTheme.JabRefIcons.AUTO_LINKED_FILE.asButton();
acceptAutoLinkedFile.setTooltip(new Tooltip(Localization.lang("This file was found automatically. Do you want to link it to this entry?")));
acceptAutoLinkedFile.visibleProperty().bind(linkedFile.isAutomaticallyFoundProperty());
acceptAutoLinkedFile.setOnAction(event -> linkedFile.acceptAsLinked());
acceptAutoLinkedFile.managedProperty().bind(linkedFile.isAutomaticallyFoundProperty());
acceptAutoLinkedFile.setOnAction(event -> {
linkedFile.acceptAsLinked();
linkedFile.setOpacityProperty(1.0);
});
acceptAutoLinkedFile.getStyleClass().setAll("icon-button");

Button writeXMPMetadata = IconTheme.JabRefIcons.IMPORT.asButton();
Expand All @@ -175,7 +174,7 @@ private static Node createFileDisplay(LinkedFileViewModel linkedFile) {
HBox container = new HBox(10);
container.setPrefHeight(Double.NEGATIVE_INFINITY);

container.getChildren().addAll(info, acceptAutoLinkedFile, writeXMPMetadata);
container.getChildren().addAll(acceptAutoLinkedFile, info, writeXMPMetadata);

return container;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ private List<LinkedFileViewModel> findAssociatedNotLinkedFiles(BibEntry entry) {
preferences.getFilePreferences(),
externalFileTypes);
newLinkedFile.markAsAutomaticallyFound();
newLinkedFile.setOpacityProperty(0.3);
result.add(newLinkedFile);
}
} catch (IOException e) {
Expand Down

0 comments on commit 6f9f5cb

Please sign in to comment.