/** * Save the model file and inform all listeners. This method is called when the offering duration * is changed by some means */ protected void saveModelAndInform() { try { model.saveModelFile(); } catch (IOException e) { JOptionPane.showMessageDialog(null, "Error saving model file: " + e); } for (CourseModelListener lnr : listeners) lnr.modelUpdated(); }
@Override public void setValueAt(Object value, int row, int col) { switch (col) { case 0: sortedElements.get(row).setStatus((Status) value); try { model.saveStatusFile(); } catch (IOException e) { JOptionPane.showMessageDialog(null, "Error saving status file: " + e); } model.fireCourseStatusChanged(selected); break; case 2: sortedElements.get(row).setDuration((Integer) value); saveModelAndInform(); break; default: throw new RuntimeException("Column " + col + " should not be editable"); } }