MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / saveLogAs

Method saveLogAs

src/org/opensourcephysics/controls/OSPLog.java:631–650  ·  view source on GitHub ↗

Saves a log to a text file selected with a chooser. @return the name of the file

()

Source from the content-addressed store, hash-verified

629 * @return the name of the file
630 */
631 public String saveLogAs() {
632 int result = getChooser().showSaveDialog(null);
633 if(result==JFileChooser.APPROVE_OPTION) {
634 File file = getChooser().getSelectedFile();
635 // check to see if file already exists
636 if(file.exists()) {
637 int selected = JOptionPane.showConfirmDialog(frame,
638 ControlsRes.getString("OSPLog.ReplaceExisting_dialog_message") + file.getName() //$NON-NLS-1$
639 + ControlsRes.getString("OSPLog.question_mark"), //$NON-NLS-1$
640 ControlsRes.getString("OSPLog.ReplaceFile_dialog_title"), //$NON-NLS-1$
641 JOptionPane.YES_NO_CANCEL_OPTION);
642 if(selected!=JOptionPane.YES_OPTION) {
643 return null;
644 }
645 }
646 String fileName = XML.getRelativePath(file.getAbsolutePath());
647 return saveLog(fileName);
648 }
649 return null;
650 }
651
652 /**
653 * Saves the xml-formatted log records to a file specified by name.

Callers 2

saveLogMethod · 0.95
actionPerformedMethod · 0.95

Calls 9

getChooserMethod · 0.95
getStringMethod · 0.95
getRelativePathMethod · 0.95
saveLogMethod · 0.95
existsMethod · 0.80
showConfirmDialogMethod · 0.80
getNameMethod · 0.65
showSaveDialogMethod · 0.45
getAbsolutePathMethod · 0.45

Tested by

no test coverage detected