private void update() {
if (tblPeople.getSelectedRow() < 0) {
return;
}
Person person = tblModel.people.get(tblPeople.getSelectedRow());
String s = JOptionPane.showInputDialog(PeoplePanel.this, "Enter new name for '" + person + "'", person.name);
if (s == null || s.trim().isEmpty()) {
return;
}
s = s.trim();
try {
Sessions.beginTransaction();
Person existing = (Person) Sessions.getSession().createCriteria(Person.class).add(Restrictions.eq("name", s)).uniqueResult();
if (existing != null && existing.id != person.id) {
Sessions.rollbackTransaction();
JOptionPane.showMessageDialog(this, "Person '" + existing + "' already exists.", "Add person", JOptionPane.WARNING_MESSAGE);
return;
}