~ubuntu-branches/ubuntu/quantal/mysql-workbench/quantal

« back to all changes in this revision

Viewing changes to frontend/common/new_server_instance_wizard.h

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2012-03-01 21:57:30 UTC
  • Revision ID: package-import@ubuntu.com-20120301215730-o7y8av8y38n162ro
Tags: upstream-5.2.38+dfsg
ImportĀ upstreamĀ versionĀ 5.2.38+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU General Public License as
 
6
 * published by the Free Software Foundation; version 2 of the
 
7
 * License.
 
8
 * 
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
12
 * GNU General Public License for more details.
 
13
 * 
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 
17
 * 02110-1301  USA
 
18
 */
 
19
 
 
20
#ifndef _NEW_SERVER_INSTANCE_WIZARD_H_
 
21
#define _NEW_SERVER_INSTANCE_WIZARD_H_
 
22
 
 
23
#include "grt/common.h"
 
24
#include "grtui/grt_wizard_form.h"
 
25
#include "grtui/wizard_finished_page.h"
 
26
#include "grtui/wizard_progress_page.h"
 
27
#include "grtui/grtdb_connect_panel.h"
 
28
 
 
29
#include "workbench/wb_context.h"
 
30
#include "workbench/wb_module.h"
 
31
 
 
32
#include "cppdbc.h"
 
33
 
 
34
#include "mforms/fs_object_selector.h"
 
35
#include "mforms/radiobutton.h"
 
36
#include "mforms/checkbox.h"
 
37
 
 
38
/**
 
39
 * Implementation of a wizard to create a new server instance. This process involves selecting a proper connection
 
40
 * of the target operating system, path selection of the config file or what monitoring commands must be executed.
 
41
 */
 
42
 
 
43
using namespace grtui;
 
44
using namespace mforms;
 
45
 
 
46
class NewServerInstanceWizard;
 
47
 
 
48
class NewServerInstancePage : public WizardPage
 
49
{
 
50
public:
 
51
  NewServerInstancePage(WizardForm *form, const std::string &pageid);
 
52
protected:
 
53
  NewServerInstanceWizard* wizard();
 
54
};
 
55
 
 
56
class HostMachinePage : public NewServerInstancePage
 
57
{
 
58
public:
 
59
  HostMachinePage(WizardForm* host, wb::WBContext *wb);
 
60
protected:
 
61
  virtual bool advance();
 
62
 
 
63
  void host_selection_changed();
 
64
  void refresh_connections();
 
65
private:
 
66
  wb::WBContext *_context;
 
67
  Box _top_box;
 
68
 
 
69
  Panel _top_border;
 
70
  Label _intro_label;
 
71
  Label _host_description;
 
72
  RadioButton _localhost_button;
 
73
  RadioButton _networkhost_button;
 
74
  RadioButton _dbhost_button;
 
75
  Box _ip_address_block;
 
76
  Label _ip_address_label;
 
77
  TextEntry _ip_address;
 
78
  Label _ip_address_help;
 
79
  Box _dbhost_block;
 
80
  Selector _dbhost_selector;
 
81
};
 
82
 
 
83
class HostAndRemoteTypePage : public NewServerInstancePage
 
84
{
 
85
public:
 
86
  HostAndRemoteTypePage(WizardForm* host);
 
87
protected:
 
88
  virtual void enter(bool advancing);
 
89
  virtual bool advance();
 
90
  virtual bool skip_page();
 
91
 
 
92
  void refresh_profile_list();
 
93
  void toggle_remote_admin();
 
94
private:
 
95
  Panel _management_type_panel; // Border.
 
96
  Box _management_type_box;     // Content.
 
97
  Panel _os_panel; // Border.
 
98
  Box _os_box;     // Content.
 
99
  
 
100
  Label _os_description;
 
101
  
 
102
  Table _params;
 
103
  Label _os_label;
 
104
  Selector _os_selector;
 
105
  
 
106
  Label _type_label;
 
107
  Selector _type_selector;
 
108
  
 
109
  mforms::RadioButton _no_remote_admin;
 
110
  mforms::RadioButton _win_remote_admin;
 
111
  mforms::RadioButton _ssh_remote_admin;
 
112
 
 
113
  std::map<std::string, std::vector<std::pair<std::string,std::string> > > _presets;
 
114
};
 
115
 
 
116
class SSHConfigurationPage : public NewServerInstancePage
 
