_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);
+ _restart_button = new QPushButton("Restart 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);
mainLayout->addWidget(_create_button);
mainLayout->addWidget(_edit_clone_button);
mainLayout->addWidget(_start_button);
+ mainLayout->addWidget(_restart_button);
mainLayout->addWidget(_delete_button);
mainLayout->addWidget(_get_results_button);
mainLayout->addWidget(_refresh_button);
connect(_start_button, SIGNAL(clicked()), receiver, name);
}
+void
+BL::Buttons::setReStartButtonSlot(QObject * receiver, const char * name)
+{
+ connect(_restart_button, SIGNAL(clicked()), receiver, name);
+}
+
void
BL::Buttons::setDeleteButtonSlot(QObject * receiver, const char * name)
{
_start_button->setEnabled(false);
}
+void
+BL::Buttons::enable_restart_button()
+{
+ _restart_button->setEnabled(true);
+}
+
+void
+BL::Buttons::disable_restart_button()
+{
+ _restart_button->setEnabled(false);
+}
+
void
BL::Buttons::enable_delete_button()
{
void setCreateButtonSlot(QObject * receiver, const char * name);
void setEditCloneButtonSlot(QObject * receiver, const char * name);
void setStartButtonSlot(QObject * receiver, const char * name);
+ void setReStartButtonSlot(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_start_button();
void disable_start_button();
+ void enable_restart_button();
+ void disable_restart_button();
+
void enable_delete_button();
void disable_delete_button();
QPushButton * _create_button;
QPushButton * _edit_clone_button;
QPushButton * _start_button;
+ QPushButton * _restart_button;
QPushButton * _delete_button;
QPushButton * _get_results_button;
QPushButton * _refresh_button;
//
#include "BL_CreateJobWizard.hxx"
+#include "BL_JobsManager_QT.hxx"
BL::CreateJobWizard::CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALOMEServices * salome_services)
{
{
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)
+ // We can only edit a job in CREATED, ERROR
+ if (job->getState() == BL::Job::CREATED or job->getState() == BL::Job::ERROR)
{
setField("job_name", QString(name.c_str()));
+ _job_name_page->_check_name = false;
}
if (job->getType() == BL::Job::YACS_SCHEMA)
: QWizardPage(parent)
{
_jobs_manager = jobs_manager;
+ _check_name = true;
setTitle("Create a new job");
QLabel *label = new QLabel("Enter Job name, you cannot add two jobs with the same name");
// Check if job name already exists
else {
- if (_jobs_manager->job_already_exist(job_name.toStdString()) == false)
+ if (_jobs_manager->job_already_exist(job_name.toStdString()) == false or _check_name == false)
{
return_value = true;
}
#include <QtGui>
#include "BL_Traces.hxx"
-#include "BL_JobsManager_QT.hxx"
#include "BL_SALOMEServices.hxx"
#include "JM_ResourceCatalog.hxx"
QRadioButton * _yacs_schema_button;
QRadioButton * _command_button;
QRadioButton * _python_salome_button;
+ bool _check_name;
};
class ConclusionPage: virtual public QWizardPage
_salome_services = new BL::SALOMEServices();
if (_salome_services->initNS() == false)
DEBMSG("WARNING !!!!! SALOME IS NOT REACHABLE !!!!");
- _jobs_manager = new BL::JobsManager_QT(_dock_parent, _salome_services);
+ _jobs_manager = new BL::JobsManager_QT(_dock_parent, this, _salome_services);
_model_manager = new BL::QModelManager(this, _jobs_manager);
_model = _model_manager->getModel();
_buttons->setCreateButtonSlot(this, SLOT(create_job()));
_buttons->setEditCloneButtonSlot(this, SLOT(edit_clone_job()));
_buttons->setStartButtonSlot(this, SLOT(start_job()));
+ _buttons->setReStartButtonSlot(this, SLOT(restart_job()));
_buttons->setDeleteButtonSlot(this, SLOT(delete_job()));
_buttons->setRefreshButtonSlot(this, SLOT(refresh_job()));
_buttons->setGetResultsButtonSlot(this, SLOT(get_results_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()));
+ _restart_job_action = _wrapper->createAction("Restart a Job", QIcon(), "Restart a Job", "Restart a Job", 0, _dock_parent, false, this, SLOT(restart_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()));
_wrapper->addActionToMenu(_create_job_action, menu_id);
_wrapper->addActionToMenu(_edit_clone_job_action, menu_id);
_wrapper->addActionToMenu(_start_job_action, menu_id);
+ _wrapper->addActionToMenu(_restart_job_action, menu_id);
_wrapper->addActionToMenu(_delete_job_action, menu_id);
_wrapper->addActionToMenu(_get_results_job_action, menu_id);
_wrapper->addActionToMenu(_refresh_job_action, menu_id);
BL::GenericGui::create_job()
{
DEBTRACE("Create Job Slot BL::GenericGui");
- _jobs_manager->create_job_wizard();
+ _jobs_manager->create_job();
}
void
BL::GenericGui::edit_clone_job()
{
DEBTRACE("Edit/Clone Job Slot BL::GenericGui");
- _jobs_manager->create_job_wizard(_job_name_selected.toStdString());
+ _jobs_manager->edit_clone_job(_job_name_selected.toStdString());
}
void
updateButtonsStates();
}
+void
+BL::GenericGui::restart_job()
+{
+ DEBTRACE("Restart Job Slot BL::GenericGui");
+ _jobs_manager->restart_job(_job_name_selected.toStdString());
+ updateButtonsStates();
+}
+
void
BL::GenericGui::refresh_job()
{
QMessageBox::Ok);
if (ret == QMessageBox::Ok)
{
- _jobs_manager->delete_job(_job_name_selected);
- _model_manager->deleteJob(_row_selected);
- emit job_deleted(_job_name_selected);
- _row_selected = -1;
- _job_name_selected = "";
- updateButtonsStates();
+ delete_job_internal();
}
}
+void
+BL::GenericGui::delete_job_internal()
+{
+ _jobs_manager->delete_job(_job_name_selected);
+ _model_manager->deleteJob(_row_selected);
+ emit job_deleted(_job_name_selected);
+ _row_selected = -1;
+ _job_name_selected = "";
+ updateButtonsStates();
+}
+
void
BL::GenericGui::job_selected(const QModelIndex & index)
{
_buttons->disable_get_results_button();
_edit_clone_job_action->setEnabled(false);
_buttons->disable_edit_clone_button();
+ _restart_job_action->setEnabled(false);
+ _buttons->disable_restart_button();
}
else if (_job_name_selected != "" and _row_selected != -1)
{
_buttons->enable_start_button();
_buttons->enable_delete_button();
_buttons->disable_get_results_button();
+ _restart_job_action->setEnabled(false);
+ _buttons->disable_restart_button();
break;
case BL::Job::IN_PROCESS:
_buttons->disable_delete_button();
_get_results_job_action->setEnabled(false);
_buttons->disable_get_results_button();
+ _restart_job_action->setEnabled(false);
+ _buttons->disable_restart_button();
break;
case BL::Job::QUEUED:
_buttons->enable_delete_button();
_get_results_job_action->setEnabled(false);
_buttons->disable_get_results_button();
+ _restart_job_action->setEnabled(false);
+ _buttons->disable_restart_button();
break;
case BL::Job::RUNNING:
_buttons->enable_delete_button();
_get_results_job_action->setEnabled(false);
_buttons->disable_get_results_button();
+ _restart_job_action->setEnabled(false);
+ _buttons->disable_restart_button();
break;
case BL::Job::PAUSED:
_buttons->enable_delete_button();
_get_results_job_action->setEnabled(false);
_buttons->disable_get_results_button();
+ _restart_job_action->setEnabled(false);
+ _buttons->disable_restart_button();
break;
case BL::Job::ERROR:
_buttons->enable_delete_button();
_get_results_job_action->setEnabled(false);
_buttons->disable_get_results_button();
+ _restart_job_action->setEnabled(true);
+ _buttons->enable_restart_button();
break;
case BL::Job::FINISHED:
_buttons->enable_delete_button();
_get_results_job_action->setEnabled(true);
_buttons->enable_get_results_button();
+ _restart_job_action->setEnabled(true);
+ _buttons->enable_restart_button();
break;
}
}
void createActions();
void createMenus();
+ void delete_job_internal();
+
public slots:
void create_job();
void edit_clone_job();
void start_job();
+ void restart_job();
void delete_job();
void refresh_job();
void get_results_job();
QAction * _create_job_action;
QAction * _edit_clone_job_action;
QAction * _start_job_action;
+ QAction * _restart_job_action;
QAction * _delete_job_action;
QAction * _get_results_job_action;
QAction * _refresh_job_action;
//
#include "BL_JobsManager_QT.hxx"
+#include "BL_GenericGui.hxx"
BL::JobManagerEvent::JobManagerEvent(const std::string & action_i,
const std::string & event_name_i,
BL::JobManagerEvent::~JobManagerEvent() {}
-BL::JobsManager_QT::JobsManager_QT(QWidget * parent, BL::SALOMEServices * salome_services) :
+BL::JobsManager_QT::JobsManager_QT(QWidget * parent, BL::GenericGui * main_gui, BL::SALOMEServices * salome_services) :
QDockWidget(parent), BL::JobsManager(salome_services)
{
DEBTRACE("Creating BL::JobsManager_QT");
+ _main_gui = main_gui;
setObserver(this);
// Widget Part
_timer->start(1 * 60 * 60 * 1000);
}
+void
+BL::JobsManager_QT::restart_job(const std::string & name)
+{
+ DEBTRACE("Restart job with name: " << name);
+ BL::CreateJobWizard wizard(this, _salome_services);
+ wizard.clone(name);
+ wizard.end(1);
+ wizard.job_name = name;
+ wizard.start_job = true;
+ _main_gui->delete_job_internal();
+ create_job_with_wizard(wizard);
+}
+
+void
+BL::JobsManager_QT::edit_clone_job(const std::string & name)
+{
+ BL::CreateJobWizard wizard(this, _salome_services);
+ wizard.clone(name);
+ wizard.exec();
+
+ // Check if the job has the same name
+ if (name == wizard.job_name)
+ {
+ DEBTRACE("Job " << name << " has been changed");
+ _main_gui->delete_job_internal();
+ }
+
+ if (wizard.job_name != "")
+ {
+ create_job_with_wizard(wizard);
+ }
+ else
+ {
+ DEBTRACE("User cancel Create Job Wizard");
+ }
+}
+
void
-BL::JobsManager_QT::create_job_wizard(const std::string & name)
+BL::JobsManager_QT::create_job()
{
BL::CreateJobWizard wizard(this, _salome_services);
- if (name != "")
- wizard.clone(name);
wizard.exec();
-
if (wizard.job_name != "")
{
- BL::Job * new_job = createJob(wizard.job_name);
- if (wizard.yacs_file != "")
- {
- // YACS schema job
- new_job->setType(BL::Job::YACS_SCHEMA);
- new_job->setJobFile(wizard.yacs_file);
- }
- else if (wizard.command != "")
- {
- // Command Job
- new_job->setType(BL::Job::COMMAND);
- new_job->setJobFile(wizard.command);
- }
- else if (wizard.python_salome_file != "")
- {
- // Command Job
- new_job->setType(BL::Job::PYTHON_SALOME);
- new_job->setJobFile(wizard.python_salome_file);
- }
-
- // For all jobs
- new_job->setEnvFile(wizard.env_file);
- BL::Job::BatchParam param;
- param.batch_directory = wizard.batch_directory;
- param.maximum_duration = wizard.maximum_duration;
- param.expected_memory = wizard.expected_memory;
- param.nb_proc = wizard.nb_proc;
- new_job->setBatchParameters(param);
- BL::Job::FilesParam files_params;
- files_params.result_directory = wizard.result_directory;
- files_params.input_files_list = wizard.input_files_list;
- files_params.output_files_list = wizard.output_files_list;
- new_job->setFilesParameters(files_params);
- new_job->setResource(wizard.resource_choosed);
- new_job->setBatchQueue(wizard.batch_queue);
-
- // End
- addJobToLauncher(wizard.job_name);
- emit new_job_added(QString::fromStdString(wizard.job_name));
- if (wizard.start_job)
- start_job(wizard.job_name);
+ create_job_with_wizard(wizard);
}
else
{
}
}
+void
+BL::JobsManager_QT::create_job_with_wizard(BL::CreateJobWizard & wizard)
+{
+ BL::Job * new_job = createJob(wizard.job_name);
+ if (wizard.yacs_file != "")
+ {
+ // YACS schema job
+ new_job->setType(BL::Job::YACS_SCHEMA);
+ new_job->setJobFile(wizard.yacs_file);
+ }
+ else if (wizard.command != "")
+ {
+ // Command Job
+ new_job->setType(BL::Job::COMMAND);
+ new_job->setJobFile(wizard.command);
+ }
+ else if (wizard.python_salome_file != "")
+ {
+ // Command Job
+ new_job->setType(BL::Job::PYTHON_SALOME);
+ new_job->setJobFile(wizard.python_salome_file);
+ }
+
+ // For all jobs
+ new_job->setEnvFile(wizard.env_file);
+ BL::Job::BatchParam param;
+ param.batch_directory = wizard.batch_directory;
+ param.maximum_duration = wizard.maximum_duration;
+ param.expected_memory = wizard.expected_memory;
+ param.nb_proc = wizard.nb_proc;
+ new_job->setBatchParameters(param);
+ BL::Job::FilesParam files_params;
+ files_params.result_directory = wizard.result_directory;
+ files_params.input_files_list = wizard.input_files_list;
+ files_params.output_files_list = wizard.output_files_list;
+ new_job->setFilesParameters(files_params);
+ new_job->setResource(wizard.resource_choosed);
+ new_job->setBatchQueue(wizard.batch_queue);
+
+ // End
+ addJobToLauncher(wizard.job_name);
+ emit new_job_added(QString::fromStdString(wizard.job_name));
+ if (wizard.start_job)
+ start_job(wizard.job_name);
+}
+
void
BL::JobsManager_QT::delete_job(QString job_name)
{
std::string data;
};
+ class GenericGui;
class JobsManager_QT: virtual public QDockWidget,
virtual public BL::JobsManager,
virtual public BL::Observer
Q_OBJECT
public:
- JobsManager_QT(QWidget * parent, BL::SALOMEServices * salome_services);
+ JobsManager_QT(QWidget * parent, BL::GenericGui * main_gui, BL::SALOMEServices * salome_services);
virtual ~JobsManager_QT();
void delete_job(QString job_name);
- void create_job_wizard(const std::string & name = "");
+
+ void create_job();
+ void edit_clone_job(const std::string & name);
+ void restart_job(const std::string & name);
virtual void sendEvent(const std::string & action,
const std::string & event_name,
void write_normal_text(const QString & text);
void write_error_text(const QString & text);
+ protected:
+ void create_job_with_wizard(BL::CreateJobWizard & wizard);
+
public slots:
void RefreshJobs();
void no_auto_refresh();
QPushButton * _auto_refresh_jobs;
QTimer * _timer;
QTextEdit * _log;
+ BL::GenericGui * _main_gui;
};
}