public ExtendedElement save(ExtendedElement parent) {
parent.setAttribute("name", m_nameField.getText());
if (m_passwordField.getText().length() != 0)
parent.setAttribute("password", m_passwordField.getText());
ExtendedElement buttonsElement = parent.createChildWithName("buttons");
buttonsElement.setAttribute("up", m_upField.getText());
buttonsElement.setAttribute("down", m_downField.getText());
buttonsElement.setAttribute("next", m_nextField.getText());
buttonsElement.setAttribute("previous", m_previousField.getText());
buttonsElement.setAttribute("start", m_startField.getText());
buttonsElement.setAttribute("end", m_endField.getText());
parent.createChildWithNameAndText("results", m_resultsField.getText());
parent.createChildWithNameAndText("stimuli", m_stimuliField.getText());
ExtendedElement mainElement;
if (m_standardButton.isSelected())
mainElement = parent.getOrCreateChildWithName("standardTest");
else if (m_ddButton.isSelected())
mainElement = parent.getOrCreateChildWithName("dragdropTest");
else
mainElement = parent.getOrCreateChildWithName("timesyncTest");
mainElement.createChildWithNameAndText("header", m_headerField.getText());
if (((Integer) m_pauseDelayField.getValue()).intValue() != 0) {
ExtendedElement pauseElement = mainElement.createChildWithNameAndText("pause", m_pauseMessageField.getText());
pauseElement.setAttribute("delay", ((Integer) m_pauseDelayField.getValue()).toString());
pauseElement.setAttribute("unit", m_pauseMinutesButton.isSelected() ? "minutes" : "pages");
}
return parent;
}