]> SALOME platform Git repositories - modules/jobmanager.git/commitdiff
Salome HOME
Fix bug preventing to change the type of a cloned job
authorRenaud Barate <renaud.barate@edf.fr>
Mon, 26 Jan 2015 13:04:11 +0000 (14:04 +0100)
committerRenaud Barate <renaud.barate@edf.fr>
Mon, 26 Jan 2015 13:04:11 +0000 (14:04 +0100)
src/genericgui/BL_CreateJobWizard.cxx
src/genericgui/BL_CreateJobWizard.hxx
src/genericgui/BL_JobsManager_QT.cxx

index 9d9ea3c0a745673c2fd0d1add51e1771e5625660..ce6add017a7966e8c0ab980e24ed5349a2d74926 100644 (file)
@@ -47,6 +47,7 @@ BL::CreateJobWizard::CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALO
   _salome_services = salome_services;
 
   job_name = "";
+  job_type = YACS;
   yacs_file = "";
   command = "";
   python_salome_file = "";
@@ -125,7 +126,7 @@ BL::CreateJobWizard::clone(const std::string & name)
     if (job->getType() == BL::Job::YACS_SCHEMA)
     {
       setField("yacs_file", QString(job->getJobFile().c_str()));
-      _job_name_page->_yacs_schema_button->click();
+      setField("job_type_yacs", true);
       setField("env_yacs_file", QString(job->getEnvFile().c_str()));
       if (job->getDumpYACSState() != -1)
       {
@@ -137,13 +138,13 @@ BL::CreateJobWizard::clone(const std::string & name)
     else if (job->getType() == BL::Job::COMMAND)
     {
       setField("command", QString(job->getJobFile().c_str()));
-      _job_name_page->_command_button->click();
+      setField("job_type_command", true);
       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->_python_salome_button->click();
+      setField("job_type_python_salome", true);
       setField("env_PythonSalome_file", QString(job->getEnvFile().c_str()));
     }
 
@@ -247,6 +248,12 @@ BL::CreateJobWizard::end(int result)
     // Job Name Panel
     QString f_job_name = field("job_name").toString();
     job_name = f_job_name.trimmed().toUtf8().constData();
+    if (field("job_type_yacs").toBool())
+      job_type = YACS;
+    else if (field("job_type_command").toBool())
+      job_type = COMMAND;
+    else
+      job_type = PYTHON_SALOME;
 
     // YACS Schema Panel
     QString f_yacs_file = field("yacs_file").toString();
@@ -262,11 +269,11 @@ BL::CreateJobWizard::end(int result)
     python_salome_file = f_python_salome_file.trimmed().toUtf8().constData();
 
     QString f_env_file;
-    if (yacs_file != "")
+    if (job_type == YACS)
       f_env_file = field("env_yacs_file").toString();
-    else if (command != "")
+    else if (job_type == COMMAND)
       f_env_file = field("env_command_file").toString();
-    else if (python_salome_file != "")
+    else if (job_type == PYTHON_SALOME)
       f_env_file = field("env_PythonSalome_file").toString();
     env_file = f_env_file.trimmed().toUtf8().constData();
 
@@ -394,16 +401,19 @@ BL::JobNamePage::JobNamePage(QWidget * parent, BL::JobsManager_QT * jobs_manager
 
   QLabel * label_type = new QLabel("Choose type of batch job:");
   QGroupBox *groupBox = new QGroupBox("Type of job");
-  _yacs_schema_button = new QRadioButton(tr("YACS Schema"));
+  QRadioButton * _yacs_schema_button = new QRadioButton(tr("YACS Schema"));
   _yacs_schema_button->setChecked(true);
-  _command_button = new QRadioButton(tr("Command"));
-  _python_salome_button = new QRadioButton(tr("Python script in SALOME"));
+  QRadioButton * _command_button = new QRadioButton(tr("Command"));
+  QRadioButton * _python_salome_button = new QRadioButton(tr("Python script in SALOME"));
   QVBoxLayout *vbox = new QVBoxLayout;
   vbox->addWidget(_yacs_schema_button);
   vbox->addWidget(_command_button);
   vbox->addWidget(_python_salome_button);
   vbox->addStretch(1);
   groupBox->setLayout(vbox);
+  registerField("job_type_yacs", _yacs_schema_button);
+  registerField("job_type_command", _command_button);
+  registerField("job_type_python_salome", _python_salome_button);
 
   QGroupBox * explanationBox = new QGroupBox("Explanation");
   QVBoxLayout *explanationvbox = new QVBoxLayout;
@@ -425,9 +435,9 @@ BL::JobNamePage::JobNamePage(QWidget * parent, BL::JobsManager_QT * jobs_manager
   layout->addWidget(explanationBox, 4, 0, 1, -1);
   setLayout(main_layout);
 
-  connect(_yacs_schema_button, SIGNAL(clicked(bool)), this, SLOT(yacs_schema_button(bool)));
-  connect(_command_button, SIGNAL(clicked(bool)), this, SLOT(command_button(bool)));
-  connect(_python_salome_button, SIGNAL(clicked(bool)), this, SLOT(python_salome_button(bool)));
+  connect(_yacs_schema_button, SIGNAL(toggled(bool)), this, SLOT(yacs_schema_button(bool)));
+  connect(_command_button, SIGNAL(toggled(bool)), this, SLOT(command_button(bool)));
+  connect(_python_salome_button, SIGNAL(toggled(bool)), this, SLOT(python_salome_button(bool)));
 
   // Default button
   yacs_schema_button(true);
@@ -501,11 +511,11 @@ BL::JobNamePage::validatePage()
 int
 BL::JobNamePage::nextId() const
 {
-  if (_yacs_schema_button->isChecked())
+  if (field("job_type_yacs").toBool())
   {
     return BL::CreateJobWizard::Page_YACSSchema;
   } 
-  else if (_command_button->isChecked())
+  else if (field("job_type_command").toBool())
   {
     return BL::CreateJobWizard::Page_Command_Main_Definitions;
   }
index 54f5e112b8bc58995be6464ba7eb12293096f036..b9d37604db2221e4c81bed5e8afc08421aaac1b4 100644 (file)
@@ -67,6 +67,7 @@ namespace BL{
     public:
       // Results
       std::string job_name;
+      enum {YACS, COMMAND, PYTHON_SALOME} job_type;
 
       std::string yacs_file;
       std::string command;
@@ -137,9 +138,6 @@ namespace BL{
       QLabel * _explanation;
 
     public:
-      QRadioButton * _yacs_schema_button;
-      QRadioButton * _command_button;
-      QRadioButton * _python_salome_button;
       bool _check_name;
   };
 
index 3e57f6ea4c7a493fccb22389d996a8cca94373dd..4b5f3f39c5a44cac2ba6ff2d561805b8960591cb 100644 (file)
@@ -272,24 +272,26 @@ void
 BL::JobsManager_QT::create_job_with_wizard(BL::CreateJobWizard & wizard)
 {
   BL::Job * new_job = createJob(wizard.job_name);
-  if (wizard.yacs_file != "")
+  switch (wizard.job_type)
   {
+  case BL::CreateJobWizard::YACS:
     // YACS schema job
     new_job->setType(BL::Job::YACS_SCHEMA);
     new_job->setJobFile(wizard.yacs_file);
     new_job->setDumpYACSState(wizard.dump_yacs_state);
-  }
-  else if (wizard.command != "")
-  {
+    break;
+  case BL::CreateJobWizard::COMMAND:
     // Command Job
     new_job->setType(BL::Job::COMMAND);
     new_job->setJobFile(wizard.command);
-  }
-  else if (wizard.python_salome_file != "")
-  {
-    // Command Job
+    break;
+  case BL::CreateJobWizard::PYTHON_SALOME:
+    // Python Salome Job
     new_job->setType(BL::Job::PYTHON_SALOME);
     new_job->setJobFile(wizard.python_salome_file);
+    break;
+  default:
+    throw BL::Exception("Unknown job type");
   }
 
   // For all jobs