org.datafx.samples.app.DataModel Maven / Gradle / Ivy
package org.datafx.samples.app;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ListProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import org.datafx.controller.flow.injection.FlowScoped;
@FlowScoped
public class DataModel {
private ListProperty persons;
private IntegerProperty selectedPersonIndex;
public ListProperty getPersons() {
if (persons == null) {
ObservableList innerList = FXCollections.observableArrayList();
persons = new SimpleListProperty<>(innerList);
}
return persons;
}
public int getSelectedPersonIndex() {
return selectedPersonIndexProperty().get();
}
public void setSelectedPersonIndex(int selectedPersonIndex) {
this.selectedPersonIndex.set(selectedPersonIndex);
}
public IntegerProperty selectedPersonIndexProperty() {
if (selectedPersonIndex == null) {
selectedPersonIndex = new SimpleIntegerProperty();
}
return selectedPersonIndex;
}
}