/** * A helper method to save changes * * @param fileAdaptor * @param curatorFrame * @return true for saving the changes, while false for an unsuccessful saving. An unsuccessful * saving might result from cancelling or throwing an exception. */ private boolean saveChanges(XMLFileAdaptor fileAdaptor) { // Make sure everything is changed if (fileAdaptor.isDirty()) { int reply = JOptionPane.showConfirmDialog( this, "You have to save changes first before doing synchronization.\n" + "Do you want to save changes and then do synchronization?", "Save Changes?", JOptionPane.OK_CANCEL_OPTION); if (reply == JOptionPane.CANCEL_OPTION) return false; try { fileAdaptor.save(); return true; } catch (Exception e) { JOptionPane.showMessageDialog( this, "Cannot save changes:" + e.getMessage(), "Error in Saving", JOptionPane.ERROR_MESSAGE); System.err.println("SynchronizationDialog.saveChanges(): " + e); e.printStackTrace(); return false; } } return true; }