Debian Codegraph @

DatabaseExplorer/DbViewerPanel.h

raw
1 //////////////////////////////////////////////////////////////////////////////
2 //////////////////////////////////////////////////////////////////////////////
3 //
4 // copyright : (C) 2014 Eran Ifrah
5 // file name : DbViewerPanel.h
6 //
7 // -------------------------------------------------------------------------
8 // A
9 // _____ _ _ _ _
10 // / __ \ | | | | (_) |
11 // | / \/ ___ __| | ___| | _| |_ ___
12 // | | / _ \ / _ |/ _ \ | | | __/ _ )
13 // | \__/\ (_) | (_| | __/ |___| | || __/
14 // \____/\___/ \__,_|\___\_____/_|\__\___|
15 //
16 // F i l e
17 //
18 // This program is free software; you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation; either version 2 of the License, or
21 // (at your option) any later version.
22 //
23 //////////////////////////////////////////////////////////////////////////////
24 //////////////////////////////////////////////////////////////////////////////
25
26 #ifndef DBEXPLORERPANEL_H
27 #define DBEXPLORERPANEL_H
28
29 #include "../Interfaces/imanager.h"
30 #include "GUI.h" // Base class: _DbExplorerPanel
31 #include "clToolBar.h"
32 // database
33 #include <wx/dblayer/include/DatabaseLayer.h>
34
35 //#ifdef DBL_USE_MYSQL
36 //#include <wx/dblayer/include/MysqlDatabaseLayer.h>
37 //#endif
38
39 #include <wx/wxsf/wxShapeFramework.h>
40
41 // wx classes
42 #include <wx/aui/aui.h>
43 #include <wx/hashmap.h>
44 #include <wx/textdlg.h>
45 #include <wx/txtstrm.h>
46 #include <wx/wx.h>
47
48 // other
49 #include "DnDTableShape.h"
50 #include "IDbAdapter.h"
51 #include "IDbItem.h"
52 #include "column.h"
53 #include "database.h"
54 #include "dbconnection.h"
55 #include "dumpclass.h"
56 #include "table.h"
57 #include "view.h"
58 //#include "MySqlDbAdapter.h"
59 #include "ClassGenerateDialog.h"
60 #include "LogDialog.h"
61 #include "dbitem.h"
62
63 #include <unordered_set>
64
65 class DbExplorerFrame;
66 WX_DECLARE_HASH_MAP(wxString, wxTreeItemId, wxStringHash, wxStringEqual, TableHashMap);
67
68 class MainBook;
69 /*! \brief Main application panel. It show database tree and can open special editors. */
70 class DbViewerPanel : public _DbViewerPanel
71 {
72 std::unordered_set<DbExplorerFrame*> m_frames;
73
74 protected:
75 virtual void OnContextMenu(wxTreeEvent& event);
76
77 private:
78 xsSerializable* m_pConnections;
79 IDbAdapter* m_pDbAdapter;
80 wxWindow* m_pGlobalParent;
81 wxString m_server;
82 wxTreeItemId m_selectedID;
83 wxWindow* m_pNotebook;
84 IManager* m_mgr;
85 TableHashMap m_hashTables;
86 Database* m_pEditedDatabase;
87 DbConnection* m_pEditedConnection;
88 wxWindow* m_pPrevPanel;
89 bool m_SuppressUpdate;
90 clToolBar* m_toolbar;
91
92 public:
93 DbViewerPanel(wxWindow* parent, wxWindow* notebook, IManager* pManager);
94 virtual ~DbViewerPanel();
95 void SetDbAdapter(IDbAdapter* dbAdapter) { m_pDbAdapter = dbAdapter; }
96
97 void AddDbConnection(DbConnection* pDbCon) { m_pConnections->AddChild(pDbCon); }
98 void SetServer(wxString& server) { m_server = server; }
99 void OpenSQLiteFile(const wxFileName& fileName, bool openDefaultSQLPanel);
100
101 virtual void OnConnectClick(wxCommandEvent& event);
102 virtual void OnConnectUI(wxUpdateUIEvent& event);
103 virtual void OnItemActivate(wxTreeEvent& event);
104 virtual void OnRefreshClick(wxCommandEvent& event);
105 virtual void OnRefreshUI(wxUpdateUIEvent& event);
106 virtual void OnItemSelectionChange(wxTreeEvent& event);
107 virtual void OnDnDStart(wxTreeEvent& event);
108 virtual void OnItemRightClick(wxTreeEvent& event);
109 virtual void OnToolCloseClick(wxCommandEvent& event);
110 virtual void OnToolCloseUI(wxUpdateUIEvent& event);
111 virtual void OnShowThumbnail(wxCommandEvent& e);
112
113 void OnPageClosing(wxBookCtrlEvent& event);
114 void OnPageChanged(wxBookCtrlEvent& event);
115
116 void OnPopupClick(wxCommandEvent& evt);
117 void RefreshDbView();
118 void RemoveFrame(DbExplorerFrame* frame);
119 static void InitStyledTextCtrl(wxStyledTextCtrl* sci);
120
121 protected:
122 enum PanelType { Sql };
123 bool ImportDb(const wxString& sqlFile, Database* pDb);
124 wxString CreatePanelName(Table* t);
125 wxString CreatePanelName(View* v);
126 wxString CreatePanelName(Database* d);
127 bool DoSelectPage(const wxString& page);
128 void AddEditorPage(wxWindow* page, const wxString& name);
129 };
130
131 #endif // DBEXPLORERPANEL_H