File: new_server_instance_wizard.h

package info (click to toggle)
mysql-workbench 6.3.8%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 113,932 kB
  • ctags: 87,814
  • sloc: ansic: 955,521; cpp: 427,465; python: 59,728; yacc: 59,129; xml: 54,204; sql: 7,091; objc: 965; makefile: 638; sh: 613; java: 237; perl: 30; ruby: 6; php: 1
file content (316 lines) | stat: -rw-r--r-- 7,730 bytes parent folder | download | duplicates (2)
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
/* 
 * Copyright (c) 2009, 2013, 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 _NEW_SERVER_INSTANCE_WIZARD_H_
#define _NEW_SERVER_INSTANCE_WIZARD_H_

#include "grt/common.h"
#include "grtui/grt_wizard_form.h"
#include "grtui/wizard_finished_page.h"
#include "grtui/wizard_progress_page.h"
#include "grtui/grtdb_connect_panel.h"

#include "workbench/wb_context.h"
#include "workbench/wb_module.h"

#include "cppdbc.h"

#include "mforms/fs_object_selector.h"
#include "mforms/radiobutton.h"
#include "mforms/checkbox.h"

/**
 * Implementation of a wizard to set up remote management for a given connection.
 */

using namespace grtui;
using namespace mforms;

class NewServerInstanceWizard;

class NewServerInstancePage : public WizardPage
{
public:
  NewServerInstancePage(WizardForm *form, const std::string &pageid);
protected:
  NewServerInstanceWizard* wizard();
};

class IntroductionPage : public WizardPage
{
public:
  IntroductionPage(WizardForm *form);
};

class TestDatabaseSettingsPage : public WizardProgressPage
{
public:
  TestDatabaseSettingsPage(WizardForm* host);
  virtual void enter(bool advancing);
protected:
  sql::ConnectionWrapper _dbc_conn;
  std::string _message;
  bool open_connection();
  virtual void tasks_finished(bool success);
  bool get_server_version();
  bool get_server_platform();

  NewServerInstanceWizard* wizard();
};

class HostAndRemoteTypePage : public NewServerInstancePage
{
public:
  HostAndRemoteTypePage(WizardForm* host);
protected:
  virtual void enter(bool advancing);
  virtual bool advance();
  virtual bool skip_page();

  void refresh_profile_list();
  void toggle_remote_admin();
private:
  Panel _management_type_panel; // Border.
  Box _management_type_box;     // Content.
  Panel _os_panel; // Border.
  Box _os_box;     // Content.
  
  Label _os_description;
  
  Table _params;
  Label _os_label;
  Selector _os_selector;
  
  Label _type_label;
  Selector _type_selector;
  
  mforms::RadioButton _win_remote_admin;
  mforms::RadioButton _ssh_remote_admin;

  std::map<std::string, std::vector<std::pair<std::string,std::string> > > _presets;
};

class SSHConfigurationPage : public NewServerInstancePage
{
public:
  SSHConfigurationPage(WizardForm* host);
protected:
  void use_ssh_key_changed();
  
  virtual void enter(bool advancing);
  virtual bool advance();
  virtual void leave(bool advancing);
  virtual bool skip_page();

private:
  Label _main_description1;
  Label _main_description2;

  Table _ssh_settings_table;
  
  Box _indent;
  Label _host_name_label;
  TextEntry _host_name;
  Label _port_label;
  TextEntry _port;

  Label _username_label;
  TextEntry _username;

  CheckBox _use_ssh_key;
  Label _ssh_path_label;
  TextEntry _ssh_key_path;
  Button _ssh_key_browse_button;
  FsObjectSelector* _file_selector;
};

class WindowsManagementPage : public NewServerInstancePage
{
public:
  WindowsManagementPage(WizardForm* host, wb::WBContext* context);
protected:
  void refresh_config_path();

  virtual void enter(bool advancing);
  virtual void leave(bool advancing);

  virtual bool advance();
  virtual bool skip_page();
private:
  wb::WBContext* _context;
  std::vector<std::string> _config_paths;
  std::vector<std::string> _service_names;

