2
* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
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
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.
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
20
#ifndef _WB_COMMAND_UI_H_
21
#define _WB_COMMAND_UI_H_
24
#include "wb_context.h"
25
#include "base/trackable.h"
39
// Manager menus and toolbars.
40
class MYSQLWBBACKEND_PUBLIC_FUNC CommandUI: public base::trackable
42
friend class WBContextUI;
46
boost::function<void ()> execute;
47
boost::function<bool ()> validate;
52
grt::ListRef<app_ShortcutItem> _shortcuts;
54
std::map<std::string, BuiltinCommand> _builtin_commands;
55
boost::signals2::signal<void ()> _validate_edit_menu_items;
57
bool validate_command_item(const app_CommandItemRef &item, const ParsedCommand &cmd);
58
void update_item_state(const app_ToolbarItemRef &item, const ParsedCommand &cmd, mforms::ToolBarItem *tb_item);
59
void update_item_state(const app_CommandItemRef &item, const ParsedCommand &cmd, mforms::MenuItem *menu_item);
61
void append_shortcut_items(const grt::ListRef<app_ShortcutItem> &plist, const std::string &context,
62
std::vector<WBShortcut> *items);
64
bool execute_builtin_command(const std::string &name);
65
bool validate_builtin_command(const std::string &name);
66
bool validate_plugin_command(const std::string &name);
69
void add_recent_menu(mforms::MenuItem *parent);
70
void add_plugins_menu_items(mforms::MenuItem *parent, const std::string &group);
71
void add_plugins_menu(mforms::MenuItem *parent, const std::string &context);
72
void add_menu_items_for_context(const std::string &context, mforms::MenuItem *parent, const app_MenuItemRef &menu);
74
void menu_will_show(mforms::MenuItem *parent);
76
mforms::MenuBar *create_menubar_for_context(const std::string &context);
78
void revalidate_edit_menu_items();
79
boost::signals2::signal<void ()>* signal_validate_edit_menu_items() { return &_validate_edit_menu_items; }
81
CommandUI(WBContext *wb);
83
mforms::ToolBar *create_toolbar(const std::string &toolbar_file);
84
mforms::ToolBar *create_toolbar(const std::string &toolbar_file, const boost::function<void (std::string)> &activate_slot);
88
void activate_command(const std::string &command);
89
bool activate_command(const std::string &command, bec::ArgumentPool argpool);
91
std::vector<WBShortcut> get_shortcuts_for_context(const std::string &context);
93
void add_frontend_commands(const std::list<std::string> &commands);
94
void remove_frontend_commands(const std::list<std::string> &commands);
95
void add_builtin_command(const std::string &name,
96
const boost::function<void ()> &slot,
97
const boost::function<bool ()> &validate= boost::function<bool ()>());
98
void remove_builtin_command(const std::string &name);
103
#endif /* _WB_COMMAND_UI_H_ */