File: sql_script_run_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 (100 lines) | stat: -rw-r--r-- 2,974 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
/* 
 * 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 _SQL_SCRIPT_RUN_WIZARD_H_
#define _SQL_SCRIPT_RUN_WIZARD_H_


#include "wbpublic_public_interface.h"
#include "grtui/grt_wizard_plugin.h"
#include "grtui/wizard_progress_page.h"
#include "grtui/wizard_finished_page.h"

namespace mforms {
  class CodeEditor;
  class Selector;
}

class WBPUBLICBACKEND_PUBLIC_FUNC SqlScriptReviewPage : public grtui::WizardPage
{
public:
  SqlScriptReviewPage(grtui::WizardForm *form, GrtVersionRef version, std::string algorithm, std::string lock);
  virtual ~SqlScriptReviewPage();

protected:
  virtual void enter(bool advancing);
  virtual bool advance();
  virtual std::string next_button_caption();

  void option_changed();
private:
  mforms::Box _box;
  mforms::Label _page_heading;
  mforms::CodeEditor *_sql_editor;
  mforms::Selector *_algorithm_selector;
  mforms::Selector *_lock_selector;
};


class WBPUBLICBACKEND_PUBLIC_FUNC SqlScriptApplyPage : public grtui::WizardProgressPage
{
private:
  std::string _log;
  int _err_count;
  mforms::Button *_abort_btn;

  void abort_exec();

  grt::ValueRef do_execute_sql_script(const std::string &sql_script);
public:
  SqlScriptApplyPage(grtui::WizardForm *form);
  int on_error(long long err_code, const std::string& err_msg, const std::string& err_sql);
  int on_exec_progress(float progress);
  int on_exec_stat(long success_count, long err_count);
  boost::function<void (const std::string &)> apply_sql_script;
  bool execute_sql_script();
  virtual std::string next_button_caption();
  virtual bool allow_back();
  virtual bool allow_next();
  virtual bool allow_cancel();
  virtual void enter(bool advancing);
}; 


class WBPUBLICBACKEND_PUBLIC_FUNC SqlScriptRunWizard : public grtui::WizardForm
{
public:
  SqlScriptReviewPage *review_page;
  SqlScriptApplyPage *apply_page;
public:
  SqlScriptRunWizard(bec::GRTManager *grtm, GrtVersionRef version, std::string algorithm, std::string lock);

  bool has_errors();
  bool applied();

  boost::function<void ()> abort_apply;

  // Used by the wizard if an option changed.
  // Parameters: online DDL algorithm and lock.
  boost::function<std::string (const std::string&, const std::string&)> regenerate_script;
};


#endif /* _SQL_SCRIPT_RUN_WIZARD_H_ */