File: ErdCommitWizard.cpp

package info (click to toggle)
codelite 6.1.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 48,992 kB
  • ctags: 43,502
  • sloc: cpp: 334,263; ansic: 18,441; xml: 4,713; yacc: 2,653; lex: 2,449; python: 1,188; sh: 385; makefile: 40
file content (505 lines) | stat: -rw-r--r-- 17,583 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright            : (C) 2014 The CodeLite Team
// file name            : ErdCommitWizard.cpp
//
// -------------------------------------------------------------------------
// A
//              _____           _      _     _ _
//             /  __ \         | |    | |   (_) |
//             | /  \/ ___   __| | ___| |    _| |_ ___
//             | |    / _ \ / _  |/ _ \ |   | | __/ _ )
//             | \__/\ (_) | (_| |  __/ |___| | ||  __/
//              \____/\___/ \__,_|\___\_____/_|\__\___|
//
//                                                  F i l e
//
//    This program is free software; you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation; either version 2 of the License, or
//    (at your option) any later version.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

#include "ErdCommitWizard.h"

#include "res/gui/folder.xpm"
#include "res/gui/form_blue.xpm"
#include "res/gui/form_yellow.xpm"
#include "res/gui/wiztest.xpm"

ErdCommitWizard::ErdCommitWizard(wxWindow* parent, xsSerializable* pConnections, const wxString& createScript): wxWizard(parent,wxID_ANY,_T("ERD commit wizard"),
	        wxBitmap(wiztest_xpm)) {

	m_createScript = createScript;
	m_pConnections = pConnections;
	m_pSelectedDatabase = NULL;
	m_pFirstPage = new FirstPage(this);

	DatabasePage* pDbPage = new DatabasePage(this,pConnections);
	m_pFirstPage->SetNext(pDbPage);
	pDbPage->SetPrev(m_pFirstPage);

	BackupPage* pBackPage = new BackupPage(this);
	pDbPage->SetNext(pBackPage);
	pBackPage->SetPrev(pDbPage);

	WriteStructurePage* pWritePage = new WriteStructurePage(this);
	pBackPage->SetNext(pWritePage);
	pWritePage->SetPrev(pBackPage);

	RestorePage* pRestorePage = new RestorePage(this);
	pWritePage->SetNext(pRestorePage);
	pRestorePage->SetPrev(pWritePage);

	LastPage* pLastPage = new LastPage(this);
	pRestorePage->SetNext(pLastPage);
	pLastPage->SetPrev(pRestorePage);

	GetPageAreaSizer()->Add(m_pFirstPage);
}

ErdCommitWizard::~ErdCommitWizard() {
}

wxWizardPageSimple* ErdCommitWizard::GetFirstPage() {
	return m_pFirstPage;
}


FirstPage::FirstPage(wxWizard* parent):wxWizardPageSimple(parent) {
	wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
	mainSizer->Add(
	    new wxStaticText(this, wxID_ANY, wxString(_("Wizard for creating db structure\n")) +
	                     wxString(_("on ERD diagram base.\n\n")) +
	                     wxString(_("All tables which really exist in\n")) +
	                     wxString(_("the database, will be deleted during\n")) +
	                     wxString(_("this process, but you can do a backup\n")) +
	                     wxString(_("in the second step."))),
	    0,wxALL,5);
	SetSizer(mainSizer);
	mainSizer->Fit(this);
}

FirstPage::~FirstPage() {
}



DatabasePage::DatabasePage(ErdCommitWizard* parent, xsSerializable* pConnections):wxWizardPageSimple(parent) {
	m_pParentWizard = parent;
	m_pConnections = pConnections;
	m_mainSizer = new wxFlexGridSizer( 2, 1, 0, 0 );
	m_mainSizer->AddGrowableCol( 0 );
	m_mainSizer->AddGrowableRow( 1 );
	m_mainSizer->SetFlexibleDirection( wxBOTH );
	m_mainSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
	m_mainSizer->Add(new wxStaticText(this,wxID_ANY,_("Select target database:")));
	m_treeDatabases = new wxTreeCtrl(this,wxID_ANY,wxDefaultPosition, wxDefaultSize, wxTR_DEFAULT_STYLE|wxTR_HIDE_ROOT);
	m_mainSizer->Add(m_treeDatabases, 0, wxALL|wxEXPAND, 5 );


	SetSizer(m_mainSizer);
	m_mainSizer->Fit(this);
	LoadDatabases();
}

