From: ribes Date: Mon, 25 Jan 2010 14:51:24 +0000 (+0000) Subject: - Begin of clone X-Git-Tag: V5_1_4a1~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a6d130f0c2faa51efcfcb581af300ec61ec47193;p=modules%2Fjobmanager.git - Begin of clone --- diff --git a/src/engine/BL_SALOMEServices.cxx b/src/engine/BL_SALOMEServices.cxx index 3060fb7..da485c3 100644 --- a/src/engine/BL_SALOMEServices.cxx +++ b/src/engine/BL_SALOMEServices.cxx @@ -89,7 +89,7 @@ BL::SALOMEServices::getResourceList() Engines::ResourceList * resourceList = NULL; try { - Engines::ResourceList * resourceList = _resources_manager->GetFittingResources(params); + resourceList = _resources_manager->GetFittingResources(params); } catch (const SALOME::SALOME_Exception & ex) { diff --git a/src/genericgui/BL_Buttons.cxx b/src/genericgui/BL_Buttons.cxx index b13f7df..2e82557 100644 --- a/src/genericgui/BL_Buttons.cxx +++ b/src/genericgui/BL_Buttons.cxx @@ -25,14 +25,16 @@ BL::Buttons::Buttons(QWidget * parent) : QGroupBox(parent) 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); @@ -59,6 +61,12 @@ BL::Buttons::setCreateButtonSlot(QObject * receiver, const char * name) 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) { @@ -83,6 +91,18 @@ BL::Buttons::setGetResultsButtonSlot(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() { diff --git a/src/genericgui/BL_Buttons.hxx b/src/genericgui/BL_Buttons.hxx index 866e96d..e364cd7 100644 --- a/src/genericgui/BL_Buttons.hxx +++ b/src/genericgui/BL_Buttons.hxx @@ -35,11 +35,15 @@ namespace BL 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(); @@ -51,6 +55,7 @@ namespace BL protected: QPushButton * _create_button; + QPushButton * _edit_clone_button; QPushButton * _start_button; QPushButton * _delete_button; QPushButton * _get_results_button; diff --git a/src/genericgui/BL_CreateJobWizard.cxx b/src/genericgui/BL_CreateJobWizard.cxx index 70211a1..e247c87 100644 --- a/src/genericgui/BL_CreateJobWizard.cxx +++ b/src/genericgui/BL_CreateJobWizard.cxx @@ -46,7 +46,9 @@ BL::CreateJobWizard::CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALO 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)); @@ -66,6 +68,83 @@ BL::CreateJobWizard::~CreateJobWizard() 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::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) { @@ -118,7 +197,7 @@ BL::CreateJobWizard::end(int result) 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(); diff --git a/src/genericgui/BL_CreateJobWizard.hxx b/src/genericgui/BL_CreateJobWizard.hxx index 78bd250..9ee5789 100644 --- a/src/genericgui/BL_CreateJobWizard.hxx +++ b/src/genericgui/BL_CreateJobWizard.hxx @@ -33,6 +33,7 @@ namespace BL{ class JobsManager_QT; + class JobNamePage; class CreateJobWizard: virtual public QWizard { Q_OBJECT @@ -43,6 +44,8 @@ namespace BL{ void setFilesList(QListWidget * input_files_list, QListWidget * output_files_list); + void clone(const std::string & name); + public slots: void end(int result); @@ -53,6 +56,8 @@ namespace BL{ QListWidget * _input_files_list; QListWidget * _output_files_list; + BL::JobNamePage * _job_name_page; + public: // Results std::string job_name; @@ -106,10 +111,12 @@ namespace BL{ 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 diff --git a/src/genericgui/BL_GenericGui.cxx b/src/genericgui/BL_GenericGui.cxx index 66aae0d..66e912a 100644 --- a/src/genericgui/BL_GenericGui.cxx +++ b/src/genericgui/BL_GenericGui.cxx @@ -43,6 +43,7 @@ BL::GenericGui::GenericGui(BL::MainWindows_Wrap * wrapper) : QObject(wrapper->ge /* 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())); @@ -137,10 +138,11 @@ void 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())); } @@ -150,6 +152,7 @@ BL::GenericGui::createMenus() 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); @@ -163,6 +166,13 @@ BL::GenericGui::create_job() _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() { @@ -234,12 +244,16 @@ BL::GenericGui::updateButtonsStates() _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: diff --git a/src/genericgui/BL_GenericGui.hxx b/src/genericgui/BL_GenericGui.hxx index 5a80e5e..0d0c03d 100644 --- a/src/genericgui/BL_GenericGui.hxx +++ b/src/genericgui/BL_GenericGui.hxx @@ -52,6 +52,7 @@ namespace BL public slots: void create_job(); + void edit_clone_job(); void start_job(); void delete_job(); void refresh_job(); @@ -80,6 +81,7 @@ namespace BL 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; diff --git a/src/genericgui/BL_JobsManager_QT.cxx b/src/genericgui/BL_JobsManager_QT.cxx index f6c9627..db22286 100644 --- a/src/genericgui/BL_JobsManager_QT.cxx +++ b/src/genericgui/BL_JobsManager_QT.cxx @@ -150,9 +150,11 @@ BL::JobsManager_QT::one_hour_refresh() } 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 != "") diff --git a/src/genericgui/BL_JobsManager_QT.hxx b/src/genericgui/BL_JobsManager_QT.hxx index b1b0980..86cfb1a 100644 --- a/src/genericgui/BL_JobsManager_QT.hxx +++ b/src/genericgui/BL_JobsManager_QT.hxx @@ -57,7 +57,7 @@ namespace BL{ 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,