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 Issue Unable to remove multiline property from field #12040

Closed
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We fixed an issue where <kbd>Tab</kbd> cannot be used to jump to next field in some single-line fields. [#11785](https://github.com/JabRef/jabref/issues/11785)
- We fixed an issue where it was not possible to select selecting content of other user's comments.[#11106](https://github.com/JabRef/jabref/issues/11106)
- We fixed an issue where web search preferences "Custom API key" table modifications not discarded. [#11925](https://github.com/JabRef/jabref/issues/11925)
- We fixed an issue where multiline property from field was unable to be removed after adding it. [#11897](https://github.com/JabRef/jabref/issues/11897)

### Removed

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jabref.gui.preferences.customentrytypes;

import javafx.application.Platform;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ReadOnlyStringWrapper;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
Expand Down Expand Up @@ -176,7 +177,7 @@ private void setupFieldsTable() {
makeRotatedColumnHeader(fieldTypeColumn, Localization.lang("Required"));

fieldTypeMultilineColumn.setCellFactory(CheckBoxTableCell.forTableColumn(fieldTypeMultilineColumn));
fieldTypeMultilineColumn.setCellValueFactory(item -> item.getValue().multilineProperty());
fieldTypeMultilineColumn.setCellValueFactory(this::createMultilinePropertyListener);
PressJump marked this conversation as resolved.
Show resolved Hide resolved
makeRotatedColumnHeader(fieldTypeMultilineColumn, Localization.lang("Multiline"));

fieldTypeActionColumn.setSortable(false);
Expand Down Expand Up @@ -206,6 +207,18 @@ private void setupFieldsTable() {
EasyBind.subscribe(addNewField.getEditor().textProperty(), text -> addNewField.setValue(FieldsUtil.FIELD_STRING_CONVERTER.fromString(text)));
}

private BooleanProperty createMultilinePropertyListener(TableColumn.CellDataFeatures<FieldViewModel, Boolean> item) {
BooleanProperty property = item.getValue().multilineProperty();
property.addListener((obs, wasSelected, isSelected) -> {
viewModel.entryTypes().forEach(typeViewModel -> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add doc that all types need to be changed as the standard fields are global for each entry type.

typeViewModel.fields().stream()
.filter(field -> field.displayNameProperty().get().equals(item.getValue().displayNameProperty().get()))
.forEach(field -> field.multilineProperty().set(isSelected));
});
});
return property;
}

private void makeRotatedColumnHeader(TableColumn<?, ?> column, String text) {
Label label = new Label();
label.setText(text);
Expand Down
Loading