File: ddGenerationWizard.h

package info (click to toggle)
pgadmin3 1.20.0~beta2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 73,704 kB
  • ctags: 18,591
  • sloc: cpp: 193,786; ansic: 18,736; sh: 5,154; pascal: 1,120; yacc: 927; makefile: 516; lex: 421; xml: 126; perl: 40
file content (224 lines) | stat: -rw-r--r-- 4,819 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
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin III - PostgreSQL Tools
//
// Copyright (C) 2002 - 2014, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
// ddBrowserDataContainer.h - Item to contain data for each treview child.
//
//////////////////////////////////////////////////////////////////////////

#ifndef DDGENERATIONWIZARD_H
#define DDGENERATIONWIZARD_H

#include "hotdraw/figures/hdIFigure.h"
#include "dd/ddmodel/ddDatabaseDesign.h"
#include "dd/ddmodel/ddDBReverseEngineering.h"
#include <wx/grid.h>

class SelGenTablesPage;
class SelGenSchemaPage;
class ReportGridPage;

enum
{
    DDTABSGRID = 7100
};

class ddGenerationWizard : public wxWizard
{
public:
	ddGenerationWizard(wxFrame *frame, ddDatabaseDesign *design, pgConn *connection, bool useSizer = true);
	~ddGenerationWizard();

	// Wizard related functions
	wxWizardPage *GetFirstPage() const
	{
		return initialPage;
	}
	ddDatabaseDesign *getDesign()
	{
		return figuresDesign;
	};
	pgConn *getConnection()
	{
		return conn;
	};
	// Transfer data between pages
	OID OIDSelectedSchema;
	wxString schemaName;
	SelGenTablesPage *page2;
	SelGenSchemaPage *page3;
	ReportGridPage *page4;
	wxString DDL;
	wxArrayString preSelTables;

private:

	void OnWizardPageChanging(wxWizardEvent &event);

	// Page 4 - Report and Finish
	void OnFinishPressed(wxWizardEvent &event);

	pgConn *conn;
	wxWizardPageSimple *initialPage;
	wxStaticText *frontText;
	ddDatabaseDesign *figuresDesign;
	DECLARE_EVENT_TABLE()
};

class SelGenTablesPage : public wxWizardPage
{
public:
	SelGenTablesPage(wxWizard *parent, wxWizardPage *prev);
	~SelGenTablesPage();
	virtual wxWizardPage *GetPrev() const
	{
		return m_prev;
	};
	virtual wxWizardPage *GetNext() const
	{
		return m_next;
	};
	void SetPrev(wxWizardPage *prev)
	{
		m_prev = prev;
	}
	void SetNext(wxWizardPage *next)
	{
		m_next = next;
	}
	void OnButtonAdd(wxCommandEvent &);
	void OnButtonAddAll(wxCommandEvent &);
	void OnButtonRemove(wxCommandEvent &);
	void OnButtonRemoveAll(wxCommandEvent &);
	void RefreshTablesList();
	int countSelTables()
	{
		return m_selTables->GetCount();
	};
	wxString getSelTableName(int index)
	{
		return m_selTables->GetString(index);
	};
private:
	void moveToSelectList(wxString tableName);
	void OnWizardPageChanging(wxWizardEvent &event);
	wxStaticText *leftText, *rightText, *centerText;
	wxWizardPage *m_prev, *m_next;
	wxListBox *m_allTables, *m_selTables;
	ddGenerationWizard *wparent;
	wxArrayString tablesNames;
	wxBitmapButton *buttonAdd, *buttonAddAll, *buttonRemove, *buttonRemoveAll;
	wxBitmap addBitmap, addAllBitmap, removeBitmap, removeAllBitmap;
	DECLARE_EVENT_TABLE()
};

class SelGenSchemaPage : public wxWizardPage
{
public:
	SelGenSchemaPage(wxWizard *parent, wxWizardPage *prev);
	~SelGenSchemaPage();
	virtual wxWizardPage *GetPrev() const
	{
		return m_prev;
	};
	virtual wxWizardPage *GetNext() const
	{
		return m_next;
	};
	void SetPrev(wxWizardPage *prev)
	{
		m_prev = prev;
	}
	void SetNext(wxWizardPage *next)
	{
		m_next = next;
	}
private:
	void OnWizardPageChanging(wxWizardEvent &event);
	void refreshSchemas(pgConn *connection);
	wxStaticText *message;
	wxWizardPage *m_prev, *m_next;
	wxListBox *m_allSchemas;
	wxArrayString schemasNames;
	oidsHashMap schemasHM;
	ddGenerationWizard *wparent;
	DECLARE_EVENT_TABLE()
};

// Special version of wxGrid to allow use of fast comboboxes and grid columns auto fit
// some snippets from http://forums.wxwidgets.org/viewtopic.php?t=27568 under same wxwidgets license
// others from pgAdming gqb
class wxDDGrid: public wxGrid
{
public:
	wxDDGrid(wxWindow *parent, wxWindowID id);
	void ComboBoxEvent(wxGridEvent &event);
	void RevertSel();

	int sf[10];

	void OnSizeEvt( wxSizeEvent &ev );
	int StretchIt();
	int keepFit;

public:
	void SetColStretch ( unsigned i, int factor )
	{
		if( i < 10 ) sf[i] = factor;
	}
	int  GetColStretch ( unsigned i ) const
	{
		return (i < 10) ? sf[i] : 1;
	}
	void ReLayout()
	{
		StretchIt();
	}
	void SetFit( int fit_style )
	{
		keepFit = fit_style;
	}
private:
	wxGridSelection *m_selTemp;
};

class ReportGridPage : public wxWizardPage
{
public:
	ReportGridPage(wxWizard *parent, wxWizardPage *prev);
	~ReportGridPage();
	virtual wxWizardPage *GetPrev() const
	{
		return m_prev;
	};
	virtual wxWizardPage *GetNext() const
	{
		return m_next;
	};
	void SetPrev(wxWizardPage *prev)
	{
		m_prev = prev;
	}
	void SetNext(wxWizardPage *next)
	{
		m_next = next;
	}
	void populateGrid();
	wxDDGrid *getGrid()
	{
		return reportGrid;
	};
private:
	void OnWizardPageChanging(wxWizardEvent &event);
	void OnCellLeftClick(wxGridEvent &ev);

	wxStaticText *message;
	wxWizardPage *m_prev, *m_next;
	wxDDGrid *reportGrid;
	ddGenerationWizard *wparent;
	DECLARE_EVENT_TABLE()
};
#endif