package editor.menubar;

import xml.Element;
import xml.ElementXMLSerializer;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * The ExportActionListener is used to deal with the user action of exporting
 * an element tree to XML
 */
public class ExportActionListener implements ActionListener {
    private Element root;

    public ExportActionListener(Element root) {
        this.root = root;
    }

    @Override
    public void actionPerformed(ActionEvent actionEvent) {
        ElementXMLSerializer exs = new ElementXMLSerializer();
        String fileName = "tree.xml";
        System.out.printf("[DEBUG] writing file: %s\n", fileName);
        exs.serializeToFile(root, fileName);
    }
}

@@ -68,24 +68,46 @@
 erializer;%0A%0A
+import javax.swing.*;%0A
 import java.
@@ -598,36 +598,215 @@
     
-String fileName = %22tree.xml%22
+JFrame exportFileChooserFrame = new JFrame();%0A        JFileChooser fc = new JFileChooser();%0A        fc.showSaveDialog(exportFileChooserFrame);%0A        String fileName = fc.getSelectedFile().getAbsolutePath()
 ;%0A  
@@ -856,10 +856,14 @@
 le: 
-%25s
+%5C%22%25s%5C%22
 %5Cn%22,

Add save dialog for export