public boolean open() { MostRecentFileDialog mrfd = new MostRecentFileDialog("org.concord.otviewer.openotml"); mrfd.setFilenameFilter("otml"); int retval = mrfd.showOpenDialog(getDialogParent()); File file = null; if (retval == MostRecentFileDialog.APPROVE_OPTION) { file = mrfd.getSelectedFile(); } if (file == null || !file.exists()) { return false; } // CHECKME it isn't clear if the userName should be cleared here or not try { load(file); return true; } catch (MalformedURLException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return false; }
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(); } } }