@Override
    public final void windowClosing(final WindowEvent e) {
        if (!this.holder.wasChanged()) {
            System.exit(0);
        }
        int react = JOptionPane.showConfirmDialog(this.frame,
                "The diagramhas not been saved. Save changes now?",
                "Closing diagram without saving",
                JOptionPane.YES_NO_CANCEL_OPTION);
        if (react == JOptionPane.CANCEL_OPTION) {
            return;
        } else if (react == JOptionPane.NO_OPTION) {
            System.exit(0);
        }
        final JFileChooser chooser = new JFileChooser(".");
        while (true) {
            final int returnVal = chooser.showSaveDialog(this.frame);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                final File file = chooser.getSelectedFile();
                if (file.exists()) {
                    react = JOptionPane
                            .showConfirmDialog(
                                    this.frame,
                                    String
                                            .format(
                                                    "The file '%s' already exists. Do you want to overwrite it?",
                                                    file.getAbsolutePath()));
                    if (react == JOptionPane.CANCEL_OPTION) {
                        return;
                    } else if (react == JOptionPane.NO_OPTION) {
                        continue;
                    }
                }
                final CSVProcessor csvProc = new CSVProcessor(" ");
                try {
                    csvProc.write(file, this.holder
                            .getCurrentDocumentAsArray());
                    System.exit(0);
                } catch (final IOException e1) {
                    JOptionPane.showMessageDialog(this.frame,
                            "Error while accessing file.");
                }
            }
            return;
        }
    }