DatabasePage::~DatabasePage() {

}

void DatabasePage::LoadDatabases() {
	// clear items from tree
	m_treeDatabases->DeleteAllItems();
	// create imageList for icons
	wxImageList *pImageList = new wxImageList(16,16,true,3);
	pImageList->Add(wxIcon(folder_xpm));						// folder icon
	pImageList->Add(wxIcon(form_blue_xpm));						// table icon
	pImageList->Add(wxIcon(form_yellow_xpm));						// view icon
	m_treeDatabases->SetImageList(pImageList);

	wxTreeItemId totalRootID = m_treeDatabases->AddRoot(wxString::Format(wxT("Databases")),-1);

	// ---------------- load connections ----------------------------
	SerializableList::compatibility_iterator connectionNode = m_pConnections->GetFirstChildNode();
	while(connectionNode) {
		DbConnection* pDbCon = (DbConnection*) wxDynamicCast(connectionNode->GetData(),DbConnection);
		if (pDbCon) {
			wxTreeItemId rootID = m_treeDatabases->AppendItem(totalRootID,wxString::Format(wxT("Databases (%s)"),pDbCon->GetServerName().c_str()),-1,-1, new DbItem(pDbCon));
			m_treeDatabases->Expand(rootID);
			// ----------------------- load databases -------------------------------
			SerializableList::compatibility_iterator dbNode = pDbCon->GetFirstChildNode();
			while(dbNode) {
				Database* pDatabase = wxDynamicCast(dbNode->GetData(), Database);
				if (pDatabase) {
					//wxTreeItemId dbID = m_treeDatabases->AppendItem(rootID,pDatabase->getName(),-1,-1, new DbItem(pDatabase,NULL));//new DbDatabase(db->getName()));
					m_treeDatabases->AppendItem(rootID,pDatabase->GetName(),-1,-1, new DbItem(pDatabase));//new DbDatabase(db->getName()));

				}
				dbNode = dbNode->GetNext();
			}
			// -----------------------------------------------------------------------
		}
		connectionNode = connectionNode->GetNext();
	}

}

bool DatabasePage::TransferDataFromWindow() {
	DbItem* data = (DbItem*) m_treeDatabases->GetItemData(m_treeDatabases->GetSelection());
	if (data) {
		Database* pdb = wxDynamicCast(data->GetData(), Database);
		if (pdb) {
			m_pParentWizard->SetSelectedDatabase(pdb);
		}
	}
	//TODO:LANG:
	if (!m_pParentWizard->GetSelectedDatabase()) {
		wxMessageBox(_("The first time you have to select a target database!"));
		return false;
	}
	return true;
}
BackupPage::BackupPage(ErdCommitWizard* parent):wxWizardPageSimple(parent) {
	m_pParentWizard = parent;
	backuped = false;

	m_mainSizer = new wxFlexGridSizer(8,1,0,0);
	m_mainSizer->AddGrowableCol(0);
	m_mainSizer->SetFlexibleDirection(wxBOTH);
	m_mainSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );

	m_mainSizer->Add(new wxStaticText(this,wxID_ANY, _("Backup data file")));
	m_pFileData = new wxFilePickerCtrl(this,wxID_ANY,_("data.sql"),_("Select file"), wxT("SQL file *.sql|*.sql"),wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_SAVE|wxFLP_OVERWRITE_PROMPT);
	m_mainSizer->Add(m_pFileData, 0, wxALL|wxEXPAND, 5 );
	m_mainSizer->Add(new wxStaticLine(this), 0, wxALL|wxEXPAND, 5 );
	m_pCheckStructure = new wxCheckBox(this, wxID_ANY,_("Backup database structure"));
	m_mainSizer->Add(m_pCheckStructure, 0, wxALL|wxEXPAND, 5 );
	m_mainSizer->Add(new wxStaticText(this,wxID_ANY, _("Backup structure file")));
	m_pFileStructure = new wxFilePickerCtrl(this,wxID_ANY,_("structure.sql"),_("Select file"), wxT("SQL file *.sql|*.sql"),wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_SAVE|wxFLP_OVERWRITE_PROMPT);
	m_mainSizer->Add(m_pFileStructure, 0, wxALL|wxEXPAND, 5 );
	m_mainSizer->Add(new wxStaticLine(this), 0, wxALL|wxEXPAND, 5 );

	m_btnBackup = new wxButton(this, wxID_ANY, _("Backup!"));
	m_mainSizer->Add(m_btnBackup,0,wxALIGN_CENTER_HORIZONTAL,0);

	SetSizer(m_mainSizer);
	m_mainSizer->Fit(this);

	m_pFileStructure->Connect(wxEVT_UPDATE_UI, wxUpdateUIEventHandler(BackupPage::OnFileStructureUI),NULL,this);
	m_btnBackup->Connect(wxEVT_UPDATE_UI,wxUpdateUIEventHandler(BackupPage::OnBtnBackupUI),NULL,this);
	m_btnBackup->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BackupPage::OnBtnBackupClick),NULL,this);

}

