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
|
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin III - PostgreSQL Tools
//
// Copyright (C) 2002 - 2014, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
// frmMain.h - The main form
//
//////////////////////////////////////////////////////////////////////////
#ifndef FRMMAIN_H
#define FRMMAIN_H
// wxWindows headers
#include <wx/wx.h>
#include <wx/listctrl.h>
#include <wx/notebook.h>
// wxAUI
#include <wx/aui/aui.h>
#include "frm/frmQuery.h"
#include "dlg/dlgClasses.h"
#include "utils/factory.h"
//
// This number MUST be incremented if changing any of the default perspectives
//
#define FRMMAIN_PERSPECTIVE_VER wxT("8418")
#ifdef __WXMAC__
#define FRMMAIN_DEFAULT_PERSPECTIVE wxT("layout2|name=objectBrowser;caption=Object browser;state=16779260;dir=4;layer=1;row=0;pos=0;prop=100000;bestw=200;besth=450;minw=100;minh=200;maxw=-1;maxh=-1;floatx=236;floaty=222;floatw=-1;floath=-1|name=listViews;caption=Info pane;state=1020;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=sqlPane;caption=SQL pane;state=16779260;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=toolBar;caption=Tool bar;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=520;besth=39;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|dock_size(5,0,0)=18|dock_size(3,0,0)=228|dock_size(1,10,0)=41|dock_size(4,1,0)=233|")
#else
#ifdef __WXGTK__
#define FRMMAIN_DEFAULT_PERSPECTIVE wxT("layout2|name=objectBrowser;caption=Object browser;state=16779260;dir=4;layer=1;row=0;pos=0;prop=100000;bestw=200;besth=450;minw=100;minh=200;maxw=-1;maxh=-1;floatx=236;floaty=222;floatw=-1;floath=-1|name=listViews;caption=Info pane;state=1020;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=sqlPane;caption=SQL pane;state=16779260;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=toolBar;caption=Tool bar;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=586;besth=44;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|dock_size(5,0,0)=18|dock_size(3,0,0)=228|dock_size(1,10,0)=41|dock_size(4,1,0)=233|")
#else
#define FRMMAIN_DEFAULT_PERSPECTIVE wxT("layout2|name=objectBrowser;caption=Object browser;state=16779260;dir=4;layer=1;row=0;pos=0;prop=100000;bestw=200;besth=450;minw=100;minh=200;maxw=-1;maxh=-1;floatx=236;floaty=222;floatw=-1;floath=-1|name=listViews;caption=Info pane;state=1020;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=sqlPane;caption=SQL pane;state=16779260;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=toolBar;caption=Tool bar;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=506;besth=39;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|dock_size(5,0,0)=18|dock_size(3,0,0)=228|dock_size(1,10,0)=41|dock_size(4,1,0)=233|")
#endif
#endif
class pgServer;
class pgServerCollection;
class ctlSQLBox;
class ctlTree;
class dlgProperty;
class serverCollection;
class propertyFactory;
class pluginUtilityFactory;
class ctlMenuButton;
// A plugin utility
typedef struct PluginUtility
{
wxString title;
wxString command;
wxString description;
wxString keyfile;
wxString platform;
wxArrayString server_types;
bool database;
wxArrayString applies_to;
bool set_password;
wxArrayString set_env;
} PluginUtility;
enum
{
NBP_PROPERTIES = 0,
NBP_STATISTICS,
NBP_DEPENDENCIES,
NBP_DEPENDENTS
};
enum
{
REFRESH_OBJECT_NONE = 0,
REFRESH_OBJECT_ONLY,
REFRESH_OBJECT_AND_CHILDREN
};
#if defined(HAVE_OPENSSL_CRYPTO) || defined(HAVE_GCRYPT)
BEGIN_DECLARE_EVENT_TYPES()
extern const wxEventType SSH_TUNNEL_ERROR_EVENT;
END_DECLARE_EVENT_TYPES()
#endif
// Class declarations
class frmMain : public pgFrame
{
public:
frmMain(const wxString &title);
~frmMain();
void OnAction(wxCommandEvent &ev);
void OnReport(wxCommandEvent &ev);
wxString GetHelpPage() const;
void StartMsg(const wxString &msg);
void EndMsg(bool done = true);
void SetStatusText(const wxString &msg);
void SetCurrentObject(pgObject *data)
{
currentObject = data;
}
bool CheckAlive();
void execSelChange(wxTreeItemId item, bool currentNode);
void Refresh(pgObject *data);
void ExecDrop(bool cascaded);
void ShowObjStatistics(pgObject *data, wxWindow *ctrl = NULL);
wxImageList *GetImageList()
{
return imageList;
}
ctlTree *GetBrowser()
{
return browser;
}
ctlSQLBox *GetSqlPane()
{
return sqlPane;
}
ctlListView *GetProperties()
{
return properties;
}
ctlListView *GetStatistics();
ctlListView *GetDependencies();
ctlListView *GetReferencedBy();
void SelectStatisticsTab()
{
listViews->SetSelection(1);
};
void StoreServers();
int ReconnectServer(pgServer *server, bool restore = true);
void ReportConnError(pgServer *server);
pgServerCollection *GetServerCollection()
{
return serversObj;
}
pgServer *ConnectToServer(const wxString &servername, bool restore = false);
void SetLastPluginUtility(pluginUtilityFactory *pluginFactory)
{
lastPluginUtility = pluginFactory;
}
pluginUtilityFactory *GetLastPluginUtility()
{
return lastPluginUtility;
}
wxMenu *GetPluginsMenu()
{
return pluginsMenu;
}
wxString GetCurrentNodePath();
bool SetCurrentNode(wxTreeItemId node, const wxString &path);
void UpdateAllRecentFiles();
void UpdateAllFavouritesList();
void UpdateAllMacrosList();
void SetItemBackgroundColour(wxTreeItemId item, wxColour colour);
wxString GetNodePath(wxTreeItemId node);
void ObjectBrowserRefreshing(bool refresh)
{
m_refreshing = refresh;
}
#if defined(HAVE_OPENSSL_CRYPTO) || defined(HAVE_GCRYPT)
void OnSSHTunnelEvent(wxCommandEvent &event);
#endif
private:
wxAuiManager manager;
ctlTree *browser;
ctlListView *properties;
ctlListView *statistics;
ctlListView *dependents, *dependencies;
ctlAuiNotebook *listViews;
ctlSQLBox *sqlPane;
wxMenu *newMenu, *debuggingMenu, *reportMenu, *toolsMenu, *pluginsMenu, *viewMenu,
*treeContextMenu, *newContextMenu, *slonyMenu, *scriptingMenu, *viewDataMenu;
pgServerCollection *serversObj;
pluginUtilityFactory *lastPluginUtility;
int pluginUtilityCount;
propertyFactory *propFactory;
actionFactory *newMenuFactory;
actionFactory *debuggingMenuFactory;
actionFactory *reportMenuFactory;
actionFactory *scriptingMenuFactory;
actionFactory *viewdataMenuFactory;
wxStopWatch stopwatch;
wxString timermsg;
long msgLevel;
bool m_refreshing;
wxTreeItemId denyCollapseItem;
pgObject *currentObject;
wxControl *currentControl;
void OnChildFocus(wxChildFocusEvent &event);
void OnEraseBackground(wxEraseEvent &event);
void OnSize(wxSizeEvent &event);
void OnSelectItem(wxListEvent &event);
void CreateMenus();
void OnContents(wxCommandEvent &event);
void OnExit(wxCommandEvent &event);
void ViewData(bool filter = false);
void OnSaveDefinition(wxCommandEvent &event);
void OnToggleSqlPane(wxCommandEvent &event);
void OnToggleObjectBrowser(wxCommandEvent &event);
void OnToggleToolBar(wxCommandEvent &event);
void OnDefaultView(wxCommandEvent &event);
void OnAuiUpdate(wxAuiManagerEvent &event);
void OnAuiNotebookPageClose(wxAuiNotebookEvent &event);
void OnContextMenu(wxCommandEvent &event);
void OnPageChange(wxAuiNotebookEvent &event);
void OnPropSelChanged(wxListEvent &event);
void OnPropSelActivated(wxListEvent &event);
void OnPropRightClick(wxListEvent &event);
void OnTreeSelChanged(wxTreeEvent &event);
void OnTreeKeyDown(wxTreeEvent &event);
void OnSelActivated(wxTreeEvent &event);
void OnSelRightClick(wxTreeEvent &event);
void OnCollapse(wxTreeEvent &event);
void OnExpand(wxTreeEvent &event);
void OnClose(wxCloseEvent &event);
void OnNew(wxCommandEvent &event);
void OnDelete(wxCommandEvent &ev);
void OnCopy(wxCommandEvent &ev);
void OnCheckAlive(wxCommandEvent &event);
void OnPositionStc(wxStyledTextEvent &event);
void ResetLists();
bool dropSingleObject(pgObject *data, bool updateFinal, bool cascaded);
void doPopup(wxWindow *win, wxPoint point, pgObject *object);
void setDisplay(pgObject *data, ctlListView *props = 0, ctlSQLBox *sqlbox = 0);
void RetrieveServers();
bool reportError(const wxString &error, const wxString &msgToIdentify, const wxString &hint);
wxTreeItemId RestoreEnvironment(pgServer *server);
void GetExpandedChildNodes(wxTreeItemId node, wxArrayString &expandedNodes);
void ExpandChildNodes(wxTreeItemId node, wxArrayString &expandedNodes);
void PopulatePluginButtonMenu(wxCommandEvent &event);
// In plugins.cpp
void LoadPluginUtilities();
void AddPluginUtility(PluginUtility *util);
void CreatePluginUtility(PluginUtility *util);
void ClearPluginUtility(PluginUtility *util);
DECLARE_EVENT_TABLE()
};
enum
{
CTL_BROWSER = 301,
CTL_NOTEBOOK,
CTL_PROPVIEW,
CTL_STATVIEW,
CTL_DEPVIEW,
CTL_REFVIEW,
CTL_SQLPANE
};
class contentsFactory : public actionFactory
{
public:
contentsFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
wxWindow *StartDialog(frmMain *form, pgObject *obj);
};
class pgsqlHelpFactory : public actionFactory
{
public:
pgsqlHelpFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar, bool bigTool);
wxWindow *StartDialog(frmMain *form, pgObject *obj);
};
class edbHelpFactory : public actionFactory
{
public:
edbHelpFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar, bool bigTool);
wxWindow *StartDialog(frmMain *form, pgObject *obj);
};
class greenplumHelpFactory : public actionFactory
{
public:
greenplumHelpFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar, bool bigTool);
wxWindow *StartDialog(frmMain *form, pgObject *obj);
};
class slonyHelpFactory : public actionFactory
{
public:
slonyHelpFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar, bool bigTool);
wxWindow *StartDialog(frmMain *form, pgObject *obj);
};
class faqFactory : public actionFactory
{
public:
faqFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
wxWindow *StartDialog(frmMain *form, pgObject *obj);
};
class bugReportFactory : public actionFactory
{
public:
bugReportFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
wxWindow *StartDialog(frmMain *form, pgObject *obj);
};
class pluginUtilityFactory : public actionFactory
{
public:
pluginUtilityFactory(menuFactoryList *list, wxMenu *menu, PluginUtility *util);
wxWindow *StartDialog(frmMain *form, pgObject *obj);
bool CheckEnable(pgObject *obj);
private:
bool HaveDatabase(pgObject *obj);
wxString title, command, description;
bool database, set_password;
wxArrayString applies_to, server_types, set_env;
};
class pluginButtonMenuFactory : public actionFactory
{
public:
pluginButtonMenuFactory(menuFactoryList *list, wxMenu *popupmenu, ctlMenuToolbar *toolbar, int pluginCount);
wxWindow *StartDialog(frmMain *form, pgObject *obj);
bool CheckEnable(pgObject *obj);
private:
ctlMenuButton *pulldownButton;
bool enableButton;
};
#endif
|