Skip to content

Fixes problems with managing external file types (issue 5846) #5894

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

Merged
merged 3 commits into from
Feb 2, 2020
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
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ Stephen Beitzel
Stéphane Curet
Super-Tang
Sven Jäger
systemoperator
Thiago Toledo
Thomas Arildsen
Thomas Ilsche
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed an issue where an erroneous "The library has been modified by another program" message was shown when saving. [#4877](https://github.com/JabRef/jabref/issues/4877)
- We fixed an issue where the file extension was missing after downloading a file (we now fall-back to pdf). [#5816](https://github.com/JabRef/jabref/issues/5816)
- We fixed an issue where cleaning up entries broke web URLs, if "Make paths of linked files relative (if possible)" was enabled, which resulted in various other issues subsequently. [#5861](https://github.com/JabRef/jabref/issues/5861)
- We fixed several issues concerning managing external file types: Now everything is usable and fully functional. Previously, there were problems with the radio buttons, with saving the settings and with loading an input field value. Furthermore, different behavior for Windows and other operating systems was given, which was unified as well. [#5846](https://github.com/JabRef/jabref/issues/5846)

### Removed
- Ampersands are no longer escaped by default in the `bib` file. If you want to keep the current behaviour, you can use the new "Escape Ampersands" formatter as a save action.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ private void showEditDialog(ExternalFileType type, String dialogTitle) {
typeForEdit = (CustomExternalFileType) type;
} else {
typeForEdit = new CustomExternalFileType(type);
fileTypes.add(fileTypes.indexOf(type), typeForEdit);
fileTypes.remove(type);
}

EditExternalFileTypeEntryDialog dlg = new EditExternalFileTypeEntryDialog(typeForEdit, dialogTitle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public void initialize() {
icon.setGraphic(viewModel.getIcon());

defaultApplication.selectedProperty().bindBidirectional(viewModel.defaultApplicationSelectedProperty());
customApplication.selectedProperty().bindBidirectional(viewModel.customApplicationSelectedProperty());
selectedApplication.disableProperty().bind(viewModel.defaultApplicationSelectedProperty());
btnBrowse.disableProperty().bind(viewModel.defaultApplicationSelectedProperty());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,31 @@
import javafx.beans.property.StringProperty;
import javafx.scene.Node;

import org.jabref.logic.util.OS;

public class EditExternalFileTypeViewModel {

private final StringProperty extensionProperty = new SimpleStringProperty("");
private final StringProperty nameProperty = new SimpleStringProperty("");
private final StringProperty mimeTypeProperty = new SimpleStringProperty("");
private final StringProperty selectedApplicationProperty = new SimpleStringProperty("");
private final BooleanProperty defaultApplicationSelectedProperty = new SimpleBooleanProperty(false);
private final BooleanProperty customApplicationSelectedProperty = new SimpleBooleanProperty(false);
private final Node icon;
private final CustomExternalFileType fileType;

public EditExternalFileTypeViewModel(CustomExternalFileType fileType) {
this.fileType = fileType;
extensionProperty.setValue(fileType.getExtension());
nameProperty.setValue(fileType.getField().getDisplayName());
nameProperty.setValue(fileType.getName());
mimeTypeProperty.setValue(fileType.getMimeType());
selectedApplicationProperty.setValue(fileType.getOpenWithApplication());
icon = fileType.getIcon().getGraphicNode();

if (fileType.getOpenWithApplication().isEmpty()) {
defaultApplicationSelectedProperty.setValue(true);
}
else {
customApplicationSelectedProperty.setValue(true);
}

}

Expand All @@ -52,6 +54,10 @@ public BooleanProperty defaultApplicationSelectedProperty() {
return defaultApplicationSelectedProperty;
}

public BooleanProperty customApplicationSelectedProperty() {
return customApplicationSelectedProperty;
}

public Node getIcon() {
return icon;
}
Expand All @@ -69,20 +75,14 @@ public void storeSettings() {
}

String application = selectedApplicationProperty.getValue().trim();
if (OS.WINDOWS) {
// On Windows, store application as empty if the "Default" option is selected,
// or if the application name is empty:
if (defaultApplicationSelectedProperty.getValue() || application.isEmpty()) {
fileType.setOpenWith("");
selectedApplicationProperty.setValue("");

} else {
fileType.setOpenWith(application);
}

// store application as empty if the "Default" option is selected, or if the application name is empty:
if (defaultApplicationSelectedProperty.getValue() || application.isEmpty()) {
fileType.setOpenWith("");
selectedApplicationProperty.setValue("");
} else {
fileType.setOpenWith(application);
}

}

}