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
|
/*
* Copyright (c) 2009, 2015, 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 _DATA_SOURCE_SELECTOR_H_
#define _DATA_SOURCE_SELECTOR_H_
#include "grtui/grt_wizard_plugin.h"
#include "grtui/wizard_view_text_page.h"
#include "mforms/fs_object_selector.h"
#include "mforms/panel.h"
#include "mforms/box.h"
#include "mforms/radiobutton.h"
struct DataSourceSelector: public base::trackable
{
enum SourceType
{
ModelSource= 0,
ServerSource= 1,
FileSource= 2
};
mforms::Panel panel;
mforms::Box box;
mforms::RadioButton* model_radio;
mforms::RadioButton* server_radio;
mforms::RadioButton* file_radio;
mforms::Box browse_box;
mforms::FsObjectSelector file_selector;
DataSourceSelector(bool SaveFile = false)
: panel(::mforms::TitledBoxPanel), box(false), browse_box(true), file_selector(true)
{
box.set_spacing(4);
box.set_padding(12);
box.set_homogeneous(true);
panel.add(&box);
int group= mforms::RadioButton::new_id();
model_radio= mforms::manage(new mforms::RadioButton(group));
server_radio= mforms::manage(new mforms::RadioButton(group));
file_radio= mforms::manage(new mforms::RadioButton(group));
box.add(model_radio, false, false);
model_radio->set_text(_("Model Schemata"));
box.add(server_radio, false, false);
server_radio->set_text(_("Live Database Server"));
file_radio->set_text(_("Script File:"));
box.add(&browse_box, false, false);
browse_box.set_spacing(8);
browse_box.add(file_radio, false,true);
browse_box.add(&file_selector, true, true);
file_selector.initialize("", SaveFile ? mforms::SaveFile : mforms::OpenFile, "SQL Files (*.sql)|*.sql");
scoped_connect(file_radio->signal_clicked(),boost::bind(&DataSourceSelector::file_source_selected, this));
}
void file_source_selected()
{
file_selector.set_enabled(file_radio->get_active());
}
void set_change_slot(const boost::function<void()> &change_slot)
{
scoped_connect(model_radio->signal_clicked(),change_slot);
scoped_connect(server_radio->signal_clicked(),change_slot);
scoped_connect(file_radio->signal_clicked(),change_slot);
}
void set_source(SourceType type)
{
switch (type)
{
case ModelSource:
model_radio->set_active(true);
(*model_radio->signal_clicked())();
break;
case ServerSource:
server_radio->set_active(true);
(*server_radio->signal_clicked())();
break;
case FileSource:
file_radio->set_active(true);
(*file_radio->signal_clicked())();
break;
}
}
SourceType get_source()
{
if (model_radio->get_active())
return ModelSource;
else if (server_radio->get_active())
return ServerSource;
else
return FileSource;
}
};
#endif //#define _DB_ALTER_SCRIPT_H_
|