~ubuntu-branches/ubuntu/quantal/mysql-workbench/quantal

« back to all changes in this revision

Viewing changes to backend/wbprivate/model/wb_component.h

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2012-03-01 21:57:30 UTC
  • Revision ID: package-import@ubuntu.com-20120301215730-o7y8av8y38n162ro
Tags: upstream-5.2.38+dfsg
ImportĀ upstreamĀ versionĀ 5.2.38+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
 
3
 *
 
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
 
7
 * License.
 
8
 * 
 
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.
 
13
 * 
 
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
 
17
 * 02110-1301  USA
 
18
 */
 
19
 
 
20
#ifndef _WB_COMPONENT_H_
 
21
#define _WB_COMPONENT_H_
 
22
 
 
23
#include "workbench/wb_context.h"
 
24
#include "base/trackable.h"
 
25
 
 
26
namespace wb {
 
27
 
 
28
  class ModelDiagramForm;
 
29
 
 
30
  class WBComponent : public base::trackable
 
31
  {
 
32
  public:
 
33
    WBComponent(WBContext *context);
 
34
    virtual ~WBComponent() {};
 
35
    
 
36
    inline WBContext *get_wb() { return _wb; }
 
37
    inline grt::GRT *get_grt() { return _wb->get_grt_manager()->get_grt(); }
 
38
    inline bec::GRTManager *get_grt_manager() { return _wb->get_grt_manager(); }
 
39
 
 
40
    virtual std::string get_name()= 0;
 
41
    virtual std::string get_diagram_class_name() { return ""; }
 
42
 
 
43
    virtual void setup_context_grt(grt::GRT *grt, WBOptions *options) {}
 
44
    virtual void load_app_options(bool update) {}
 
45
    virtual void save_app_options() {}
 
46
 
 
47
    virtual void close_document() {}
 
48
    virtual void reset_document() {}
 
49
    virtual void document_loaded() {}
 
50
    virtual void block_model_notifications() {}
 
51
    virtual void unblock_model_notifications() {}
 
52
 
 
53
    virtual bool handles_figure(const model_ObjectRef &figure)= 0;
 
54
    virtual GrtObjectRef get_object_for_figure(const model_ObjectRef &figure) { return GrtObjectRef(); }
 
55
    virtual model_ObjectRef clone_object(const model_ObjectRef &object, const model_LayerRef &destlayer, grt::CopyContext &copy_context, bool copy_only) { throw std::logic_error("not implemented"); }
 
56
 
 
57
    virtual bool can_paste_non_model_object(const grt::ObjectRef &object) { return false; }
 
58
    virtual void paste_non_model_object(ModelDiagramForm *view, const grt::ObjectRef &object) { throw std::logic_error("not implemented"); }
 
59
 
 
60
    // toolbar/menubar handling
 
61
    virtual grt::ListRef<app_ShortcutItem> get_shortcut_items() { return grt::ListRef<app_ShortcutItem>(); }
 
62
    virtual app_ToolbarRef get_tools_toolbar() { return app_ToolbarRef(); }
 
63
    virtual app_ToolbarRef get_tool_options(const std::string &tool)  { return app_ToolbarRef(); }
 
64
    
 
65
    virtual std::vector<std::string> get_command_dropdown_items(const std::string &option) { return std::vector<std::string>(); }
 
66
 
 
67
    virtual std::string get_command_option_value(const std::string &option);
 
68
    virtual void set_command_option_value(const std::string &option, const std::string &item);
 
69
 
 
70
    virtual std::string get_object_tooltip(const model_ObjectRef &object, mdc::CanvasItem *item) { return ""; }
 
71
 
 
72
    // tool handling
 
73
    virtual void setup_canvas_tool(ModelDiagramForm *view, const std::string &tool)= 0;
 
74
 
 
75
    virtual bool delete_model_object(const model_ObjectRef &object, std::map<std::string,bool> &options)= 0;
 
76
 
 
77
    // drag&drop
 
78
    virtual std::vector<std::string> get_accepted_drop_types() const { return std::vector<std::string>(); }
 
79
    virtual bool accepts_drop(ModelDiagramForm *view, int x, int y, const std::string &type, const std::list<GrtObjectRef> &objects) { return false; }
 
80
    virtual bool accepts_drop(ModelDiagramForm *view, int x, int y, const std::string &type, const std::string &text) { return false; }
 
81
 
 
82
    virtual bool perform_drop(ModelDiagramForm *view, int x, int y, const std::string &type, const std::list<GrtObjectRef> &objects) { return false; }
 
83
    virtual bool perform_drop(ModelDiagramForm *view, int x, int y, const std::string &type, const std::string &text) { return false; }
 
84
 
 
85
  protected:
 
86
    grt::ValueRef place_object(ModelDiagramForm *view, const MySQL::Geometry::Point &pos,
 
87
                      const std::string &object_struct,
 
88
                      const grt::DictRef &args= grt::DictRef());
 
89
    grt::ValueRef place_object_grt(grt::GRT *grt, ModelDiagramForm *view, 
 
90
                                       const MySQL::Geometry::Point &pos, const std::string &object_struct,
 
91
                                       const grt::DictRef &args);
 
92
 
 
93
 
 
94
  public:
 
95
    virtual void activate_canvas_object(const model_ObjectRef &figure, bool newwindow)= 0;
 
96
 
 
97
  protected:
 
98
    WBContext *_wb;
 
99
  };
 
100
 
 
101
};
 
102
 
 
103
#endif