bool BackupPage::TransferDataFromWindow() {
	if (!backuped) {
		wxMessageDialog dlg(this, _("Backing up database data before changing the structure is really good idea. Do you want to continue without doing so?"),_("Backup"),wxYES_NO);
		if (dlg.ShowModal() ==  wxID_YES) {
			return true;
		} else return false;
	}
	return true;
}

BackupPage::~BackupPage() {
}

void BackupPage::OnFileStructureUI(wxUpdateUIEvent& event) {
	if (m_pCheckStructure) {
		event.Enable(m_pCheckStructure->IsChecked());
	} else event.Enable(false);
}

void BackupPage::OnBtnBackupClick(wxCommandEvent& event) {
	m_pParentWizard->GetSelectedDatabase()->RefreshChildrenDetails();
	wxString dumpResult = wxT("");
	DumpClass* pDump = new DumpClass(m_pParentWizard->GetSelectedDatabase()->GetDbAdapter(), m_pParentWizard->GetSelectedDatabase(), m_pFileData->GetPath());
	if (pDump) dumpResult = pDump->DumpData();

	wxMessageBox(_("Data saved! ")+ dumpResult );

	if (m_pCheckStructure->IsChecked()) {
		wxString retStr;


		SerializableList::compatibility_iterator tabNode = m_pParentWizard->GetSelectedDatabase()->GetFirstChildNode();
		while(tabNode) {
			Table* tab = wxDynamicCast(tabNode->GetData(),Table);
			if (tab) {
				retStr.append(m_pParentWizard->GetSelectedDatabase()->GetDbAdapter()->GetCreateTableSql(tab,true));
			}
			tabNode = tabNode->GetNext();
		}

		tabNode = m_pParentWizard->GetSelectedDatabase()->GetFirstChildNode();
		while(tabNode) {
			View* view = wxDynamicCast(tabNode->GetData(),View);
			if (view) {
				retStr.append(m_pParentWizard->GetSelectedDatabase()->GetDbAdapter()->GetCreateViewSql(view,true));
			}
			tabNode = tabNode->GetNext();
		}

		tabNode = m_pParentWizard->GetSelectedDatabase()->GetFirstChildNode();
		while(tabNode) {
			Table* tab = wxDynamicCast(tabNode->GetData(),Table);
			if (tab) {
				retStr.append(m_pParentWizard->GetSelectedDatabase()->GetDbAdapter()->GetAlterTableConstraintSql(tab));
			}
			tabNode = tabNode->GetNext();
		}

		wxTextFile pTextFile(m_pFileStructure->GetPath());

		if (pTextFile.Exists()) {
			pTextFile.Open();
			pTextFile.Clear();
		} else {
			pTextFile.Create();
			pTextFile.Open();
		}
		if (pTextFile.IsOpened()) {
			pTextFile.AddLine(retStr);
			pTextFile.Write(wxTextFileType_None, wxConvUTF8);
			pTextFile.Close();
			wxMessageBox(_("Structure saved!"));
		}

	}
	backuped = true;
}

void BackupPage::OnBtnBackupUI(wxUpdateUIEvent& event) {
	if (m_pCheckStructure->IsChecked()) {
		event.Enable((!m_pFileData->GetPath().IsEmpty())&&(!m_pFileStructure->GetPath().IsEmpty()));
	} else event.Enable(!m_pFileData->GetPath().IsEmpty());
}

bool BackupPage::TransferDataToWindow() {
	backuped = false;
	return true;
}

