The dialog generating code doesn't belong in the main app.  Made a start on moving it.  Once I've refined the output, I'll probably want to edit it manually.