117
{
 
118
public:
 
119
  SSHConfigurationPage(WizardForm* host);
 
120
protected:
 
121
  void use_ssh_key_changed();
 
122
  
 
123
  virtual void enter(bool advancing);
 
124
  virtual bool advance();
 
125
  virtual void leave(bool advancing);
 
126
  virtual bool skip_page();
 
127
 
 
128
private:
 
129
  Label _main_description1;
 
130
  Label _main_description2;
 
131
 
 
132
  Table _ssh_settings_table;
 
133
  
 
134
  Box _indent;
 
135
  Label _host_name_label;
 
136
  TextEntry _host_name;
 
137
  Label _port_label;
 
138
  TextEntry _port;
 
139
 
 
140
  Label _username_label;
 
141
  TextEntry _username;
 
142
 
 
143
  CheckBox _use_ssh_key;
 
144
  Label _ssh_path_label;
 
145
  TextEntry _ssh_key_path;
 
146
  Button _ssh_key_browse_button;
 
147
  FsObjectSelector* _file_selector;
 
148
};
 
149
 
 
150
class WindowsManagementPage : public NewServerInstancePage
 
151
{
 
152
public:
 
153
  WindowsManagementPage(WizardForm* host, wb::WBContext* context);
 
154
protected:
 
155
  void refresh_config_path();
 
156
 
 
157
  virtual void enter(bool advancing);
 
158
  virtual void leave(bool advancing);
 
159
 
 
160
  virtual bool advance();
 
161
  virtual bool skip_page();
 
162
private:
 
163
  wb::WBContext* _context;
 
164
  std::vector<std::string> _config_paths;
 
165
  std::vector<std::string> _service_names;
 
166
 
 
167
  Table _layout_table;
 
168
  Box _indent;
 
169
 
 
170
  Label _main_description1;
 
171
  Label _main_description2;
 
172
 
 
173
  Label _service_label;
 
174
  TextEntry _service_name;
 
175
  Selector _service_selector;
 
176
  Label _progress_label;
 
177
 
 
178
  Label _config_path_label;
 
179
  TextEntry _config_path;
 
180
  Button _browse_button;
 
181
  FsObjectSelector* _file_selector;
 
182
};
 
183
 
 
184
class TestHostMachineSettingsPage : public WizardProgressPage
 
185
{
 
186
public:
 
187
  TestHostMachineSettingsPage(WizardForm* host);
 
188
 
 
189
  virtual void enter(bool advance);
 
190
  virtual void leave(bool advancing);
 
191
protected:  
 
192
  bool connect_to_host();
 
193
  bool find_config_file();
 
194
  bool find_error_files();
 
195
  bool check_admin_commands();
 
196
  virtual void tasks_finished(bool success);
 
197
  virtual bool skip_page();
 
198
 
 
199
  NewServerInstanceWizard* wizard();
 
200
private:
 
201
  TaskRow* _connect_task;
 
202
  TaskRow* _commands_task;
 
203
};
 
204
 
 
205
class DatabaseServerPage : public NewServerInstancePage
 
206
{
 
207
public:
 
208
  DatabaseServerPage(WizardForm* host, wb::WBContext* context);
 
209
protected:
 
210
  virtual void enter(bool advancing);
 
211
  virtual bool advance();
 
212
  virtual void leave(bool advancing);
 
213
  virtual bool skip_page();
 
214
private:
 
215
  Label _description;
 
216
 
 
217
  grtui::DbConnectPanel _panel;
 
218
  db_mgmt_ConnectionRef _connection;
 
219
 
 
220
  mforms::TextEntry *_conn_name;
 
221
 
 
222
  wb::WBContext* _context;
 
223
};
 
224
 
 
225
class TestDatabaseSettingsPage : public WizardProgressPage
 
226
{
 
227
public:
 
228
  TestDatabaseSettingsPage(WizardForm* host);
 
229
  virtual void enter(bool advancing);
 
230
protected:
 
231
  sql::ConnectionWrapper _dbc_conn;
 
232
  std::string _message;
 
233
  bool open_connection();
 
234
  virtual void tasks_finished(bool success);
 
235
  bool get_server_version();
 
236
  bool get_server_platform();
 
237
 
 
238
  NewServerInstanceWizard* wizard();
 
239
};
 
240
 
 
241
class ReviewPage : public NewServerInstancePage
 
242
{
 
243
public:
 
244
  ReviewPage(WizardForm* host);
 
245
protected:
 
246
  virtual void enter(bool advancing);
 
247
  virtual bool skip_page();
 
248
  virtual void leave(bool advancing);
 
249
private:
 
250
  Label _description;
 
251
  Table _content;
 
252
  Label _label;
 
253
 
 
254
  TextBox _text;
 
255
 
 
256
  CheckBox _customize_check;
 
257
};
 
