File: wb_context_ui.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 (221 lines) | stat: -rw-r--r-- 7,092 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
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
/*
 * Copyright (c) 2008, 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 _WB_CONTEXT_UI_H_
#define _WB_CONTEXT_UI_H_

// WB application functionality for UI

#include "wb_backend_public_interface.h"
#include "base/trackable.h"
#include "base/notifications.h"

#include "grts/structs.app.h"
#include "grts/structs.db.mgmt.h"
#include "home_screen.h" // Needed for enums. Remove and forward declare the enums when C++11 is available.

namespace bec 
{
  class ValueTreeBE;
  class ValueInspectorBE;
  class BaseEditor;
};

namespace mdc {
  class CanvasView;
}

class GRTShellWindow;
class OutputView;
class PluginInstallWindow;
class AddOnDownloadWindow;

namespace wb {
  
  class WBContext;
  struct WBFrontendCallbacks;
  struct WBOptions;
  struct WBPaperSize;

  class CommandUI;
  class OverviewBE;
  class PhysicalOverviewBE;
  class HistoryTreeBE;
  class DiagramOptionsBE;

  class ModelDiagramForm;

  class HomeScreen;

  // this class contains functionality that the UI needs,
  // like menu/toolbar access, special form backends etc

  class MYSQLWBBACKEND_PUBLIC_FUNC WBContextUI : public base::trackable
  {
  public:
    WBContextUI(bool verbose);
    virtual ~WBContextUI();

    bool init(WBFrontendCallbacks *callbacks, WBOptions *options);
    
    // must be called when the frontend window is already on screen
    void init_finish(WBOptions *options);
    
    void finalize();

    bool request_quit();
    void perform_quit();
    bool is_quitting() { return _quitting; };
    
    void reset();

    WBContext *get_wb() { return _wb; }
    CommandUI *get_command_ui() { return _command_ui; }

    // form/panel backends
    PhysicalOverviewBE *get_physical_overview();

    bec::ValueInspectorBE *create_inspector_for_selection(bec::UIForm *form, std::vector<std::string> &items);
    bec::ValueInspectorBE *create_inspector_for_selection(std::vector<std::string> &items);

    std::string get_description_for_selection(bec::UIForm *form, grt::ListRef<GrtObject> &activeObjList, std::vector<std::string> &items);
    std::string get_description_for_selection(grt::ListRef<GrtObject> &activeObjList, std::vector<std::string> &items);
    void set_description_for_selection(const grt::ListRef<GrtObject> &objList, const std::string &val);

    DiagramOptionsBE *create_diagram_options_be(mdc::CanvasView *view);

    GRTShellWindow *get_shell_window();

    std::string get_active_diagram_info();
    
    void activate_figure(const grt::ValueRef &value);
    
    // utility functions for user preferences
    void get_doc_properties(std::string& caption, std::string& version, std::string& author, std::string& project, std::string& date_created, std::string& date_changed, std::string& description);
    void set_doc_properties(const std::string &caption, const std::string &version, const std::string &author, const std::string &project, const std::string &date_created, const std::string &date_changed, const std::string &description);

    std::list<WBPaperSize> get_paper_sizes(bool descr_in_inches);
    bool add_paper_size(const std::string &name, double width, double height,
                      bool margins, double margin_top, double margin_bottom,
                      double margin_left, double margin_right);

    std::vector<std::string> get_wb_options_keys(const std::string &model);

    grt::DictRef get_model_options(const std::string &model_id);

    bool get_wb_options_value(const std::string &model, const std::string &key, std::string &value);
    void set_wb_options_value(const std::string &model, const std::string &key, const std::string &value,
                              const grt::Type default_type= grt::AnyType);

    void discard_wb_model_options(const std::string &model);

    app_PageSettingsRef get_page_settings();


    // form management
    void register_form(bec::UIForm *form);

    void set_active_form(bec::UIForm *form);
    bec::UIForm *get_active_form();

    bec::UIForm *get_active_main_form();

    std::string get_active_context(bool main_context= true);

    boost::signals2::signal<void (bec::UIForm*)>* signal_form_change() { return &_form_change_signal; }

    // other functionality for UI
    std::string get_title();
    std::string get_document_name();

    //deprecated std::string get_diagram_path(const model_DiagramRef &diagram);

    void show_output();
    
    void refresh_home_connections(bool clear_state = true);
    void refresh_home_documents();
    void refresh_home_starters();

    bool start_plugin_install(const std::string &path);
    void start_plugin_net_install(const std::string &url);
    
  private:
    friend class WBContext;
    // for use by WBContext

    void load_app_options(bool update);

    void history_changed();

    void overview_selection_changed();
    friend class WBContextModel; // for these callbacks, remove once everythign is moved there

    static void *form_destroyed(void *data);

    void refresh_editor_cb(bec::BaseEditor *editor);

    void form_changed();
    void update_current_diagram(bec::UIForm *form);
    
    void add_backend_builtin_commands();

    void show_about();
    void show_home_screen();
    void show_web_page(const std::string& url, bool internal_browser);
    void show_help_index();
    void locate_log_file();
    void show_log_file();

    void handle_home_action(HomeScreenAction action, const grt::ValueRef &object);

    void remove_connection(const db_mgmt_ConnectionRef &connection);
    void handle_home_context_menu(const grt::ValueRef &object, const std::string &action);

    void start_plugin(const std::string& title, const std::string& command, bool force_external= false);
    
    static void home_action_callback(HomeScreenAction action, const grt::ValueRef &object, WBContextUI *self);
    
  private:
    WBContext *_wb;

    // special forms/panels
    GRTShellWindow *_shell_window;
    HomeScreen *_home_screen;
    OutputView *_output_view;
    AddOnDownloadWindow *_addon_download_window;
    PluginInstallWindow *_plugin_install_window;

    CommandUI *_command_ui;
        
    // form management
    bec::UIForm *_active_form;
    bec::UIForm *_active_main_form;

    boost::signals2::signal<void (bec::UIForm*)> _form_change_signal;
    
    
    bool _last_unsaved_changes_state;
    bool _initializing_home_screen;
    bool _quitting;
    bool _processing_action_open_connection;
  };
};


#endif