File: grtdb_connect_panel.h

package info (click to toggle)
mysql-workbench 6.2.3%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 102,612 kB
  • ctags: 84,593
  • sloc: ansic: 804,682; cpp: 438,759; yacc: 59,129; python: 54,293; xml: 48,851; sql: 5,512; objc: 1,414; makefile: 505; sh: 455; java: 237; ruby: 6; perl: 5; php: 1
file content (176 lines) | stat: -rw-r--r-- 5,568 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
/* 
 * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; version 2 of the
 * License.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301  USA
 */

#ifndef _GRTDBCONNECTPANEL_H_
#define _GRTDBCONNECTPANEL_H_

#include <mforms/box.h>
#include <mforms/table.h>
#include <mforms/label.h>
#include <mforms/textentry.h>
#include <mforms/selector.h>
#include <mforms/panel.h>
#include <mforms/tabview.h>

#include "db_conn_be.h"

namespace grtui
{

enum {
  DbConnectPanelShowConnectionCombo = (1 << 0),
  DbConnectPanelShowRDBMSCombo = (1<<1),
  DbConnectPanelShowManageConnections = (1<<2),
  DbConnectPanelHideConnectionName = (1<<3),
  DbConnectPanelDontSetDefaultConnection = (1<<4),
  DbConnectPanelDefaults = (DbConnectPanelShowConnectionCombo | DbConnectPanelShowManageConnections)
};
typedef int DbConnectPanelFlags;
  
class WBPUBLICBACKEND_PUBLIC_FUNC DbConnectPanel : public mforms::Box
{
public:
  DbConnectPanel(DbConnectPanelFlags = DbConnectPanelDefaults);
  virtual ~DbConnectPanel();

  void init(const db_mgmt_ManagementRef &mgmt, const grt::ListRef<db_mgmt_Rdbms> &allowed_rdbms, const db_mgmt_ConnectionRef &default_conn=db_mgmt_ConnectionRef());
  void init(const db_mgmt_ManagementRef &mgmt, const db_mgmt_ConnectionRef &default_conn=db_mgmt_ConnectionRef());
  
  void init(DbConnection *conn, const db_mgmt_ConnectionRef &default_conn=db_mgmt_ConnectionRef());

  static bool is_connectable_driver_type(db_mgmt_DriverRef driver);

  void set_default_host_name(const std::string &host, bool update=false);
  std::string default_host_name() { return _default_host_name; }
  
  void set_skip_schema_name(bool flag);

  void set_enabled(bool flag);
  
  mforms::TextEntry *get_name_entry() { return  &_name_entry; }

  DbConnection *get_be() const { return _connection; }

  void set_active_stored_conn(const std::string &name);
  void set_active_stored_conn(db_mgmt_ConnectionRef connection);

  db_mgmt_ConnectionRef get_default_connection() { return _anonymous_connection; }
  
  db_mgmt_ConnectionRef get_connection();
  void set_connection(const db_mgmt_ConnectionRef& conn);
  
  boost::signals2::signal<void (std::string,bool)>* signal_validation_state_changed() { return &_signal_validation_state_changed; }

  void save_connection_as(const std::string &name);
  
  void set_driver_changed_cb(const boost::function<void (db_mgmt_DriverRef)> &cb) {_driver_changed_cb = cb;};
  
  bool test_connection();
  
  db_mgmt_RdbmsRef selected_rdbms();
  db_mgmt_DriverRef selected_driver();
protected:
  grt::ListRef<db_mgmt_Rdbms> _allowed_rdbms;
  DbConnection *_connection;
  db_mgmt_ConnectionRef _anonymous_connection;
  std::map<std::string, grt::DictRef> _parameters_per_driver;
  std::string _default_host_name;

  mforms::Table _table;
  mforms::Label _label1;
  mforms::Label _label2;
  mforms::Label _label3;
  
  mforms::TextEntry _name_entry;
  mforms::Selector _stored_connection_sel;
  mforms::Selector _rdbms_sel;
  mforms::Selector _driver_sel;
  mforms::Label _desc1;
  mforms::Label _desc2;
  mforms::Label _desc3;
  
  mforms::TabView _tab;

  mforms::Panel _params_panel;
  mforms::Table *_params_table;
  std::vector<mforms::Box*> _param_rows;

  mforms::Panel _ssl_panel;
  mforms::Table *_ssl_table;
  std::vector<mforms::Box*> _ssl_rows;

  mforms::Panel _advanced_panel;
  mforms::Table *_advanced_table;
  std::vector<mforms::Box*> _advanced_rows;

  mforms::Panel _options_panel;
  mforms::Table *_options_table;
  std::vector<mforms::Box*> _options_rows;

  std::list<mforms::View*> _views;
  mforms::Label _warning;

private:
  void save_param(const std::string& name, const grt::StringRef& param);
  std::string get_saved_param(const std::string& name);
  
  boost::signals2::signal<void (std::string,bool)> _signal_validation_state_changed;
  
  bool _initialized;
  bool _delete_connection_be;
  bool _show_connection_combo;
  bool _show_manage_connections;
  bool _allow_edit_connections;
  bool _updating;
  bool _skip_schema_name;
  bool _dont_set_default_connection;
  std::string _last_validation;

  void suspend_view_layout(bool flag);
  void begin_layout();
  void end_layout();
  void create_control(DbDriverParam *driver_param, ControlType ctrl_type, const base::ControlBounds& bounds,
    const std::string &caption);

  void change_active_rdbms();
  void change_active_driver();
  
  void set_keychain_password(DbDriverParam *param, bool clear);
  
  void param_value_changed(mforms::View *sender);
  void enum_param_value_changed(mforms::Selector *sender, std::vector<std::string> options);
  
  void refresh_stored_connections();
  
  void change_active_stored_conn();
  void reset_stored_conn_list();

  grt::ListRef<db_mgmt_Connection> connection_list();
  
  db_mgmt_ConnectionRef open_editor();
  
  grt::StringListRef get_enum_values(db_mgmt_DriverParameterRef param);
  
  boost::function<void (const db_mgmt_DriverRef &)> _driver_changed_cb;
};

};


#endif /* _GRTDBCONNECTFORM_H_ */