258
 
 
259
class PathsPage : public NewServerInstancePage
 
260
{
 
261
public:
 
262
  PathsPage(WizardForm* host, wb::WBContext* context);
 
263
protected:
 
264
  virtual void enter(bool advancing);
 
265
  virtual bool advance();
 
266
  virtual bool skip_page();
 
267
  void browse_remote_config_file();
 
268
  void test_path();
 
269
  void test_section();
 
270
private:
 
271
  wb::WBContext* _context;
 
272
  
 
273
  Label _description;
 
274
  Table _content;
 
275
 
 
276
  Label _version_label;
 
277
  TextEntry _version;
 
278
  
 
279
  Label _config_path_label;
 
280
  TextEntry _config_path;
 
281
  Button _browse_button;
 
282
  FsObjectSelector* _file_selector;
 
283
  Button _test_config_path_button;
 
284
  Label _test_config_path_description;
 
285
  
 
286
  Label _section_name_label;
 
287
  TextEntry _section_name;
 
288
  Button _test_section_button;
 
289
  Label _test_section_description;
 
290
};
 
291
 
 
292
class CommandsPage : public NewServerInstancePage
 
293
{
 
294
public:
 
295
  CommandsPage(WizardForm* host);
 
296
protected:
 
297
  virtual void enter(bool advancing);
 
298
  virtual bool advance();
 
299
  virtual bool skip_page();
 
300
private:
 
301
  Label _description;
 
302
  Table _content;
 
303
  
 
304
  Label _start_label;
 
305
  TextEntry _start_command;
 
306
  Label _stop_label;
 
307
  TextEntry _stop_command;
 
308
  Label _status_label;
 
309
  TextEntry _status_command;
 
310
  
 
311
  CheckBox _use_sudo;
 
312
};
 
313
 
 
314
class CompleteSetupPage : public NewServerInstancePage
 
315
{
 
316
public:
 
317
  CompleteSetupPage(WizardForm* host, wb::WBContext* context);
 
318
protected:
 
319
  virtual bool advance();
 
320
  virtual void enter(bool advancing);  
 
321
  virtual void leave(bool advancing);
 
322
  void create_instance();
 
323
  virtual bool next_closes_wizard() { return true; }
 
324
  virtual std::string close_caption() const { return finish_caption(); }
 
325
private:
 
326
  wb::WBContext* _context;
 
327
 
 
328
  Label _description;
 
329
  Box _instance_name_box;
 
330
  Label _instance_name_label;
 
331
  TextEntry _instance_name;
 
332
};
 
333
 
 
334
class NewServerInstanceWizard : public WizardForm
 
335
{
 
336
public:
 
337
  NewServerInstanceWizard(wb::WBContext* context);
 
338
  ~NewServerInstanceWizard();
 
339
 
 
340
  db_mgmt_ServerInstanceRef assemble_server_instance();
 
341
  grt::ValueRef test_setting_grt(grt::GRT *grt, const std::string &name);
 
342
  
 
343
  void load_defaults();
 
344
  std::string get_server_info(const std::string& key);
 
345
  
 
346
  wb::WBContext* wb() { return _context; }
 
347
 
 
348
  bool is_admin_enabled();
 
349
  bool is_local();
 
350
  bool test_setting(const std::string &name, std::string &detail);
 
351
 
 
352
protected:
 
353
  wb::WBContext* _context;
 
354
  db_mgmt_ServerInstanceRef _instance; // The server instance we are working on.
 
355
 
 
356
private:
 
357
  HostMachinePage* _host_machine_page;
 
358
  HostAndRemoteTypePage* _os_page;
 
359
  SSHConfigurationPage* _ssh_configuration_page;
 
360
  WindowsManagementPage*  _windows_connection_page;
 
361
  TestHostMachineSettingsPage* _test_host_machine_settings_page;
 
362
  ReviewPage* _review_page;
 
363
  DatabaseServerPage* _database_server_page;
 
364
  TestDatabaseSettingsPage* _test_database_settings_page;
 
365
  PathsPage* _paths_page;
 
366
  CommandsPage* _commands_page;
 
367
  CompleteSetupPage* _complete_setup_page;
 
368
};
 
369
 
 
370
#endif // _NEW_SERVER_INSTANCE_WIZARD_H_