Skip to content

Commit

Permalink
Merge pull request #5224 from davidemdot/fix-5220
Browse files Browse the repository at this point in the history
Fix exception when adding field formatter in 'Cleanup entries' dialog
  • Loading branch information
Siedlerchr authored Aug 24, 2019
2 parents 4656533 + a0af540 commit a76b8f3
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;

import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
Expand Down Expand Up @@ -40,18 +42,17 @@ public class FieldFormatterCleanupsPanel extends GridPane {

private static final String DESCRIPTION = Localization.lang("Description") + ": ";
private final CheckBox cleanupEnabled;
private final FieldFormatterCleanups defaultFormatters;
private final List<Formatter> availableFormatters;
private FieldFormatterCleanups fieldFormatterCleanups;
private ListView<FieldFormatterCleanup> actionsList;
private ComboBox<Formatter> formattersCombobox;
private ComboBox<Field> selectFieldCombobox;
private ComboBox<String> selectFieldCombobox;
private Button addButton;
private Label descriptionAreaText;
private Button removeButton;
private Button resetButton;
private Button recommendButton;

private final FieldFormatterCleanups defaultFormatters;
private final List<Formatter> availableFormatters;
private ObservableList<FieldFormatterCleanup> actions;

public FieldFormatterCleanupsPanel(String description, FieldFormatterCleanups defaultFormatters) {
Expand Down Expand Up @@ -104,7 +105,7 @@ private void buildLayout() {
actionsList = new ListView<>(actions);
actionsList.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
new ViewModelListCellFactory<FieldFormatterCleanup>()
.withText(action -> action.getField() + ": " + action.getFormatter().getName())
.withText(action -> action.getField().getDisplayName() + ": " + action.getFormatter().getName())
.withStringTooltip(action -> action.getFormatter().getDescription())
.install(actionsList);
add(actionsList, 1, 1, 3, 1);
Expand Down Expand Up @@ -164,7 +165,8 @@ private GridPane getSelectorPanel() {
GridPane builder = new GridPane();
Set<Field> fields = FieldFactory.getCommonFields();
fields.add(InternalField.KEY_FIELD);
selectFieldCombobox = new ComboBox<>(FXCollections.observableArrayList(fields));
Set<String> fieldsString = fields.stream().map(Field::getDisplayName).sorted().collect(Collectors.toCollection(TreeSet::new));
selectFieldCombobox = new ComboBox<>(FXCollections.observableArrayList(fieldsString));
selectFieldCombobox.setEditable(true);
builder.add(selectFieldCombobox, 1, 1);

Expand Down Expand Up @@ -217,7 +219,7 @@ public boolean isDefaultSaveActions() {

private FieldFormatterCleanup getFieldFormatterCleanup() {
Formatter selectedFormatter = formattersCombobox.getValue();
Field field = selectFieldCombobox.getValue();
Field field = FieldFactory.parseField(selectFieldCombobox.getSelectionModel().getSelectedItem());
return new FieldFormatterCleanup(field, selectedFormatter);
}

Expand All @@ -242,5 +244,4 @@ public void changed(ObservableValue<? extends T> observable, T oldValue, T newVa
setStatus(cleanupEnabled.isSelected());
}
}

}

0 comments on commit a76b8f3

Please sign in to comment.