Engines::ResourceList * resourceList = NULL;
try
{
- Engines::ResourceList * resourceList = _resources_manager->GetFittingResources(params);
+ resourceList = _resources_manager->GetFittingResources(params);
}
catch (const SALOME::SALOME_Exception & ex)
{
setTitle("Actions");
- _create_button = new QPushButton("Create Job", this);
- _start_button = new QPushButton("Start Job", this);
- _delete_button = new QPushButton("Delete Job", this);
+ _create_button = new QPushButton("Create a Job", this);
+ _edit_clone_button = new QPushButton("Edit/Clone a Job", this);
+ _start_button = new QPushButton("Start a Job", this);
+ _delete_button = new QPushButton("Delete a Job", this);
_get_results_button = new QPushButton("Get Job Results", this);
_refresh_button = new QPushButton("Refresh Jobs", this);
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addWidget(_create_button);
+ mainLayout->addWidget(_edit_clone_button);
mainLayout->addWidget(_start_button);
mainLayout->addWidget(_delete_button);
mainLayout->addWidget(_get_results_button);
connect(_create_button, SIGNAL(clicked()), receiver, name);
}
+void
+BL::Buttons::setEditCloneButtonSlot(QObject * receiver, const char * name)
+{
+ connect(_edit_clone_button, SIGNAL(clicked()), receiver, name);
+}
+
void
BL::Buttons::setStartButtonSlot(QObject * receiver, const char * name)
{
connect(_get_results_button, SIGNAL(clicked()), receiver, name);
}
+void
+BL::Buttons::enable_edit_clone_button()
+{
+ _edit_clone_button->setEnabled(true);
+}
+
+void
+BL::Buttons::disable_edit_clone_button()
+{
+ _edit_clone_button->setEnabled(false);
+}
+
void
BL::Buttons::enable_start_button()
{
virtual ~Buttons();
void setCreateButtonSlot(QObject * receiver, const char * name);
+ void setEditCloneButtonSlot(QObject * receiver, const char * name);
void setStartButtonSlot(QObject * receiver, const char * name);
void setDeleteButtonSlot(QObject * receiver, const char * name);
void setRefreshButtonSlot(QObject * receiver, const char * name);
void setGetResultsButtonSlot(QObject * receiver, const char * name);
+ void enable_edit_clone_button();
+ void disable_edit_clone_button();
+
void enable_start_button();
void disable_start_button();
protected:
QPushButton * _create_button;
+ QPushButton * _edit_clone_button;
QPushButton * _start_button;
QPushButton * _delete_button;
QPushButton * _get_results_button;
setOptions(QWizard::IndependentPages | QWizard::NoBackButtonOnStartPage);
// Common pages
- setPage(Page_JobName, new BL::JobNamePage(this, _jobs_manager));
+ _job_name_page = new BL::JobNamePage(this, _jobs_manager);
+
+ setPage(Page_JobName, _job_name_page);
setPage(Page_BatchParameters, new BL::BatchParametersPage(this));
setPage(Page_Files, new BL::FilesPage(this));
setPage(Page_Resource, new BL::ResourcePage(this, salome_services));
DEBTRACE("Destroying BL::CreateJobWizard");
}
+void
+BL::CreateJobWizard::clone(const std::string & name)
+{
+ if (_jobs_manager->job_already_exist(name) == true)
+ {
+ BL::Job * job = _jobs_manager->getJob(name);
+
+ // We can only edit a job in CREATED, ERROR or FINISHED
+ if (job->getState() == BL::Job::CREATED or BL::Job::FINISHED or BL::Job::ERROR)
+ {
+ setField("job_name", QString(name.c_str()));
+ }
+
+ if (job->getType() == BL::Job::YACS_SCHEMA)
+ {
+ setField("yacs_file", QString(job->getJobFile().c_str()));
+ _job_name_page->_yacs_schema_button->click();
+ setField("env_yacs_file", QString(job->getEnvFile().c_str()));
+ }
+ else if (job->getType() == BL::Job::COMMAND)
+ {
+ setField("command", QString(job->getJobFile().c_str()));
+ _job_name_page->_command_button->click();
+ setField("env_command_file", QString(job->getEnvFile().c_str()));
+ }
+ else if (job->getType() == BL::Job::PYTHON_SALOME)
+ {
+ setField("PythonSalome", QString(job->getJobFile().c_str()));
+ _job_name_page->_yacs_schema_button->click();
+ setField("env_PythonSalome_file", QString(job->getEnvFile().c_str()));
+ }
+
+ BL::Job::BatchParam batch_params = job->getBatchParameters();
+ setField("batch_directory", QString(batch_params.batch_directory.c_str()));
+ QString proc_value;
+ proc_value.setNum(batch_params.nb_proc);
+ setField("proc_value", proc_value);
+
+ std::size_t pos = batch_params.maximum_duration.find(":");
+ std::string hour_str = batch_params.maximum_duration.substr(0, pos);
+ int hour;
+ std::istringstream iss_hour(hour_str);
+ iss_hour >> hour;
+ setField("duration_hour", hour);
+
+ std::string min_str = batch_params.maximum_duration.substr(pos + 1, batch_params.maximum_duration.npos);
+ int min;
+ std::istringstream iss_min(min_str);
+ iss_min >> min;
+ setField("duration_min", min);
+
+ std::string mem_type = batch_params.expected_memory.substr(batch_params.expected_memory.size() - 2, 2);
+ if (mem_type == "mb")
+ setField("mem_type", 0);
+ else
+ setField("mem_type", 1);
+ std::string mem_value = batch_params.expected_memory.substr(0, batch_params.expected_memory.find(mem_type));
+ int mem_val;
+ std::istringstream iss_mem(mem_value);
+ iss_mem >> mem_val;
+ setField("mem_value", mem_val);
+
+ BL::Job::FilesParam files_params = job->getFilesParameters();
+
+ std::list<std::string>::iterator it = files_params.input_files_list.begin();
+ for (; it != files_params.input_files_list.end(); it++)
+ _input_files_list->addItem(QString((*it).c_str()));
+ it = files_params.output_files_list.begin();
+ for (; it != files_params.output_files_list.end(); it++)
+ _output_files_list->addItem(QString((*it).c_str()));
+
+ setField("result_directory", QString(files_params.result_directory.c_str()));
+ setField("resource_choosed", QString(job->getResource().c_str()));
+ setField("batch_queue", QString(job->getBatchQueue().c_str()));
+ }
+}
+
void
BL::CreateJobWizard::setFilesList(QListWidget * input_files_list, QListWidget * output_files_list)
{
time_min = "0" + field("duration_min").toString();
else
time_min = field("duration_min").toString();
- maximum_duration = time_hour.toStdString() + ":" + time_min.toStdString() + ":00";
+ maximum_duration = time_hour.toStdString() + ":" + time_min.toStdString();
QString mem = field("mem_value").toString();
int mem_type_i = field("mem_type").toInt();
namespace BL{
class JobsManager_QT;
+ class JobNamePage;
class CreateJobWizard: virtual public QWizard
{
Q_OBJECT
void setFilesList(QListWidget * input_files_list, QListWidget * output_files_list);
+ void clone(const std::string & name);
+
public slots:
void end(int result);
QListWidget * _input_files_list;
QListWidget * _output_files_list;
+ BL::JobNamePage * _job_name_page;
+
public:
// Results
std::string job_name;
private:
BL::JobsManager_QT * _jobs_manager;
+ QLabel * _explanation;
+
+ public:
QRadioButton * _yacs_schema_button;
QRadioButton * _command_button;
QRadioButton * _python_salome_button;
- QLabel * _explanation;
};
class ConclusionPage: virtual public QWizardPage
/* Buttons */
_buttons = new BL::Buttons(_tab_parent);
_buttons->setCreateButtonSlot(this, SLOT(create_job()));
+ _buttons->setEditCloneButtonSlot(this, SLOT(edit_clone_job()));
_buttons->setStartButtonSlot(this, SLOT(start_job()));
_buttons->setDeleteButtonSlot(this, SLOT(delete_job()));
_buttons->setRefreshButtonSlot(this, SLOT(refresh_job()));
BL::GenericGui::createActions()
{
DEBTRACE("CreateActions BL::GenericGui");
- _create_job_action = _wrapper->createAction("Create Job", QIcon(), "Create Job", "Create Job", 0, _dock_parent, false, this, SLOT(create_job()));
- _start_job_action = _wrapper->createAction("Start Job", QIcon(), "Start Job", "Start Job", 0, _dock_parent, false, this, SLOT(start_job()));
- _delete_job_action = _wrapper->createAction("Delete Job", QIcon(), "Delete Job", "Delete Job", 0, _dock_parent, false, this, SLOT(delete_job()));
- _refresh_job_action = _wrapper->createAction("Refresh Job", QIcon(), "Refresh Job", "Refresh Job", 0, _dock_parent, false, this, SLOT(refresh_job()));
+ _create_job_action = _wrapper->createAction("Create a Job", QIcon(), "Create a Job", "Create a Job", 0, _dock_parent, false, this, SLOT(create_job()));
+ _edit_clone_job_action = _wrapper->createAction("Edit/Clone a Job", QIcon(), "Edit/Clone a Job", "Edit/Clone a Job", 0, _dock_parent, false, this, SLOT(edit_clone_job()));
+ _start_job_action = _wrapper->createAction("Start a Job", QIcon(), "Start a Job", "Start a Job", 0, _dock_parent, false, this, SLOT(start_job()));
+ _delete_job_action = _wrapper->createAction("Delete a Job", QIcon(), "Delete a Job", "Delete a Job", 0, _dock_parent, false, this, SLOT(delete_job()));
+ _refresh_job_action = _wrapper->createAction("Refresh Jobs", QIcon(), "Refresh Jobs", "Refresh Jobs", 0, _dock_parent, false, this, SLOT(refresh_job()));
_get_results_job_action = _wrapper->createAction("Get Job Results", QIcon(), "Get Job Results", "Get Job Results", 0, _dock_parent, false, this, SLOT(refresh_job()));
}
DEBTRACE("CreateMenus BL::GenericGui");
int menu_id = _wrapper->createTopMenu("JobManager");
_wrapper->addActionToMenu(_create_job_action, menu_id);
+ _wrapper->addActionToMenu(_edit_clone_job_action, menu_id);
_wrapper->addActionToMenu(_start_job_action, menu_id);
_wrapper->addActionToMenu(_delete_job_action, menu_id);
_wrapper->addActionToMenu(_get_results_job_action, menu_id);
_jobs_manager->create_job_wizard();
}
+void
+BL::GenericGui::edit_clone_job()
+{
+ DEBTRACE("Edit/Clone Job Slot BL::GenericGui");
+ _jobs_manager->create_job_wizard(_job_name_selected.toStdString());
+}
+
void
BL::GenericGui::start_job()
{
_buttons->disable_start_button();
_buttons->disable_delete_button();
_buttons->disable_get_results_button();
+ _edit_clone_job_action->setEnabled(false);
+ _buttons->disable_edit_clone_button();
}
else if (_job_name_selected != "" and _row_selected != -1)
{
BL::Job * job = _jobs_manager->getJob(_job_name_selected.toStdString());
BL::Job::State job_state = job->getState();
+ _edit_clone_job_action->setEnabled(true);
+ _buttons->enable_edit_clone_button();
switch (job_state)
{
case BL::Job::CREATED:
public slots:
void create_job();
+ void edit_clone_job();
void start_job();
void delete_job();
void refresh_job();
BL::Summary * _summary;
QAction * _create_job_action;
+ QAction * _edit_clone_job_action;
QAction * _start_job_action;
QAction * _delete_job_action;
QAction * _get_results_job_action;
}
void
-BL::JobsManager_QT::create_job_wizard()
+BL::JobsManager_QT::create_job_wizard(const std::string & name)
{
BL::CreateJobWizard wizard(this, _salome_services);
+ if (name != "")
+ wizard.clone(name);
wizard.exec();
if (wizard.job_name != "")
virtual ~JobsManager_QT();
void delete_job(QString job_name);
- void create_job_wizard();
+ void create_job_wizard(const std::string & name = "");
virtual void sendEvent(const std::string & action,
const std::string & event_name,