Skip to content

Commit

Permalink
Convert ObservableList into ListProperty - review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ricantech authored and ricantech committed Feb 17, 2019
1 parent a89ac49 commit e4f3ea3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import java.util.Optional;
import java.util.function.Supplier;

import javafx.beans.property.ListProperty;
import javafx.beans.value.ChangeListener;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
Expand Down Expand Up @@ -93,8 +93,8 @@ private void removeKeyword() {
}
}

private void initListView(ListView<String> listViewToInit, Supplier<ObservableList<String>> backingList, ChangeListener<String> onSelectedListener) {
listViewToInit.setItems(backingList.get());
private void initListView(ListView<String> listViewToInit, Supplier<ListProperty<String>> backingList, ChangeListener<String> onSelectedListener) {
listViewToInit.itemsProperty().bind(backingList.get());
listViewToInit.getSelectionModel().selectedItemProperty().addListener(onSelectedListener);
listViewToInit.getSelectionModel().select(FIRST_ELEMENT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
import java.util.Set;
import java.util.stream.Collectors;

import javafx.beans.property.ListProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;

import org.jabref.gui.AbstractViewModel;
import org.jabref.gui.BasePanel;
import org.jabref.gui.DialogService;
import org.jabref.logic.l10n.Localization;
Expand All @@ -21,7 +23,7 @@

import static com.google.common.collect.ImmutableList.of;

class ContentSelectorDialogViewModel {
class ContentSelectorDialogViewModel extends AbstractViewModel {

private static final List<String> DEFAULT_FIELD_NAMES = of(FieldName.AUTHOR, FieldName.JOURNAL, FieldName.KEYWORDS, FieldName.PUBLISHER);

Expand All @@ -30,8 +32,8 @@ class ContentSelectorDialogViewModel {
private final BasePanel basePanel;
private final Map<String, List<String>> fieldNameKeywordsMap = new HashMap<>();

private ObservableList<String> fieldNames = FXCollections.observableArrayList();
private ObservableList<String> keywords = FXCollections.observableArrayList();
private ListProperty<String> fieldNames = new SimpleListProperty<>(FXCollections.observableArrayList());
private ListProperty<String> keywords = new SimpleListProperty<>(FXCollections.observableArrayList());

ContentSelectorDialogViewModel(MetaData metaData, BasePanel basePanel, DialogService dialogService) {
this.metaData = metaData;
Expand All @@ -57,11 +59,11 @@ private void populateFieldNameKeywordsMapWithExistingValues() {
);
}

ObservableList<String> getFieldNamesBackingList() {
ListProperty<String> getFieldNamesBackingList() {
return fieldNames;
}

ObservableList<String> getKeywordsBackingList() {
ListProperty<String> getKeywordsBackingList() {
return keywords;
}

Expand Down

0 comments on commit e4f3ea3

Please sign in to comment.