WriteStructurePage::WriteStructurePage(ErdCommitWizard* parent):wxWizardPageSimple(parent) {
	m_pParentWizard = parent;
	m_mainSizer = new wxFlexGridSizer(1,0,0);
	m_mainSizer->AddGrowableCol(0);
	m_mainSizer->AddGrowableRow(1);
	m_mainSizer->SetFlexibleDirection(wxBOTH);
	m_mainSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );

	m_mainSizer->Add(new wxStaticText(this, wxID_ANY,_("Write log:")));

	m_txLog = new wxTextCtrl(this, wxID_ANY,wxT(""),wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY);
	m_mainSizer->Add(m_txLog,0,wxEXPAND,5);
	m_mainSizer->Add(new wxStaticLine(this),0, wxEXPAND,2);

	wxBoxSizer* pSizer = new wxBoxSizer(wxHORIZONTAL);
	m_btnWrite = new wxButton(this, wxID_ANY,_("Write !!"));
	m_btnShowSql = new wxButton(this, wxID_ANY, _("Show SQL"));

	pSizer->Add(m_btnWrite, wxALIGN_CENTER_HORIZONTAL);
	pSizer->Add(m_btnShowSql, wxALIGN_CENTER_HORIZONTAL);

	m_mainSizer->Add(pSizer,0,wxEXPAND,0);

	SetSizer(m_mainSizer);
	m_mainSizer->Fit(this);

	m_btnWrite->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(WriteStructurePage::OnBtnWriteClick),NULL, this);
	m_btnShowSql->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(WriteStructurePage::OnBtnShowSqlClick), NULL, this);


}

WriteStructurePage::~WriteStructurePage() {
}

void WriteStructurePage::OnBtnShowSqlClick(wxCommandEvent& event) {
	CodePreviewDialog dlg(this, m_pParentWizard->GetCreateScript());
	dlg.ShowModal();
}

void WriteStructurePage::OnBtnWriteClick(wxCommandEvent& event) {
	DatabaseLayerPtr pDbLayer(NULL);
	try {
		pDbLayer = m_pParentWizard->GetSelectedDatabase()->GetDbAdapter()->GetDatabaseLayer(m_pParentWizard->GetSelectedDatabase()->GetName());
		if (pDbLayer) {
			pDbLayer->BeginTransaction();

			wxString useSql = m_pParentWizard->GetSelectedDatabase()->GetDbAdapter()->GetUseDb(m_pParentWizard->GetSelectedDatabase()->GetName());
			if (!useSql.IsEmpty()) pDbLayer->RunQuery(wxString::Format(wxT("USE %s"), m_pParentWizard->GetSelectedDatabase()->GetName().c_str()));


			pDbLayer->RunQuery(m_pParentWizard->GetCreateScript());

			pDbLayer->Commit();
			pDbLayer->Close();
			m_txLog->SetValue(_("Data structure written successfully!"));
			commited = true;
		}

	} catch (DatabaseLayerException& e) {
		if (pDbLayer) {
			pDbLayer->RollBack();
			pDbLayer->Close();
		}
		wxString errorMessage = wxString::Format(_("Error (%d): %s"), e.GetErrorCode(), e.GetErrorMessage().c_str());
		m_txLog->SetValue(errorMessage);
	} catch( ... ) {
		if (pDbLayer) {
			pDbLayer->RollBack();
			pDbLayer->Close();
		}
		m_txLog->SetValue(_("Unknown error!"));
	}
}

bool WriteStructurePage::TransferDataFromWindow() {
	if (!commited) {
		wxMessageDialog dlg(this, _("Would you like to continue without writing the database structure?"),_("Question"),wxYES_NO);
		if (dlg.ShowModal() ==  wxID_YES) {
			return true;
		} else return false;
	}
	return true;
}

bool WriteStructurePage::TransferDataToWindow() {
	commited = false;
	return true;
}

LastPage::LastPage(wxWizard* parent):wxWizardPageSimple(parent) {
	wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
	mainSizer->Add(
	    new wxStaticText(this, wxID_ANY, _("Writing structure ended.\n")),
	    0,wxALL,5);
	SetSizer(mainSizer);
	mainSizer->Fit(this);
}

LastPage::~LastPage() {
}

