public void saveAs() { MostRecentFileDialog mrfd = new MostRecentFileDialog("org.concord.otviewer.saveotml"); mrfd.setFilenameFilter("otml"); if (currentUserFile != null) { mrfd.setCurrentDirectory(currentUserFile.getParentFile()); mrfd.setSelectedFile(currentUserFile); } int retval = mrfd.showSaveDialog(getDialogParent()); File file = null; if (retval == MostRecentFileDialog.APPROVE_OPTION) { file = mrfd.getSelectedFile(); String fileName = file.getPath(); currentUserFile = file; if (!fileName.toLowerCase().endsWith(".otml")) { currentUserFile = new File(currentUserFile.getAbsolutePath() + ".otml"); } try { ExporterJDOM.export(currentUserFile, userDataDB.getRoot(), userDataDB); userDataDB.setDirty(false); } catch (Exception e) { e.printStackTrace(); } } }
public void save() { if (currentUserFile == null || !currentUserFile.exists()) { saveAs(); return; } if (currentUserFile.exists()) { try { ExporterJDOM.export(currentUserFile, userDataDB.getRoot(), userDataDB); userDataDB.setDirty(false); } catch (Exception e) { e.printStackTrace(); } } }