  Table _layout_table;
  Box _indent;

  Label _main_description1;
  Label _main_description2;

  Label _service_label;
  TextEntry _service_name;
  Selector _service_selector;
  Label _progress_label;

  Label _config_path_label;
  TextEntry _config_path;
  Button _browse_button;
  FsObjectSelector* _file_selector;
};

class TestHostMachineSettingsPage : public WizardProgressPage
{
public:
  TestHostMachineSettingsPage(WizardForm* host);

  virtual void enter(bool advance);
  virtual void leave(bool advancing);
protected:  
  bool connect_to_host();
  bool find_config_file();
  bool find_error_files();
  bool check_admin_commands();
  virtual void tasks_finished(bool success);
  virtual bool skip_page();

  NewServerInstanceWizard* wizard();
private:
  TaskRow* _connect_task;
  TaskRow* _commands_task;
};

class ReviewPage : public NewServerInstancePage
{
public:
  ReviewPage(WizardForm* host);
protected:
  virtual void enter(bool advancing);
  virtual void leave(bool advancing);
  virtual bool skip_page();
  virtual bool next_closes_wizard();
  virtual std::string close_caption() const { return finish_caption(); }

  void customize_changed();
private:
  Label _description;
  Table _content;
  Label _label;

  TextBox _text;

  CheckBox _customize_check;
};

class PathsPage : public NewServerInstancePage
{
public:
  PathsPage(WizardForm* host, wb::WBContext* context);
protected:
  virtual void enter(bool advancing);
  virtual bool advance();
  virtual bool skip_page();
  void browse_remote_config_file();
  void test_path();
  void test_section();
private:
  wb::WBContext* _context;
  
  Label _description;
  Table _content;

  Label _version_label;
  TextEntry _version;
  
  Label _config_path_label;
  TextEntry _config_path;
  Button _browse_button;
  FsObjectSelector* _file_selector;
  Button _test_config_path_button;
  Label _test_config_path_description;
  
  Label _section_name_label;
  TextEntry _section_name;
  Button _test_section_button;
  Label _test_section_description;
};

class CommandsPage : public NewServerInstancePage
{
public:
  CommandsPage(WizardForm* host);
protected:
  virtual void enter(bool advancing);
  virtual void leave(bool advancing);
  virtual bool advance();
  virtual bool skip_page();
  virtual bool next_closes_wizard() { return true; }
  virtual std::string close_caption() const { return finish_caption(); }

private:
  Label _description;
  Table _content;
  
  Label _start_label;
  TextEntry _start_command;
  Label _stop_label;
  TextEntry _stop_command;
  
  CheckBox _use_sudo;
};

class NewServerInstanceWizard : public WizardForm
{
public:
  NewServerInstanceWizard(wb::WBContext* context, db_mgmt_ConnectionRef connection);
  ~NewServerInstanceWizard();

  db_mgmt_ServerInstanceRef assemble_server_instance();
  grt::ValueRef test_setting_grt(grt::GRT *grt, const std::string &name);
  
  void load_defaults();
  std::string get_server_info(const std::string& key);
  
  wb::WBContext* wb() { return _context; }

  bool is_admin_enabled();
  bool is_local();
  bool test_setting(const std::string &name, std::string &detail);

  void create_instance();

protected:
  wb::WBContext* _context;

  db_mgmt_ConnectionRef _connection;   // The connection for which we are configuring the server instance.
  db_mgmt_ServerInstanceRef _instance; // The server instance we are working on.

private:
  IntroductionPage *_introduction_page;
  TestDatabaseSettingsPage *_test_database_settings_page;
  HostAndRemoteTypePage* _os_page;
  SSHConfigurationPage* _ssh_configuration_page;
  WindowsManagementPage*  _windows_connection_page;
  TestHostMachineSettingsPage* _test_host_machine_settings_page;
  ReviewPage* _review_page;
  PathsPage* _paths_page;
  CommandsPage* _commands_page;

};

#endif // _NEW_SERVER_INSTANCE_WIZARD_H_