1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| /**
*
*/
package standardNaast.model;
import java.beans.PropertyChangeSupport;
import java.util.Collections;
import org.jdesktop.observablecollections.ObservableCollections;
import org.jdesktop.observablecollections.ObservableList;
import org.springframework.util.CollectionUtils;
import standardNaast.entities.Personne;
import standardNaast.service.PersonneService;
import standardNaast.service.PersonneServiceImpl;
/**
* @author stessy
*
*/
public class PersonnesModel {
private ObservableList<Personne> personnesList;
private Personne personne;
private PersonneService personneService;
private final PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
public ObservableList<Personne> getPersonnesList() {
if (CollectionUtils.isEmpty(this.personnesList)) {
if (this.personneService == null) {
this.personneService = new PersonneServiceImpl();
}
this.personnesList = ObservableCollections.observableList(this.personneService.findAllPerson());
}
Collections.sort(this.personnesList);
return this.personnesList;
}
public Personne getSelectedPersonne() {
return this.personne;
}
public void setSelectedPersonne(final Personne personne) {
Personne oldPersonne = this.personne;
this.personne = personne;
this.changeSupport.firePropertyChange("personne", oldPersonne, this.personne);
}
} |
Partager