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

Method saveXMLAs

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

Saves the xml-formatted log records to a file selected with a chooser. @return the name of the file

()

Source from the content-addressed store, hash-verified

687 * @return the name of the file
688 */
689 public String saveXMLAs() {
690 int result = getChooser().showSaveDialog(null);
691 if(result==JFileChooser.APPROVE_OPTION) {
692 File file = getChooser().getSelectedFile();
693 // check to see if file already exists
694 if(file.exists()) {
695 int selected = JOptionPane.showConfirmDialog(frame,
696 ControlsRes.getString("OSPLog.ReplaceExisting_dialog_message") + file.getName() //$NON-NLS-1$
697 + ControlsRes.getString("OSPLog.question_mark"), //$NON-NLS-1$
698 ControlsRes.getString("OSPLog.ReplaceFile_dialog_title"), //$NON-NLS-1$
699 JOptionPane.YES_NO_CANCEL_OPTION);
700 if(selected!=JOptionPane.YES_OPTION) {
701 return null;
702 }
703 }
704 logFileName = XML.getRelativePath(file.getAbsolutePath());
705 return saveXML(logFileName);
706 }
707 return null;
708 }
709
710 /**
711 * Opens a text file selected with a chooser and writes the contents to the log.

Callers 1

saveXMLMethod · 0.95

Calls 9

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

Tested by

no test coverage detected