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
|
/*
* Copyright (c) 2007, 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 _WIZARDPROGRESSPAGE_H_
#define _WIZARDPROGRESSPAGE_H_
#include "grt_wizard_form.h"
#include "mforms/imagebox.h"
#include "mforms/label.h"
#include "mforms/table.h"
#include "mforms/panel.h"
#include "mforms/textbox.h"
#include "mforms/progressbar.h"
#include "grt/grt_dispatcher.h"
namespace grtui {
class WBPUBLICBACKEND_PUBLIC_FUNC WizardProgressPage : public WizardPage
{
public:
WizardProgressPage(WizardForm *form, const std::string &id, bool has_progressbar);
virtual ~WizardProgressPage();
virtual ::mforms::View *get_advanced_panel() { return &_log_panel; }
void set_heading(const std::string &text);
protected:
enum TaskState {
StateNormal,
StateBusy,
StateDone,
StateWarning,
StateError,
StateDisabled
};
struct WBPUBLICBACKEND_PUBLIC_FUNC TaskRow
{
mforms::ImageBox icon;
mforms::Label label;
boost::function<bool ()> execute; //! return value indicates whether an asynchronous function was actually executed
boost::function<bool ()> process_fail; //! return value indicates whether it can continue executing ok
boost::function<void (grt::ValueRef)> process_finish;
std::string status_text;
bool enabled;
bool async;
bool async_running;
bool async_failed;
int async_errors;
TaskRow() : enabled(true), async(false), async_running(false), async_failed(false), async_errors(0) {}
void set_state(TaskState state);
void set_enabled(bool flag);
};
mforms::Label _heading;
std::vector<TaskRow*> _tasks;
std::map<bec::GRTTask*, bec::GRTTask::Ref> _task_list;
std::string _finish_message;
mforms::Label _status_text;
mforms::Table _task_table;
mforms::Box *_progress_bar_box;
mforms::ProgressBar *_progress_bar;
mforms::Label *_progress_label;
mforms::Panel _log_panel;
mforms::TextBox _log_text;
int _current_task;
bool _busy;
bool _done;
bool _got_warning_messages;
bool _got_error_messages;
TaskRow *add_async_task(const std::string &caption,
const boost::function<bool ()> &execute,
const std::string &status_text);
TaskRow *add_task(const std::string &caption,
const boost::function<bool ()> &execute,
const std::string &status_text);
TaskRow *add_disabled_task(const std::string &caption);
TaskRow *current_task();
void end_adding_tasks(const std::string &finish_message);
void clear_tasks();
void reset_tasks();
void start_tasks();
void set_status_text(const std::string &text, bool is_error= false);
void update_progress(float pct, const std::string &caption);
void add_log_text(const std::string &text);
virtual void extra_clicked();
private:
TaskRow *add_task(bool async,
const std::string &caption,
const boost::function<bool ()> &execute,
const std::string &status_text);
public:
void execute_grt_task(const boost::function<grt::ValueRef (grt::GRT*)> &slot, bool sync);
void process_grt_task_message(const grt::Message &msg);
void process_grt_task_fail(const std::exception &error, bec::GRTTask* task);
void process_grt_task_finish(const grt::ValueRef &result, bec::GRTTask* task);
protected:
void perform_tasks();
virtual bool allow_cancel();
virtual bool allow_next();
virtual bool allow_back();
virtual void tasks_finished(bool success) {}
virtual std::string extra_button_caption();
virtual void enter(bool advancing);
};
};
#endif /* _WIZARDPROGRESSPAGE_H_ */
|