1
1
//////////////////////////////////////////////////////////////////////////
3
3
// pgAdmin III - PostgreSQL Tools
4
// RCS-ID: $Id: frmQuery.h 7127 2008-03-05 11:40:26Z dpage $
5
// Copyright (C) 2002 - 2008, The pgAdmin Development Team
6
// This software is released under the Artistic Licence
4
// RCS-ID: $Id: frmQuery.h 7945 2009-06-26 09:00:11Z dpage $
5
// Copyright (C) 2002 - 2009, The pgAdmin Development Team
6
// This software is released under the BSD Licence
8
8
// frmQuery.h - The SQL Query form
13
13
#define __FRM_QUERY_H
15
15
#include "dlg/dlgClasses.h"
16
#include "gqb/gqbViewController.h"
17
#include "gqb/gqbModel.h"
16
18
#include "utils/factory.h"
17
19
#include "utils/favourites.h"
18
20
#include "utils/macros.h"
22
#include <wx/sstream.h>
23
#include <wx/txtstrm.h>
21
26
#include <wx/aui/aui.h>
27
#include <wx/textctrl.h>
28
#include <wx/dcbuffer.h>
22
29
#include <wx/timer.h>
24
#define FRMQUERY_PERPSECTIVE_VER wxT("$Rev: 7127 $")
31
#define FRMQUERY_PERPSECTIVE_VER wxT("$Rev: 7945 $")
27
#define FRMQUERY_DEFAULT_PERSPECTIVE wxT("layout2|name=toolBar;caption=Tool bar;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=385;besth=23;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=databaseBar;caption=Database bar;state=16788208;dir=1;layer=10;row=0;pos=396;prop=100000;bestw=250;besth=21;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=sqlQuery;caption=SQL query;state=17404;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=350;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=outputPane;caption=Output pane;state=16779260;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=550;besth=300;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=scratchPad;caption=Scratch pad;state=16779260;dir=2;layer=0;row=0;pos=0;prop=100000;bestw=250;besth=200;minw=100;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|dock_size(1,10,0)=25|dock_size(5,0,0)=200|dock_size(3,0,0)=290|dock_size(2,0,0)=255|")
34
#define FRMQUERY_DEFAULT_PERSPECTIVE wxT("layout2|name=toolBar;caption=Tool bar;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=415;besth=23;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=databaseBar;caption=Database bar;state=16788208;dir=1;layer=10;row=0;pos=396;prop=100000;bestw=250;besth=21;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=sqlQuery;caption=SQL query;state=17404;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=350;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=outputPane;caption=Output pane;state=16779260;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=550;besth=300;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=scratchPad;caption=Scratch pad;state=16779260;dir=2;layer=0;row=0;pos=0;prop=100000;bestw=250;besth=200;minw=100;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|dock_size(1,10,0)=25|dock_size(5,0,0)=200|dock_size(3,0,0)=290|dock_size(2,0,0)=255|")
30
#define FRMQUERY_DEFAULT_PERSPECTIVE wxT("layout2|name=toolBar;caption=Tool bar;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=485;besth=30;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=databaseBar;caption=Database bar;state=16788208;dir=1;layer=10;row=0;pos=396;prop=100000;bestw=250;besth=30;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=sqlQuery;caption=SQL query;state=17404;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=350;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=outputPane;caption=Output pane;state=16779260;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=550;besth=300;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=scratchPad;caption=Scratch pad;state=16779260;dir=2;layer=0;row=0;pos=0;prop=100000;bestw=250;besth=200;minw=100;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|dock_size(1,10,0)=25|dock_size(5,0,0)=200|dock_size(3,0,0)=290|dock_size(2,0,0)=255|")
37
#define FRMQUERY_DEFAULT_PERSPECTIVE wxT("layout2|name=toolBar;caption=Tool bar;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=525;besth=30;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=databaseBar;caption=Database bar;state=16788208;dir=1;layer=10;row=0;pos=396;prop=100000;bestw=250;besth=30;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=sqlQuery;caption=SQL query;state=17404;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=350;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=outputPane;caption=Output pane;state=16779260;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=550;besth=300;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=scratchPad;caption=Scratch pad;state=16779260;dir=2;layer=0;row=0;pos=0;prop=100000;bestw=250;besth=200;minw=100;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|dock_size(1,10,0)=25|dock_size(5,0,0)=200|dock_size(3,0,0)=290|dock_size(2,0,0)=255|")
32
#define FRMQUERY_DEFAULT_PERSPECTIVE wxT("layout2|name=toolBar;caption=Tool bar;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=385;besth=23;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=databaseBar;caption=Database bar;state=16788208;dir=1;layer=10;row=0;pos=396;prop=100000;bestw=250;besth=21;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=sqlQuery;caption=SQL query;state=17404;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=350;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=outputPane;caption=Output pane;state=16779260;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=550;besth=300;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=scratchPad;caption=Scratch pad;state=16779260;dir=2;layer=0;row=0;pos=0;prop=100000;bestw=250;besth=200;minw=100;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|dock_size(1,10,0)=25|dock_size(5,0,0)=200|dock_size(3,0,0)=290|dock_size(2,0,0)=255|")
39
#define FRMQUERY_DEFAULT_PERSPECTIVE wxT("layout2|name=toolBar;caption=Tool bar;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=415;besth=23;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=databaseBar;caption=Database bar;state=16788208;dir=1;layer=10;row=0;pos=396;prop=100000;bestw=250;besth=21;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=sqlQuery;caption=SQL query;state=17404;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=350;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=outputPane;caption=Output pane;state=16779260;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=550;besth=300;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=scratchPad;caption=Scratch pad;state=16779260;dir=2;layer=0;row=0;pos=0;prop=100000;bestw=250;besth=200;minw=100;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|dock_size(1,10,0)=25|dock_size(5,0,0)=200|dock_size(3,0,0)=290|dock_size(2,0,0)=255|")
36
43
class ExplainCanvas;
37
44
class ctlSQLResult;
39
48
class QueryExecInfo
64
75
ctlComboBoxFix *cbConnection;
65
76
wxTextCtrl *scratchPad;
67
// Query timing/status update
78
// Query timing/status update
69
80
wxLongLong elapsedQuery, startTimeQuery;
83
pgsApplication * pgScript;
84
wxString pgsOutputString;
85
wxStringOutputStream pgsStringOutput;
86
wxTextOutputStream pgsOutput;
87
pgScriptTimer * pgsTimer;
90
void OnChangeNotebook(wxNotebookEvent& event);
91
void OnAdjustSizesTimer(wxTimerEvent & event);
92
void OnResizeHorizontally(wxSplitterEvent& event);
93
void adjustGQBSizes();
94
bool updateFromGqb(bool executing);
95
wxNotebook *sqlNotebook;
97
gqbController *controller;
99
bool gqbUpdateRunning;
100
wxTimer *adjustSizesTimer;
74
105
// These status flags are required to work round some wierdness on wxGTK,
75
106
// particularly on Solaris.
76
107
bool closing, loading;
78
109
void OnEraseBackground(wxEraseEvent& event);
79
110
void OnSize(wxSizeEvent& event);
86
117
void OnHelp(wxCommandEvent& event);
87
118
void OnCancel(wxCommandEvent& event);
88
119
void OnExecute(wxCommandEvent& event);
120
void OnExecScript(wxCommandEvent& event);
89
121
void OnExecFile(wxCommandEvent& event);
90
122
void OnExplain(wxCommandEvent& event);
91
123
void OnNew(wxCommandEvent& event);
123
155
void OnToggleOutputPane(wxCommandEvent& event);
124
156
void OnAuiUpdate(wxAuiManagerEvent& event);
125
157
void OnDefaultView(wxCommandEvent& event);
158
void OnBlockIndent(wxCommandEvent& event);
159
void OnBlockOutDent(wxCommandEvent& event);
160
void OnChangeToUpperCase(wxCommandEvent& event);
161
void OnChangeToLowerCase(wxCommandEvent& event);
162
void OnCommentText(wxCommandEvent& event);
163
void OnUncommentText(wxCommandEvent& event);
127
void OnTimer(wxTimerEvent & event);
165
void OnTimer(wxTimerEvent & event);
129
167
bool CheckChanged(bool canVeto);
130
168
void OpenLastFile();
132
170
void execQuery(const wxString &query, int resultToRetrieve=0, bool singleResult=false, const int queryOffset=0, bool toFile=false, bool explain=false, bool verbose=false);
133
171
void OnQueryComplete(wxCommandEvent &ev);
134
172
void completeQuery(bool done, bool explain, bool verbose);
173
void OnScriptComplete(wxCommandEvent &ev);
135
174
void setTools(const bool running);
136
175
void showMessage(const wxString& msg, const wxString &msgShort=wxT(""));
137
176
void setExtendedTitle();
139
178
void SetLineEndingStyle();
140
179
int GetLineEndingStyle();
141
180
void OnSetEOLMode(wxCommandEvent& event);
142
void OnMacroInvoke(wxCommandEvent& event);
143
void OnMacroManage(wxCommandEvent& event);
144
void UpdateMacrosList();
181
void SetEOLModeDisplay(int mode);
182
void OnMacroInvoke(wxCommandEvent& event);
183
void OnMacroManage(wxCommandEvent& event);
184
void UpdateMacrosList();
145
185
wxWindow *currentControl();
146
186
wxMenu *queryMenu;
147
187
wxMenu *favouritesMenu;
149
189
wxMenu *lineEndMenu;
151
192
wxString lastFilename, lastDir;
153
194
queryFavouriteFolder *favourites;
154
queryMacroList *macros;
195
queryMacroList *macros;
157
198
bool lastFileFormat;
200
// A simple mutex-like flag to prevent concurrent script execution.
201
// Required because the pgScript parser isn't currently thread-safe :-(
202
static bool ms_pgScriptRunning;
159
204
DECLARE_EVENT_TABLE()
164
207
// Position of status line fields
199
246
bool CheckEnable(pgObject *obj);
204
249
class queryToolFactory : public queryToolBaseFactory
207
queryToolFactory(menuFactoryList *list, wxMenu *mnu, wxToolBar *toolbar);
252
queryToolFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
208
253
wxWindow *StartDialog(frmMain *form, pgObject *obj);
212
256
class queryToolSqlFactory : public queryToolBaseFactory
215
queryToolSqlFactory(menuFactoryList *list, wxMenu *mnu, wxToolBar *toolbar);
259
queryToolSqlFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
216
260
wxWindow *StartDialog(frmMain *form, pgObject *obj);
217
261
bool CheckEnable(pgObject *obj);
221
264
class queryToolSelectFactory : public queryToolDataFactory
267
queryToolSelectFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
268
wxWindow *StartDialog(frmMain *form, pgObject *obj);
271
class queryToolDeleteFactory : public queryToolDataFactory
225
queryToolSelectFactory(menuFactoryList *list, wxMenu *mnu, wxToolBar *toolbar);
274
queryToolDeleteFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
226
275
wxWindow *StartDialog(frmMain *form, pgObject *obj);
276
bool CheckEnable(pgObject *obj);
229
279
class queryToolInsertFactory : public queryToolDataFactory
232
queryToolInsertFactory(menuFactoryList *list, wxMenu *mnu, wxToolBar *toolbar);
282
queryToolInsertFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
233
283
wxWindow *StartDialog(frmMain *form, pgObject *obj);
234
284
bool CheckEnable(pgObject *obj);
237
287
class queryToolUpdateFactory : public queryToolDataFactory
240
queryToolUpdateFactory(menuFactoryList *list, wxMenu *mnu, wxToolBar *toolbar);
290
queryToolUpdateFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
241
291
wxWindow *StartDialog(frmMain *form, pgObject *obj);
242
292
bool CheckEnable(pgObject *obj);
295
///////////////////////////////////////////////////////
296
class pgScriptTimer : public wxTimer
302
pgScriptTimer(frmQuery * parent);
245
306
#endif // __FRM_QUERY_H