File: wb_context_sqlide.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-- 3,441 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) 2009, 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 _WBCONTEXT_SQLIDE_H_
#define _WBCONTEXT_SQLIDE_H_

#include "workbench/wb_backend_public_interface.h"
#include "grt/grt_manager.h"
#include "grts/structs.db.mgmt.h"
#include "grts/structs.app.h"
//#include "dialogs/search_replace.h"
#include <boost/weak_ptr.hpp>
#include "base/trackable.h"
#include "base/notifications.h"
#include "mforms/utilities.h"

class SqlEditorPanel;
class SqlEditorForm;

// Central point of management for SQLIDE (sql editor)
namespace wb 
{
  class WBContextUI;
  class CommandUI;
  
  class MYSQLWBBACKEND_PUBLIC_FUNC WBContextSQLIDE : public base::trackable, base::Observer
  {
    WBContextUI *_wbui;
    std::list<boost::weak_ptr<SqlEditorForm> > _open_editors;
    app_ToolbarRef _toolbar;

    mforms::TimeoutHandle _auto_save_handle;
    ssize_t _auto_save_interval;
    bool _auto_save_active;
    bool _option_change_signal_connected;
    
  public:
    WBContextSQLIDE(WBContextUI *wbui);
    virtual ~WBContextSQLIDE();
    void init();
    void finalize();
    
    static void detect_auto_save_files(const std::string &autosave_dir);
    static std::map<std::string, std::string> auto_save_sessions();
    
    boost::shared_ptr<SqlEditorForm> create_connected_editor(const db_mgmt_ConnectionRef &conn);

    WBContextUI *get_wbui() { return _wbui; }
    CommandUI *get_cmdui();
    bec::GRTManager *get_grt_manager();
    
    SqlEditorForm* get_active_sql_editor();

    bool activate_live_object(GrtObjectRef object);

    void open_document(const std::string &path);
    
    bool request_quit();

    void reconnect_editor(SqlEditorForm *editor);
    
    void editor_will_close(SqlEditorForm*); // to be called by SqlEditorForm

  public:
    void update_plugin_arguments_pool(bec::ArgumentPool &args);

    db_query_EditorRef get_grt_editor_object(SqlEditorForm *editor);
    std::list<boost::weak_ptr<SqlEditorForm> >* get_open_editors() { return &_open_editors; }
  private:
    void call_in_editor(void (SqlEditorForm::*method)());    
    void call_in_editor_str(void (SqlEditorForm::*method)(const std::string &arg), const std::string &arg);
    void call_in_editor_str2(void (SqlEditorForm::*method)(const std::string &arg1, bool arg2, bool arg3), const std::string &arg1, bool arg2, bool arg3);
    void call_in_editor_bool(void (SqlEditorForm::*method)(bool arg), bool arg);

    void call_in_editor_panel(void (SqlEditorPanel::*method)());
    
    bool auto_save_workspaces();
    void option_changed(grt::internal::OwnedDict*dict, bool, const std::string&key);
    
    virtual void handle_notification(const std::string &name, void *sender, base::NotificationInfo &info);
  };
};
                      
#endif