~ubuntu-branches/debian/sid/pgadmin3/sid

« back to all changes in this revision

Viewing changes to pgadmin/include/frm/frmQuery.h

  • Committer: Bazaar Package Importer
  • Author(s): Gerfried Fuchs
  • Date: 2009-07-30 12:27:16 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090730122716-fddbh42on721bbs2
Tags: 1.10.0-1
* New upstream release.
* Adjusted watch file to match release candidates.
* Updated to Standards-Version 3.8.2:
  - Moved to Section: database.
  - Add DEB_BUILD_OPTIONS support for parallel building.
  - Move from findstring to filter suggestion for DEB_BUILD_OPTIONS parsing.
* pgagent got split into its own separate source package by upstream.
* Exclude Docs.vcproj from installation.
* Move doc-base.enus from pgadmin3 to pgadmin3-data package, the files are
  in there too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//////////////////////////////////////////////////////////////////////////
2
2
//
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
7
7
//
8
8
// frmQuery.h - The SQL Query form
9
9
//
13
13
#define __FRM_QUERY_H
14
14
 
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"
19
21
 
 
22
#include <wx/sstream.h>
 
23
#include <wx/txtstrm.h>
 
24
 
20
25
// wxAUI
21
26
#include <wx/aui/aui.h>
 
27
#include <wx/textctrl.h>
 
28
#include <wx/dcbuffer.h>
22
29
#include <wx/timer.h>
23
30
 
24
 
#define FRMQUERY_PERPSECTIVE_VER wxT("$Rev: 7127 $")
 
31
#define FRMQUERY_PERPSECTIVE_VER wxT("$Rev: 7945 $")
25
32
 
26
33
#ifdef __WXMAC__
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|")
28
35
#else
29
36
#ifdef __WXGTK__
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|")
31
38
#else
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|")
33
40
#endif
34
41
#endif
35
42
 
36
43
class ExplainCanvas;
37
44
class ctlSQLResult;
 
45
class pgsApplication;
 
46
class pgScriptTimer;
38
47
 
39
48
class QueryExecInfo
40
49
{
52
61
    frmQuery(frmMain *form, const wxString& _title, pgConn *conn, const wxString& qry, const wxString& file = wxEmptyString);
53
62
    ~frmQuery();
54
63
    void Go();
 
64
    
 
65
    void writeScriptOutput();
55
66
 
56
67
private:
57
68
    frmMain *mainForm;
64
75
    ctlComboBoxFix *cbConnection;
65
76
    wxTextCtrl *scratchPad;
66
77
 
67
 
    // Query timing/status update
 
78
        // Query timing/status update
68
79
    wxTimer timer;
69
80
    wxLongLong elapsedQuery, startTimeQuery;
70
 
 
71
 
    // Our connection
 
81
    
 
82
    // pgScript interface
 
83
    pgsApplication * pgScript;
 
84
    wxString pgsOutputString;
 
85
    wxStringOutputStream pgsStringOutput;
 
86
    wxTextOutputStream pgsOutput;
 
87
    pgScriptTimer * pgsTimer;
 
88
 
 
89
        //GQB related
 
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;
 
96
    gqbModel *model;
 
97
    gqbController *controller;
 
98
    bool firstTime;
 
99
        bool gqbUpdateRunning;
 
100
    wxTimer *adjustSizesTimer;
 
101
 
 
102
        // Our connection
72
103
    pgConn *conn;
73
104
 
74
105
        // These status flags are required to work round some wierdness on wxGTK,
75
106
        // particularly on Solaris.
76
107
    bool closing, loading;
77
 
    
 
108
 
78
109
    void OnEraseBackground(wxEraseEvent& event);
79
110
    void OnSize(wxSizeEvent& event);
80
111
 
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);
126
164
 
127
 
        void OnTimer(wxTimerEvent & event);
 
165
    void OnTimer(wxTimerEvent & event);
128
166
 
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;
148
 
        wxMenu *macrosMenu;
 
188
    wxMenu *macrosMenu;
149
189
    wxMenu *lineEndMenu;
 
190
    wxMenu *formatMenu;
150
191
    wxString title;
151
192
    wxString lastFilename, lastDir;
152
193
 
153
194
    queryFavouriteFolder *favourites;
154
 
        queryMacroList *macros;
 
195
    queryMacroList *macros;
155
196
 
156
197
    bool aborted;
157
198
    bool lastFileFormat;
158
199
 
 
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;
 
203
 
159
204
    DECLARE_EVENT_TABLE()
160
205
};
161
206
 
162
 
 
163
 
 
164
207
// Position of status line fields
165
208
enum
166
209
{
171
214
    STATUSPOS_SECS
172
215
};
173
216
 
174
 
 
175
217
enum
176
218
{
177
219
    CTL_SQLQUERY=331,
178
220
    CTL_SQLRESULT,
179
221
    CTL_MSGRESULT,
180
 
    CTL_MSGHISTORY
 
222
    CTL_MSGHISTORY,
 
223
    CTL_NTBKCENTER,
 
224
    CTL_COLSGRID,
 
225
    CTL_TIMERSIZES,
 
226
    CTL_TIMERFRM,
 
227
    CTL_NTBKGQB
181
228
};
182
229
 
183
230
///////////////////////////////////////////////////////
199
246
    bool CheckEnable(pgObject *obj);
200
247
};
201
248
 
202
 
 
203
 
 
204
249
class queryToolFactory : public queryToolBaseFactory
205
250
{
206
251
public:
207
 
    queryToolFactory(menuFactoryList *list, wxMenu *mnu, wxToolBar *toolbar);
 
252
    queryToolFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
208
253
    wxWindow *StartDialog(frmMain *form, pgObject *obj);
209
254
};
210
255
 
211
 
    
212
256
class queryToolSqlFactory : public queryToolBaseFactory
213
257
{
214
258
public:
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);
218
262
};
219
263
 
220
 
 
221
264
class queryToolSelectFactory : public queryToolDataFactory
 
265
{
 
266
public:
 
267
    queryToolSelectFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
 
268
    wxWindow *StartDialog(frmMain *form, pgObject *obj);
 
269
};
222
270
 
 
271
class queryToolDeleteFactory : public queryToolDataFactory
223
272
{
224
273
public:
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);
227
277
};
228
278
 
229
279
class queryToolInsertFactory : public queryToolDataFactory
230
280
{
231
281
public:
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);
235
285
};
237
287
class queryToolUpdateFactory : public queryToolDataFactory
238
288
{
239
289
public:
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);
243
293
};
244
294
 
 
295
///////////////////////////////////////////////////////
 
296
class pgScriptTimer : public wxTimer
 
297
{
 
298
private:
 
299
    frmQuery * m_parent;
 
300
 
 
301
public:
 
302
    pgScriptTimer(frmQuery * parent);
 
303
    void Notify();
 
304
};
 
305
 
245
306
#endif // __FRM_QUERY_H