| 1 |
////////////////////////////////////////////////////////////////////////////// |
| 2 |
////////////////////////////////////////////////////////////////////////////// |
| 3 |
// |
| 4 |
// copyright : (C) 2014 Eran Ifrah |
| 5 |
// file name : ErdCommitWizard.h |
| 6 |
// |
| 7 |
// ------------------------------------------------------------------------- |
| 8 |
// A |
| 9 |
// _____ _ _ _ _ |
| 10 |
// / __ \ | | | | (_) | |
| 11 |
// | / \/ ___ __| | ___| | _| |_ ___ |
| 12 |
// | | / _ \ / _ |/ _ \ | | | __/ _ ) |
| 13 |
// | \__/\ (_) | (_| | __/ |___| | || __/ |
| 14 |
// \____/\___/ \__,_|\___\_____/_|\__\___| |
| 15 |
// |
| 16 |
// F i l e |
| 17 |
// |
| 18 |
// This program is free software; you can redistribute it and/or modify |
| 19 |
// it under the terms of the GNU General Public License as published by |
| 20 |
// the Free Software Foundation; either version 2 of the License, or |
| 21 |
// (at your option) any later version. |
| 22 |
// |
| 23 |
////////////////////////////////////////////////////////////////////////////// |
| 24 |
////////////////////////////////////////////////////////////////////////////// |
| 25 |
|
| 26 |
#ifndef ERDCOMMITWIZARD_H |
| 27 |
#define ERDCOMMITWIZARD_H |
| 28 |
|
| 29 |
#include <wx/wx.h> |
| 30 |
#include <wx/treectrl.h> |
| 31 |
#include <wx/wizard.h> |
| 32 |
#include <wx/imaglist.h> |
| 33 |
#include <wx/filepicker.h> |
| 34 |
#include <wx/statline.h> |
| 35 |
#include <wx/txtstrm.h> |
| 36 |
#include <wx/wfstream.h> |
| 37 |
#include <wx/dblayer/include/DatabaseLayer.h> |
| 38 |
#include <wx/dblayer/include/DatabaseLayerException.h> |
| 39 |
#include "wx/wxxmlserializer/XmlSerializer.h" |
| 40 |
|
| 41 |
#include "dbconnection.h" |
| 42 |
#include "database.h" |
| 43 |
#include "dbitem.h" |
| 44 |
#include "dumpclass.h" |
| 45 |
#include "view.h" |
| 46 |
#include "CodePreviewDialog.h" |
| 47 |
|
| 48 |
/*! \brief Wizard for commiting database structure from ERD diagrom to database server. */ |
| 49 |
class ErdCommitWizard : public wxWizard { |
| 50 |
|
| 51 |
public: |
| 52 |
ErdCommitWizard(wxWindow* parent, xsSerializable* pConnections, const wxString& createScript); |
| 53 |
virtual ~ErdCommitWizard(); |
| 54 |
|
| 55 |
wxWizardPageSimple* GetFirstPage(); |
| 56 |
|
| 57 |
void SetSelectedDatabase(Database* db) { m_pSelectedDatabase = db; } |
| 58 |
Database* GetSelectedDatabase() { return m_pSelectedDatabase; } |
| 59 |
const wxString& GetCreateScript() { return m_createScript; } |
| 60 |
|
| 61 |
protected: |
| 62 |
wxWizardPageSimple* m_pFirstPage; |
| 63 |
wxString m_createScript; |
| 64 |
xsSerializable* m_pConnections; |
| 65 |
|
| 66 |
Database* m_pSelectedDatabase; |
| 67 |
|
| 68 |
}; |
| 69 |
|
| 70 |
/*! \brief Fist page of ErdCommitWizard */ |
| 71 |
class FirstPage : public wxWizardPageSimple { |
| 72 |
|
| 73 |
public: |
| 74 |
FirstPage(wxWizard* parent); |
| 75 |
virtual ~FirstPage(); |
| 76 |
}; |
| 77 |
|
| 78 |
class DatabasePage : public wxWizardPageSimple{ |
| 79 |
|
| 80 |
public: |
| 81 |
|
| 82 |
DatabasePage(ErdCommitWizard* parent, xsSerializable* pConnections ); |
| 83 |
virtual ~DatabasePage(); |
| 84 |
protected: |
| 85 |
virtual bool TransferDataFromWindow(); |
| 86 |
void LoadDatabases(); |
| 87 |
|
| 88 |
ErdCommitWizard* m_pParentWizard; |
| 89 |
xsSerializable* m_pConnections; |
| 90 |
wxTreeCtrl* m_treeDatabases; |
| 91 |
wxFlexGridSizer* m_mainSizer; |
| 92 |
|
| 93 |
}; |
| 94 |
/*! \brief Second page of ErdCommitWizard */ |
| 95 |
class BackupPage : public wxWizardPageSimple{ |
| 96 |
public: |
| 97 |
BackupPage(ErdCommitWizard* parent); |
| 98 |
virtual ~BackupPage(); |
| 99 |
|
| 100 |
protected: |
| 101 |
virtual bool TransferDataToWindow(); |
| 102 |
virtual bool TransferDataFromWindow(); |
| 103 |
|
| 104 |
void OnFileStructureUI(wxUpdateUIEvent& event); |
| 105 |
void OnBtnBackupUI(wxUpdateUIEvent& event); |
| 106 |
void OnBtnBackupClick(wxCommandEvent& event); |
| 107 |
|
| 108 |
ErdCommitWizard* m_pParentWizard; |
| 109 |
wxFlexGridSizer* m_mainSizer; |
| 110 |
|
| 111 |
wxFilePickerCtrl* m_pFileData; |
| 112 |
wxFilePickerCtrl* m_pFileStructure; |
| 113 |
wxCheckBox* m_pCheckStructure; |
| 114 |
|
| 115 |
wxButton* m_btnBackup; |
| 116 |
|
| 117 |
bool backuped; |
| 118 |
}; |
| 119 |
|
| 120 |
/*! \brief Third page of ErdCommitWizard */ |
| 121 |
class WriteStructurePage : public wxWizardPageSimple{ |
| 122 |
public: |
| 123 |
WriteStructurePage(ErdCommitWizard* parent); |
| 124 |
virtual ~WriteStructurePage(); |
| 125 |
|
| 126 |
|
| 127 |
protected: |
| 128 |
virtual bool TransferDataToWindow(); |
| 129 |
virtual bool TransferDataFromWindow(); |
| 130 |
|
| 131 |
void OnBtnWriteClick(wxCommandEvent& event); |
| 132 |
void OnBtnShowSqlClick(wxCommandEvent& event); |
| 133 |
|
| 134 |
|
| 135 |
ErdCommitWizard* m_pParentWizard; |
| 136 |
|
| 137 |
wxFlexGridSizer* m_mainSizer; |
| 138 |
|
| 139 |
wxTextCtrl* m_txLog; |
| 140 |
|
| 141 |
wxButton* m_btnWrite; |
| 142 |
wxButton* m_btnShowSql; |
| 143 |
|
| 144 |
bool commited; |
| 145 |
}; |
| 146 |
/*! \brief Last page of ErdCommitWizard */ |
| 147 |
class LastPage : public wxWizardPageSimple{ |
| 148 |
public: |
| 149 |
LastPage(wxWizard* parent); |
| 150 |
virtual ~LastPage(); |
| 151 |
|
| 152 |
}; |
| 153 |
/*! \brief Restore page of ErdCommitWizard */ |
| 154 |
class RestorePage : public wxWizardPageSimple{ |
| 155 |
public: |
| 156 |
RestorePage(ErdCommitWizard* parent); |
| 157 |
virtual ~RestorePage(); |
| 158 |
|
| 159 |
protected: |
| 160 |
void OnBtnRestoreUI(wxUpdateUIEvent& event); |
| 161 |
void OnBtnRestoreClick(wxCommandEvent& event); |
| 162 |
void Clear(); |
| 163 |
void AppendText(const wxString& txt); |
| 164 |
void AppendComment(const wxString& txt); |
| 165 |
void AppendSeparator(); |
| 166 |
|
| 167 |
|
| 168 |
wxString m_text; |
| 169 |
ErdCommitWizard* m_pParentWizard; |
| 170 |
wxFlexGridSizer* m_mainSizer; |
| 171 |
wxFilePickerCtrl* m_restoreFile; |
| 172 |
wxTextCtrl* m_txLog; |
| 173 |
|
| 174 |
wxButton* m_btnRestore; |
| 175 |
}; |
| 176 |
|
| 177 |
#endif // ERDCOMMITWIZARD_H |