2
* Copyright (c) 2007, 2010, 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
22
#include "relationship_canvas_floater.h"
23
#include "model/wb_model_diagram_form.h"
24
#include "base/string_utilities.h"
27
using namespace MySQL::Geometry;
28
using namespace MySQL::Drawing;
30
RelationshipFloater::RelationshipFloater(ModelDiagramForm *view)
31
: Floater(view->get_floater_layer(), _("Foreign Key Columns")), _columns_box(view->get_floater_layer(), mdc::Box::Vertical, true),
32
_text(view->get_floater_layer()), _button(view->get_floater_layer())
34
_text.set_multi_line(true);
35
_text.set_pen_color(Color(0.8, 0.8, 0.8));
36
_text.set_font(mdc::FontSpec("Helvetica", mdc::SNormal, mdc::WNormal, 11));
37
_columns_box.set_spacing(4);
38
_content_box.set_spacing(8);
39
_content_box.add(&_columns_box, false, false);
40
_content_box.add(&_text, false, false);
41
_content_box.add(&_button, false, false);
45
_content_box.set_needs_relayout();
49
RelationshipFloater::~RelationshipFloater()
51
for (std::vector<mdc::TextFigure*>::iterator iter= _columns.begin(); iter != _columns.end(); ++iter)
56
void RelationshipFloater::setup_pick_source()
58
set_title(_("Foreign Key Columns"));
59
_text.set_text(_("Pick one or more columns\nfor the foreign key."));
60
//_text.set_needs_relayout();
61
//set_needs_relayout();
63
_button.set_text(_("Pick Referenced Columns"));
67
void RelationshipFloater::add_column(const std::string &name)
69
mdc::TextFigure *text= new mdc::TextFigure(get_layer());
71
text->set_pen_color(Color::White());
73
_columns.push_back(text);
75
_columns_box.add(text, false, false);
79
void RelationshipFloater::setup_pick_target()
81
set_title(_("Referenced Columns"));
82
_text.set_text(_("Pick matching columns for\nthe referenced table."));
84
_button.set_visible(false);
88
mdc::FontSpec font(_columns[_current_column]->get_font());
89
font.toggle_bold(true);
90
_columns[_current_column]->set_font(font);
94
void RelationshipFloater::pick_next_target()
96
mdc::FontSpec font(_columns[_current_column]->get_font());
98
font.toggle_bold(true);
99
_columns[_current_column]->set_font(font);
102
if (_current_column < _columns.size())
104
font.toggle_bold(false);
105
_columns[_current_column]->set_font(font);