RestorePage::RestorePage(ErdCommitWizard* parent):wxWizardPageSimple(parent) {
	m_pParentWizard = parent;
	m_mainSizer = new wxFlexGridSizer(1, 0,0);
	m_mainSizer->SetFlexibleDirection(wxBOTH);
	m_mainSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
	m_mainSizer->AddGrowableCol(0);
	m_mainSizer->AddGrowableRow(4);


	m_mainSizer->Add(new wxStaticText(this, wxID_ANY, _("File for data restore:")), 0, wxEXPAND, 2);

	m_restoreFile = new wxFilePickerCtrl(this,wxID_ANY,wxT(""),_("Select file"), wxT("SQL file *.sql|*.sql"),wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_OPEN|wxFLP_FILE_MUST_EXIST);
	m_mainSizer->Add(m_restoreFile, 0, wxEXPAND, 2);
	m_mainSizer->Add(new wxStaticLine(this),0, wxEXPAND,2);

	m_mainSizer->Add(new wxStaticText(this, wxID_ANY, _("Restore log:")), 0, wxEXPAND, 2);

	m_txLog = new wxTextCtrl(this, wxID_ANY, wxT(""),wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY);
	m_mainSizer->Add(m_txLog,0,wxEXPAND,2 );
	m_mainSizer->Add(new wxStaticLine(this),0, wxEXPAND,2);

	m_btnRestore = new wxButton(this,wxID_ANY,_("Restore"));
	m_mainSizer->Add(m_btnRestore,0, wxALIGN_CENTER_HORIZONTAL, 5);

	SetSizer(m_mainSizer);
	m_mainSizer->Fit(this);

	m_btnRestore->Connect(wxEVT_UPDATE_UI, wxUpdateUIEventHandler(RestorePage::OnBtnRestoreUI), NULL, this);
	m_btnRestore->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(RestorePage::OnBtnRestoreClick), NULL, this);

}

RestorePage::~RestorePage() {
}
void RestorePage::OnBtnRestoreClick(wxCommandEvent& event)
{
	if (m_restoreFile->GetPath().IsEmpty()) return;

	DatabaseLayerPtr pDbLayer(NULL);
	Database* pDb = m_pParentWizard->GetSelectedDatabase();
	Clear();
	try {
		wxFileInputStream input(m_restoreFile->GetPath());
		wxTextInputStream text( input, wxT(";"), wxConvUTF8 );
		wxString command = wxT("");

		pDbLayer = pDb->GetDbAdapter()->GetDatabaseLayer(pDb->GetName());
		pDbLayer->BeginTransaction();

		wxString useSql = pDb->GetDbAdapter()->GetUseDb(pDb->GetName());
		if (!useSql.IsEmpty()) pDbLayer->RunQuery(wxString::Format(wxT("USE %s"), pDb->GetName().c_str()));

		while (!input.Eof()) {
			wxString line = text.ReadLine();
			//dialog.AppendText(line);
			int index = line.Find(wxT("--"));
			if (index != wxNOT_FOUND) line = line.Mid(0,index);
			command += line;
			if (line.Find(wxT(";")) != wxNOT_FOUND) {
				AppendSeparator();
				AppendComment(wxT("Run SQL command:"));
				AppendText(command);
				pDbLayer->RunQuery(command);
				AppendComment(_("Successful!"));
				command.Clear();
			}
		}
		pDbLayer->Commit();
		pDbLayer->Close();
	} catch (DatabaseLayerException& e) {
		if (pDbLayer) {
			pDbLayer->RollBack();
			pDbLayer->Close();
		}
		wxString errorMessage = wxString::Format(_("Error (%d): %s"), e.GetErrorCode(), e.GetErrorMessage().c_str());

		AppendComment(_("Fail!"));
		AppendComment(errorMessage);
		wxMessageDialog dlg(this,errorMessage,_("DB Error"),wxOK | wxCENTER | wxICON_ERROR);
		dlg.ShowModal();
	} catch( ... ) {
		if (pDbLayer) {
			pDbLayer->RollBack();
			pDbLayer->Close();
		}
		wxMessageDialog dlg(this,_("Unknown error."),_("DB Error"),wxOK | wxCENTER | wxICON_ERROR);
		dlg.ShowModal();
	}

}

void RestorePage::OnBtnRestoreUI(wxUpdateUIEvent& event)
{
	event.Enable(!m_restoreFile->GetPath().IsEmpty());
}
void RestorePage::AppendText(const wxString& txt)
{
	m_text.Append(txt + wxT("\n"));
	m_txLog->SetValue(m_text);
}

void RestorePage::Clear()
{
	m_text.clear();
	m_txLog->SetValue(m_text);
}

void RestorePage::AppendSeparator()
{
	m_text.Append(wxT("*********************************************************\n"));
	m_txLog->SetValue(m_text);
}

void RestorePage::AppendComment(const wxString& txt)
{
	m_text.Append(wxNow() + wxT(" ") + txt + wxT("\n"));
	m_txLog->SetValue(m_text);
}