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
|
/*
* 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 _HOME_SCREEN_H_
#define _HOME_SCREEN_H_
#include "wb_backend_public_interface.h"
#include <ctime>
#include "base/notifications.h"
#include "mforms/appview.h"
#include "mforms/drawbox.h"
#include "grts/structs.app.h"
#include "grts/structs.db.mgmt.h"
#ifdef __APPLE__
#define HOME_TITLE_FONT "Helvetica Neue Light"
#define HOME_NORMAL_FONT "Helvetica Neue Light"
#define HOME_DETAILS_FONT "Helvetica Neue Light"
// Info font is only used on Mac.
#define HOME_INFO_FONT "Baskerville"
#elif defined(_WIN32)
#define HOME_TITLE_FONT "Segoe UI"
#define HOME_NORMAL_FONT "Segoe UI"
#define HOME_NORMAL_FONT_XP "Tahoma"
#define HOME_DETAILS_FONT "Segoe UI"
#else
#define HOME_TITLE_FONT "Tahoma"
#define HOME_NORMAL_FONT "Tahoma"
#define HOME_DETAILS_FONT "Helvetica"
#endif
#define HOME_TITLE_FONT_SIZE 20
#define HOME_SUBTITLE_FONT_SIZE 13
#define HOME_TILES_TITLE_FONT_SIZE 16
#define HOME_SMALL_INFO_FONT_SIZE 10
#define HOME_DETAILS_FONT_SIZE 12
#define TILE_DRAG_FORMAT "com.mysql.workbench-drag-tile-format"
class ShortcutSection;
class DocumentsSection;
namespace mforms
{
class Menu;
};
namespace wb
{
class ConnectionsSection;
/**
* Value to tell observers which action was triggered on the home screen.
*/
enum HomeScreenAction
{
ActionNone,
ActionShortcut,
ActionRemoveShortcut,
ActionOpenConnectionFromList,
ActionNewConnection,
ActionManageConnections,
ActionFilesWithConnection,
ActionMoveConnectionToGroup,
ActionMoveConnection,
ActionUpdateFabricConnections,
ActionSetupRemoteManagement,
ActionEditSQLScript,
ActionOpenEERModel,
ActionNewEERModel,
ActionOpenEERModelFromList,
ActionNewModelFromDB,
ActionNewModelFromScript,
};
enum HomeScreenMenuType
{
HomeMenuConnection,
HomeMenuConnectionGroup,
HomeMenuConnectionFabric,
HomeMenuConnectionGeneric,
HomeMenuDocumentModelAction,
HomeMenuDocumentModel,
HomeMenuDocumentSQLAction,
HomeMenuDocumentSQL,
};
typedef void (*home_screen_action_callback)(HomeScreenAction action, const grt::ValueRef &object, void* user_data);
class CommandUI;
struct HomeAccessibleButton : mforms::Accessible
{
std::string name;
std::string default_action;
base::Rect bounds;
boost::function <bool (int, int)> default_handler;
// ------ Accesibility Customized Methods -----
virtual std::string get_acc_name() { return name; }
virtual std::string get_acc_default_action() { return default_action;}
virtual Accessible::Role get_acc_role() { return mforms::Accessible::PushButton;}
virtual base::Rect get_acc_bounds() { return bounds;}
virtual void do_default_action()
{
if (default_handler)
default_handler((int)bounds.center().x, (int)bounds.center().y);
}
};
//--------------------------------------------------------------------------------------------------
/**
* This class implements the main (home) screen in MySQL Workbench, containing
* sections for connections, plugins and documents.
*/
class MYSQLWBBACKEND_PUBLIC_FUNC HomeScreen : public mforms::AppView, public base::Observer
{
private:
ShortcutSection *_shortcut_section;
ConnectionsSection *_connection_section;
DocumentsSection *_document_section;
std::string _pending_script; // The path to a script that should be opened next time a connection is opened.
db_mgmt_ManagementRef _rdbms;
home_screen_action_callback _callback;
void* _user_data;
void update_colors();
std::vector<db_mgmt_ConnectionRef> _oldAuthList;
public:
HomeScreen(CommandUI *cmdui, db_mgmt_ManagementRef rdbms);
virtual ~HomeScreen();
db_mgmt_ManagementRef rdbms() { return _rdbms; };
boost::function<void (grt::ValueRef, std::string)> handle_context_menu;
void set_callback(home_screen_action_callback callback, void* user_data);
void trigger_callback(HomeScreenAction action, const grt::ValueRef &object);
void cancel_script_loading();
void clear_shortcuts();
void add_shortcut(const grt::ValueRef &object, const std::string &icon_name);
void clear_connections(bool clear_state = true);
void add_connection(db_mgmt_ConnectionRef connection, const std::string &title,
const std::string &description, const std::string &user, const std::string &schema);
void oldAuthConnections(const std::vector<db_mgmt_ConnectionRef> &list);
void clear_documents();
void add_document(const grt::StringRef &path, const time_t &time, const std::string schemas,
long file_size);
void set_menu(mforms::Menu *menu, HomeScreenMenuType type);
void on_resize();
void setup_done();
virtual void handle_notification(const std::string &name, void *sender, base::NotificationInfo &info);
};
}
#endif // _HOME_SCREEN_H_
|