
#ifndef _DB_REVERSE_ENGINEER_SCRIPT_H_
#define _DB_REVERSE_ENGINEER_SCRIPT_H_

#include "grtui/grt_wizard_plugin.h"
#include "grtui/wizard_progress_page.h"
#include "grtui/wizard_finished_page.h"

#include "db_rev_eng_be.h"

using namespace grtui;
using namespace mforms;

namespace ScriptImport {

/**
 * Wizard page for setting up the import.
 */
class ImportInputPage : public WizardPage
{
private:
  Table _table;
  Label _heading;
  Box _contents;
  Label _caption;
  TextEntry _filename;
  Button _browse_button;
  Label _file_codeset_caption;
  Selector _file_codeset_sel;
  
  CheckBox _autoplace_check;
  
  void fill_encodings_list();
public:
  ImportInputPage(WizardPlugin *form);
  void file_changed();
  virtual void do_validate();
  virtual bool allow_next();  
  virtual std::string next_button_caption();
  void gather_options(bool advancing);

};

/**
 * Wizard page that shows the progress of the current import operation.
 */
class ImportProgressPage : public WizardProgressPage
{
private:
  Sql_import _import_be;
  TaskRow *_auto_place_task;
  bool _auto_place;
  bool _done;
  
public:
  ImportProgressPage(WizardForm *form);
  void import_objects_finished(grt::ValueRef value);
  bool import_objects();
  bool verify_results();
  bool place_objects();
  virtual bool allow_back();  
  virtual void enter(bool advancing);
  std::string get_summary();
};


/**
 * The actual import wizard comprising the pages declared above and some additional stuff.
 */
  
class WbPluginSQLImport : public WizardPlugin
{
private:
  ImportInputPage *_input_page;
  ImportProgressPage *_progress_page;
  WizardFinishedPage *_finish_page;
  
public:
  WbPluginSQLImport(grt::Module *module);
  void update_summary(bool success);
};


}; // namespace ScriptImport


grtui::WizardPlugin *createImportScriptWizard(grt::Module *module, db_CatalogRef catalog);

#endif // _DB_REVERSE_ENGINEER_SCRIPT_H_
