Salome HOME
Add new wizard page "Advanced Parameters" with new parameter wckey
[modules/jobmanager.git] / src / genericgui / BL_CreateJobWizard.cxx
index 84df31c2b957208109a2735ad38d69447c7abc6b..2fe128e23672d00a9709e2e8ab12547cfdf7a10c 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2009-2013  CEA/DEN, EDF R&D
+// Copyright (C) 2009-2014  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 #include <stdlib.h>
 #include <time.h>
 
+#include <ui_ResourceRequirementsWizardPage.h>
+#include <ui_FilesWizardPage.h>
+#include <ui_AdvancedParametersWizardPage.h>
+
 #ifdef WNT
 #undef ERROR
 #endif
 
+using namespace std;
+using namespace BL;
+
 BL::CreateJobWizard::CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALOMEServices * salome_services)
 {
   DEBTRACE("Creating BL::CreateJobWizard");
@@ -45,10 +52,19 @@ BL::CreateJobWizard::CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALO
   python_salome_file = "";
   env_file = "";
   batch_directory = "";
+
+  // For COORM
+  coorm_batch_directory = "";
+
   maximum_duration = "";
-  expected_memory = "";
+  mem_limit = 0;
+  mem_req_type = BL::Job::MEM_PER_NODE;
   nb_proc = 1;
 
+  // Parameters for COORM
+  launcher_file = "";
+  launcher_args = "";
+
   result_directory = "";
 
   resource_choosed = "";
@@ -62,11 +78,17 @@ BL::CreateJobWizard::CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALO
 
   // Common pages
   _job_name_page = new BL::JobNamePage(this, _jobs_manager);
+  _batch_parameters_page = new BL::BatchParametersPage(this, salome_services);
 
   setPage(Page_JobName, _job_name_page);
-  setPage(Page_BatchParameters, new BL::BatchParametersPage(this, salome_services));
-  setPage(Page_Files, new BL::FilesPage(this));
+  setPage(Page_BatchParameters, _batch_parameters_page);
+
+  // For COORM
+  setPage(Page_COORM_BatchParameters, new BL::COORM_BatchParametersPage(this, salome_services));
+
+  setPage(Page_Files, new BL::FilesPage(this, salome_services));
   setPage(Page_Resource, new BL::ResourcePage(this, salome_services));
+  setPage(Page_Advanced, new BL::AdvancedParametersPage(this));
   setPage(Page_Conclusion, new BL::ConclusionPage(this));
 
   // Specific pages
@@ -125,12 +147,28 @@ BL::CreateJobWizard::clone(const std::string & name)
       setField("env_PythonSalome_file", QString(job->getEnvFile().c_str()));
     }
 
+
+       // For COORM
     BL::Job::BatchParam batch_params = job->getBatchParameters();
-    setField("batch_directory", QString(batch_params.batch_directory.c_str()));
+       BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(job->getResource().c_str());
+       std::string batch = resource_descr.batch.c_str();
+       if (batch == "coorm")
+       {
+               setField("coorm_batch_directory", QString(batch_params.batch_directory.c_str()));
+               setField("launcher_file", QString(batch_params.launcher_file.c_str()));
+               setField("launcher_args", QString(batch_params.launcher_args.c_str()));
+       }
+       else
+       {
+               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);
 
+    setField("exclusive", batch_params.exclusive);
+
     if (batch_params.maximum_duration == "")
     {
       setField("duration_hour", 0);
@@ -152,16 +190,18 @@ BL::CreateJobWizard::clone(const std::string & name)
       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);
+    unsigned long long mem_mb = batch_params.mem_limit;
+    if (mem_mb % 1024 == 0)
+    {
+      setField("mem_value", mem_mb / 1024);
+      _batch_parameters_page->setMemUnit(BatchParametersPage::GB);
+    }
     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);
+    {
+      setField("mem_value", mem_mb);
+      _batch_parameters_page->setMemUnit(BatchParametersPage::MB);
+    }
+    _batch_parameters_page->setMemReqType(batch_params.mem_req_type);
 
     BL::Job::FilesParam files_params = job->getFilesParameters();
 
@@ -176,6 +216,7 @@ BL::CreateJobWizard::clone(const std::string & name)
     setField("resource_choosed", QString(job->getResource().c_str()));
     setField("batch_queue", QString(job->getBatchQueue().c_str()));
     setField("ll_jobtype", QString(job->getLoadLevelerJobType().c_str()));
+    setField("wckey", QString(job->getWCKey().c_str()));
   }
 }
 
@@ -194,20 +235,20 @@ BL::CreateJobWizard::end(int result)
   {
     // Job Name Panel
     QString f_job_name = field("job_name").toString();
-    job_name = f_job_name.toStdString();
+    job_name = f_job_name.trimmed().toUtf8().constData();
 
     // YACS Schema Panel
     QString f_yacs_file = field("yacs_file").toString();
-    yacs_file = f_yacs_file.toStdString();
+    yacs_file = f_yacs_file.trimmed().toUtf8().constData();
     dump_yacs_state = field("dump_yacs_state").toInt();
 
     // Command Panel
     QString f_command = field("command").toString();
-    command = f_command.toStdString();
+    command = f_command.trimmed().toUtf8().constData();
 
     // Command Panel
     QString f_python_salome_file = field("PythonSalome").toString();
-    python_salome_file = f_python_salome_file.toStdString();
+    python_salome_file = f_python_salome_file.trimmed().toUtf8().constData();
 
     QString f_env_file;
     if (yacs_file != "")
@@ -216,11 +257,21 @@ BL::CreateJobWizard::end(int result)
       f_env_file = field("env_command_file").toString();
     else if (python_salome_file != "")
       f_env_file = field("env_PythonSalome_file").toString();
-    env_file = f_env_file.toStdString();
+    env_file = f_env_file.trimmed().toUtf8().constData();
 
     // Batch Panel
     QString f_batch_directory = field("batch_directory").toString();
-    batch_directory = f_batch_directory.toStdString();
+    batch_directory = f_batch_directory.trimmed().toUtf8().constData();
+
+    // For COORM
+    QString f_coorm_batch_directory = field("coorm_batch_directory").toString();
+    coorm_batch_directory = f_coorm_batch_directory.toUtf8().constData();
+
+       // For COORM
+    QString f_launcher_file = field("launcher_file").toString();
+    launcher_file = f_launcher_file.toUtf8().constData();
+    QString f_launcher_args = field("launcher_args").toString();
+    launcher_args = f_launcher_args.toUtf8().constData();
 
     QString time_hour;
     QString time_min;
@@ -231,48 +282,57 @@ BL::CreateJobWizard::end(int result)
     else
     {
       if (field("duration_hour").toInt() < 10)
-        time_hour = "0" + field("duration_hour").toString();
+        time_hour = "0" + field("duration_hour").toString().trimmed();
       else
-        time_hour = field("duration_hour").toString();
+        time_hour = field("duration_hour").toString().trimmed();
       if (field("duration_min").toInt() < 10)
-        time_min = "0" + field("duration_min").toString();
+        time_min = "0" + field("duration_min").toString().trimmed();
       else
-        time_min = field("duration_min").toString();
+        time_min = field("duration_min").toString().trimmed();
       maximum_duration = time_hour.toStdString() + ":" + time_min.toStdString();
     }
 
-    QString mem = field("mem_value").toString();
-    int mem_type_i = field("mem_type").toInt();
-    QString mem_type("gb");
-    if (mem_type_i == 0)
-      mem_type = "mb";
-    expected_memory = mem.toStdString() + mem_type.toStdString();
+    unsigned long mem = field("mem_value").toULongLong();
+    BatchParametersPage::MemUnit mem_unit = _batch_parameters_page->getMemUnit();
+    switch (mem_unit)
+    {
+    case BatchParametersPage::MB:
+      mem_limit = mem;
+      break;
+    case BatchParametersPage::GB:
+      mem_limit = mem * 1024;
+      break;
+    default:
+      throw Exception("Invalid memory unit");
+    }
+    mem_req_type = _batch_parameters_page->getMemReqType();
 
     nb_proc = field("proc_value").toInt();
+    exclusive = field("exclusive").toBool();
 
     // Files Panel
     QString f_result_directory = field("result_directory").toString();
-    result_directory = f_result_directory.toStdString();
+    result_directory = f_result_directory.trimmed().toUtf8().constData();
     for (int i = 0; i < _input_files_list->count(); ++i)
     {
       QListWidgetItem * item = _input_files_list->item(i);
       QString item_text = item->text();
-      input_files_list.push_back(item_text.toStdString());
+      input_files_list.push_back(item_text.trimmed().toUtf8().constData());
     }
     for (int i = 0; i < _output_files_list->count(); ++i)
     {
       QListWidgetItem * item = _output_files_list->item(i);
       QString item_text = item->text();
-      output_files_list.push_back(item_text.toStdString());
+      output_files_list.push_back(item_text.trimmed().toUtf8().constData());
     }
 
     // Resource list
     QString f_resource_choosed = field("resource_choosed").toString();
-    resource_choosed = f_resource_choosed.toStdString(); 
+    resource_choosed = f_resource_choosed.trimmed().toUtf8().constData();
 
     // Batch Queue
     QString f_batch_queue = field("batch_queue").toString();
-    batch_queue = f_batch_queue.toStdString();
+    batch_queue = f_batch_queue.trimmed().toUtf8().constData();
 
     // LoadLeveler JobType
     BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(resource_choosed);
@@ -280,13 +340,17 @@ BL::CreateJobWizard::end(int result)
     if (batch == "ll")
     {
       QString f_ll_jobtype = field("ll_jobtype").toString();
-      ll_jobtype = f_ll_jobtype.toStdString();
+      ll_jobtype = f_ll_jobtype.trimmed().toStdString();
     }
     else
     {
       ll_jobtype = "";
     }
 
+    // WC Key
+    QString f_wckey = field("wckey").toString();
+    wckey = f_wckey.trimmed().toUtf8().constData();
+
     start_job = field("start_job").toBool();
   }
 }
@@ -353,21 +417,30 @@ void
 BL::JobNamePage::yacs_schema_button(bool checked)
 {
   if (checked)
+  {
     _explanation->setText("This job permits to launch a YACS schema into a SALOME application");
+    setField("exclusive", true);
+  }
 }
 
 void
 BL::JobNamePage::command_button(bool checked)
 {
   if (checked)
+  {
     _explanation->setText("This job permits to launch a script into a distributed resource. This script is not launched into a SALOME application");
+    setField("exclusive", false);
+  }
 }
 
 void
 BL::JobNamePage::python_salome_button(bool checked)
 {
   if (checked)
+  {
     _explanation->setText("This job permits to launch a python script into a SALOME application");
+    setField("exclusive", true);
+  }
 }
 
 bool
@@ -386,7 +459,7 @@ BL::JobNamePage::validatePage()
 
   // Check if job name already exists
   else {
-    if (_jobs_manager->job_already_exist(job_name.toStdString()) == false || _check_name == false)
+    if (_jobs_manager->job_already_exist(job_name.toUtf8().constData()) == false || _check_name == false)
     {
       return_value = true;
     }
@@ -592,82 +665,182 @@ BL::CommandMainPage::nextId() const
   return BL::CreateJobWizard::Page_Resource;
 }
 
-BL::BatchParametersPage::BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services)
+BatchParametersPage::BatchParametersPage(QWidget * parent, SALOMEServices * salome_services)
+: QWizardPage(parent),
+  ui(new Ui::ResourceRequirementsWizardPage),
+  _salome_services(salome_services),
+  resource_choosed()
+{
+  ui->setupUi(this);
+
+  registerField("duration_hour", ui->spin_duration_hour);
+  registerField("duration_min", ui->spin_duration_min);
+  registerField("mem_value", ui->spin_memory);
+  registerField("proc_value", ui->spin_proc);
+  registerField("exclusive", ui->check_exclusive);
+
+  ui->combo_memory_unit->insertItem(ui->combo_memory_unit->count(), "MB", MB);
+  ui->combo_memory_unit->insertItem(ui->combo_memory_unit->count(), "GB", GB);
+  setMemUnit(GB);
+
+  ui->combo_memory_req_type->insertItem(ui->combo_memory_req_type->count(),
+                                        "per node", Job::MEM_PER_NODE);
+  ui->combo_memory_req_type->insertItem(ui->combo_memory_req_type->count(),
+                                        "per core", Job::MEM_PER_CPU);
+};
+
+BatchParametersPage::~BatchParametersPage()
+{
+  delete ui;
+}
+
+void
+BatchParametersPage::initializePage()
+{
+  string f_resource_choosed = field("resource_choosed").toString().toUtf8().constData();
+  if (f_resource_choosed != resource_choosed)
+  {
+    resource_choosed = f_resource_choosed;
+    // If choosed resource has a SLURM batch manager, activate option "memory per cpu"
+    ResourceDescr resource_descr = _salome_services->getResourceDescr(resource_choosed);
+    if (resource_descr.batch == "slurm")
+    {
+      ui->combo_memory_req_type->setEnabled(true);
+    }
+    else
+    {
+      ui->combo_memory_req_type->setEnabled(false);
+      setMemReqType(Job::MEM_PER_NODE);
+    }
+  }
+}
+
+BatchParametersPage::MemUnit
+BatchParametersPage::getMemUnit() const
+{
+  int idx = ui->combo_memory_unit->currentIndex();
+  return (MemUnit)(ui->combo_memory_unit->itemData(idx).toInt());
+}
+
+void
+BatchParametersPage::setMemUnit(MemUnit mem_unit)
+{
+  ui->combo_memory_unit->setCurrentIndex(ui->combo_memory_unit->findData(mem_unit));
+}
+
+Job::MemReqType
+BatchParametersPage::getMemReqType() const
+{
+  int idx = ui->combo_memory_req_type->currentIndex();
+  return (Job::MemReqType)(ui->combo_memory_req_type->itemData(idx).toInt());
+}
+
+void
+BatchParametersPage::setMemReqType(Job::MemReqType mem_req_type)
+{
+  ui->combo_memory_req_type->setCurrentIndex(ui->combo_memory_req_type->findData(mem_req_type));
+}
+
+void
+BatchParametersPage::cleanupPage()
+{
+}
+
+int 
+BatchParametersPage::nextId() const
+{
+  return CreateJobWizard::Page_Files;
+}
+
+BL::COORM_BatchParametersPage::COORM_BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services)
 : QWizardPage(parent)
 {
-  setTitle("Enter Batch Parameters");
+  setTitle("Enter COORM Parameters");
   resource_choosed = "";
 
   _salome_services = salome_services;
 
-  QLabel *label = new QLabel("In this step you define the parameters of your job");
+  QLabel *label = new QLabel("In this step you define the parameters for COORM");
   label->setWordWrap(true);
   QVBoxLayout * main_layout = new QVBoxLayout;
   main_layout->addWidget(label);
 
-  // batch_directory
+  // coorm_batch_directory
   QLabel * label_directory = new QLabel("Remote work directory: ");
   QLineEdit * line_directory = new QLineEdit(this);
-  registerField("batch_directory", line_directory);
-
-  // exected during time
-  QLabel * label_duration = new QLabel("Maximum during time: ");
-  QSpinBox * spin_duration_hour = new QSpinBox(this);
-  QLabel * label_duration_hour = new QLabel("Hours");
-  spin_duration_hour->setMinimum(0);
-  spin_duration_hour->setMaximum(1000000);
-  registerField("duration_hour", spin_duration_hour);
-  QSpinBox * spin_duration_min = new QSpinBox(this);
-  QLabel * label_duration_min = new QLabel("Minutes");
-  spin_duration_min->setMinimum(0);
-  spin_duration_min->setMaximum(59);
-  registerField("duration_min", spin_duration_min);
-
-  // memory
-  QLabel * label_memory = new QLabel("Memory per nodes expected: ");
-  QSpinBox * spin_memory = new QSpinBox(this);
-  spin_memory->setMinimum(0);
-  spin_memory->setMaximum(1000000);
-  registerField("mem_value", spin_memory);
-  QComboBox * combo_memory = new QComboBox(this);
-  combo_memory->addItem("MB");
-  combo_memory->addItem("GB");
-  combo_memory->setCurrentIndex(1);
-  registerField("mem_type", combo_memory);
-
-  // proc
-  QLabel * label_proc = new QLabel("Number of proc expected: ");
-  QSpinBox * spin_proc = new QSpinBox(this);
-  spin_proc->setMinimum(1);
-  spin_proc->setMaximum(1000000);
-  registerField("proc_value", spin_proc);
-
-  QGridLayout *layout = new QGridLayout;
+  registerField("coorm_batch_directory", line_directory);
+
+  // launcher_file
+  QPushButton * launcher_file_button = new QPushButton(tr("Choose a launcher file"));
+  connect(launcher_file_button, SIGNAL(clicked()), this, SLOT(choose_launcher_file()));
+  _launcher_file_text = new QLineEdit(this);
+  _launcher_file_text->setText("");
+  registerField("launcher_file", _launcher_file_text);
+  _launcher_file_text->setReadOnly(true);
+
+  // launcher_args
+  QLabel * launcher_args_label = new QLabel("Launcher args:");
+  QLineEdit * launcher_args_text = new QLineEdit(this);
+  registerField("launcher_args", launcher_args_text);
+
+  QGridLayout * layout = new QGridLayout;
   layout->addWidget(label_directory, 0, 0);
-  layout->addWidget(line_directory, 0, 1, 1, -1);
-  layout->addWidget(label_duration, 1, 0);
-  layout->addWidget(spin_duration_hour, 1, 1);
-  layout->addWidget(label_duration_hour, 1, 2);
-  layout->addWidget(spin_duration_min, 1, 3);
-  layout->addWidget(label_duration_min, 1, 4);
-  layout->addWidget(label_memory, 2, 0);
-  layout->addWidget(spin_memory, 2, 1);
-  layout->addWidget(combo_memory, 2, 2);
-  layout->addWidget(label_proc, 3, 0);
-  layout->addWidget(spin_proc, 3, 1);
+  layout->addWidget(line_directory, 0, 1);
+  layout->addWidget(launcher_file_button, 1, 0);
+  layout->addWidget(_launcher_file_text, 1, 1);
+  layout->addWidget(launcher_args_label, 2, 0);
+  layout->addWidget(launcher_args_text, 2, 1);
 
   main_layout->insertLayout(-1, layout);
 
   setLayout(main_layout);
 };
 
-BL::BatchParametersPage::~BatchParametersPage()
+BL::COORM_BatchParametersPage::~COORM_BatchParametersPage()
 {}
 
-void BL::BatchParametersPage::cleanupPage() {}
+bool
+BL::COORM_BatchParametersPage::validatePage()
+{
+  QString coorm_batch_directory = field("coorm_batch_directory").toString();
+  if (coorm_batch_directory == "")
+  {
+    QMessageBox::warning(NULL, "Batch Directory Error", "Please enter a batch directory");
+    return false;
+  }
+
+  QString launcher_file = field("launcher_file").toString();
+  if (launcher_file == "")
+  {
+    QMessageBox::warning(NULL, "Launcher File Error", "Please enter a launcher file");
+    return false;
+  }
+
+  return true;
+}
+
+int
+BL::COORM_BatchParametersPage::nextId() const
+{
+  return BL::CreateJobWizard::Page_Files;
+}
 
 void
-BL::BatchParametersPage::initializePage()
+BL::COORM_BatchParametersPage::choose_launcher_file()
+{
+  QString launcher_file = QFileDialog::getOpenFileName(this,
+                                                  tr("Open launcher files"), "",
+                                                  tr("Py (*.py);;All Files (*)"));
+  _launcher_file_text->setReadOnly(false);
+  _launcher_file_text->setText(launcher_file);
+  _launcher_file_text->setReadOnly(true);
+}
+
+void BL::COORM_BatchParametersPage::cleanupPage()
+{}
+
+void
+BL::COORM_BatchParametersPage::initializePage()
 {
   QString f_resource_choosed = field("resource_choosed").toString();
   if (f_resource_choosed != resource_choosed)
@@ -675,7 +848,7 @@ BL::BatchParametersPage::initializePage()
     resource_choosed = f_resource_choosed;
     // If choosed resource has a working_directory set
     // Generates a default remote working directory
-    BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(resource_choosed.toStdString());
+    BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(resource_choosed.toUtf8().constData());
     QString res_work_dir = resource_descr.working_directory.c_str();
     if (res_work_dir != "")
     {
@@ -690,158 +863,128 @@ BL::BatchParametersPage::initializePage()
           launch_date[i] = '_';
       launch_date.erase(--launch_date.end()); // Last caracter is a \n
       QString date = launch_date.c_str();
-      setField("batch_directory", res_work_dir + "/" + date);
+      setField("coorm_batch_directory", res_work_dir + "/" + date);
     }
   }
 }
 
-bool
-BL::BatchParametersPage::validatePage()
+FilesPage::FilesPage(CreateJobWizard * parent, SALOMEServices * salome_services)
+: QWizardPage(parent),
+  ui(new Ui::FilesWizardPage)
 {
-  QString batch_directory = field("batch_directory").toString();
-  if (batch_directory == "")
-  {
-    QMessageBox::warning(NULL, "Batch Directory Error", "Please enter a batch directory");
-    return false;
-  }
-
-  int mem = field("mem_value").toInt();
-  if (mem == 0)
-  {
-    QMessageBox::warning(NULL, "Memory Error", "Please enter an expected memory");
-    return false;
-  }
+  ui->setupUi(this);
 
-  return true;
-}
-
-int 
-BL::BatchParametersPage::nextId() const
-{
-  return BL::CreateJobWizard::Page_Files;
-}
-
-BL::FilesPage::FilesPage(BL::CreateJobWizard * parent)
-: QWizardPage(parent)
-{
-  setTitle("Enter Input and Output Files");
+  resource_choosed = "";
+  _salome_services = salome_services;
 
-  QLabel * main_label = new QLabel("In this step you define input and output files of your job");
-  main_label->setWordWrap(true);
+  connect(ui->add_input_files_button, SIGNAL(clicked()), this, SLOT(choose_input_files()));
+  connect(ui->remove_input_files_button, SIGNAL(clicked()), this, SLOT(remove_input_files()));
+  connect(ui->input_files_list, SIGNAL(itemSelectionChanged()), this, SLOT(input_itemSelectionChanged()));
+  connect(ui->add_output_files_button, SIGNAL(clicked()), this, SLOT(add_output_file()));
+  connect(ui->remove_output_files_button, SIGNAL(clicked()), this, SLOT(remove_output_files()));
+  connect(ui->output_files_list, SIGNAL(itemSelectionChanged()), this, SLOT(output_itemSelectionChanged()));
+  connect(ui->button_choose_result_dir, SIGNAL(clicked()), this, SLOT(choose_local_directory()));
 
-  // input_files
-  QGroupBox * input_group_box = new QGroupBox("Input Files");
-  _input_files_button = new QPushButton("Add input files");
-  _input_files_button->show();
-  connect(_input_files_button, SIGNAL(clicked()), this, SLOT(choose_input_files()));
-  _remove_input_files_button = new QPushButton("Remove input files");
-  _remove_input_files_button->show();
-  _remove_input_files_button->setEnabled(false);
-  connect(_remove_input_files_button, SIGNAL(clicked()), this, SLOT(remove_input_files()));
-  _input_files_list = new QListWidget();
-  _input_files_list->setSelectionMode(QAbstractItemView::MultiSelection);
-  connect(_input_files_list, SIGNAL(itemSelectionChanged()), this, SLOT(input_itemSelectionChanged()));
-
-  QGridLayout * input_box = new QGridLayout;
-  input_box->addWidget(_input_files_button, 0, 0);
-  input_box->addWidget(_remove_input_files_button, 0, 1);
-  input_box->addWidget(_input_files_list, 1, 0, 1, -1);
-  input_group_box->setLayout(input_box);
-
-  // output_files
-  QGroupBox * output_group_box = new QGroupBox("Output Files");
-  _output_files_button = new QPushButton("Add output file");
-  _output_files_button->show();
-  connect(_output_files_button, SIGNAL(clicked()), this, SLOT(add_output_file()));
-  _remove_output_files_button = new QPushButton("Remove output files");
-  _remove_output_files_button->show();
-  _remove_output_files_button->setEnabled(false);
-  connect(_remove_output_files_button, SIGNAL(clicked()), this, SLOT(remove_output_files()));
-  _output_files_list = new QListWidget();
-  _output_files_list->setSelectionMode(QAbstractItemView::MultiSelection);
-  _output_files_list->setEditTriggers(QAbstractItemView::DoubleClicked);
-  connect(_output_files_list, SIGNAL(itemSelectionChanged()), this, SLOT(output_itemSelectionChanged()));
-
-  // Results Directory
-  QPushButton * button_result = new QPushButton("Local Result directory");
-  connect(button_result, SIGNAL(clicked()), this, SLOT(choose_local_directory()));
-  _result_directory = new QLineEdit(this);
+  registerField("batch_directory", ui->line_remote_working_dir);
+  registerField("result_directory", ui->line_result_dir);
 
   // Default result directory is home directory (if we found it)
   // First try -> HOME
 #ifdef WNT
-  _result_directory->setText(getenv("HOME"));
+  ui->line_result_dir->setText(getenv("HOME"));
 #else
   if (getenv("HOME"))
-    _result_directory->setText(getenv("HOME"));
+    ui->line_result_dir->setText(getenv("HOME"));
   else {
     // Second try -> getpwuid
     struct passwd * pass_struct = getpwuid(getuid());
     if (pass_struct)
-      _result_directory->setText(pass_struct->pw_dir);
+      ui->line_result_dir->setText(pass_struct->pw_dir);
   }
 #endif
-  registerField("result_directory", _result_directory);
-
-  QGridLayout * output_box = new QGridLayout;
-  output_box->addWidget(_output_files_button, 0, 0);
-  output_box->addWidget(_remove_output_files_button, 0, 1);
-  output_box->addWidget(_output_files_list, 1, 0, 1, -1);
-  output_box->addWidget(button_result, 2, 0);
-  output_box->addWidget(_result_directory, 2, 1, 1, -1);
-  output_group_box->setLayout(output_box);
 
-  QVBoxLayout * main_layout = new QVBoxLayout;
-  main_layout->addWidget(main_label);
-  main_layout->addWidget(input_group_box);
-  main_layout->addWidget(output_group_box);
-  setLayout(main_layout);
+  parent->setFilesList(ui->input_files_list, ui->output_files_list);
 
-  parent->setFilesList(_input_files_list, _output_files_list);
+  // Check for warning messages
+  ui->label_warning_icon->setPixmap(QIcon::fromTheme("dialog-error").pixmap(16, 16));
+  connect(ui->line_remote_working_dir, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged()));
+  connect(ui->line_result_dir, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged()));
 };
 
-BL::FilesPage::~FilesPage()
-{}
+FilesPage::~FilesPage()
+{
+  delete ui;
+}
 
-bool
-BL::FilesPage::validatePage()
+void
+FilesPage::initializePage()
 {
-  QString result_directory = field("result_directory").toString();
-  
-  for (int i = 0; i < _output_files_list->count(); ++i)
+  QString f_resource_choosed = field("resource_choosed").toString();
+  if (f_resource_choosed != resource_choosed)
   {
-    QListWidgetItem * item = _output_files_list->item(i);
-    if (item->text() == "TO EDIT!")
+    resource_choosed = f_resource_choosed;
+    // If choosed resource has a working_directory set
+    // Generates a default remote working directory
+    BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(resource_choosed.toUtf8().constData());
+    QString res_work_dir = resource_descr.working_directory.c_str();
+    if (res_work_dir != "")
     {
-      QMessageBox::warning(NULL, "Ouput Files Error", "Some output files are not defined !");
-      return false;
+      time_t rawtime;
+      time(&rawtime);
+      std::string launch_date = ctime(&rawtime);
+      for (int i = 0; i < launch_date.size(); i++)
+        if (launch_date[i] == '/' ||
+            launch_date[i] == '-' ||
+            launch_date[i] == ':' ||
+            launch_date[i] == ' ')
+          launch_date[i] = '_';
+      launch_date.erase(--launch_date.end()); // Last caracter is a \n
+      QString date = launch_date.c_str();
+      setField("batch_directory", res_work_dir + "/" + date);
     }
   }
+}
+
+bool
+FilesPage::isComplete() const
+{
+  QString warn_msg;
+  if (field("batch_directory").toString().isEmpty())
+    warn_msg = "Remote working directory is mandatory.";
+  if (field("result_directory").toString().isEmpty() && ui->output_files_list->count() != 0)
+  {
+    if (!warn_msg.isEmpty()) warn_msg += "\n";
+    warn_msg += "Result directory is mandatory if there are output files.";
+  }
 
-  if (result_directory == "" && _output_files_list->count() != 0)
+  ui->label_warning_text->setText(warn_msg);
+  if (warn_msg.isEmpty())
+  {
+    ui->label_warning_icon->hide();
+    return true;
+  }
+  else
   {
-    QMessageBox::warning(NULL, "Result Directory Error", "Please enter a result directory or remove output files");
+    ui->label_warning_icon->show();
     return false;
   }
-
-  return true;
 }
 
 void
-BL::FilesPage::choose_input_files()
+FilesPage::choose_input_files()
 {
   QStringList files = QFileDialog::getOpenFileNames(this,
                                                     tr("Add input files"), "",
                                                     tr("All Files (*)"));
   for (int i = 0; i < files.size(); ++i) 
   {
-    if (_input_files_list->findItems(files.at(i), Qt::MatchFixedString).size() == 0)
-      _input_files_list->addItem(files.at(i));
+    if (ui->input_files_list->findItems(files.at(i), Qt::MatchFixedString).size() == 0)
+      ui->input_files_list->addItem(files.at(i));
   }
 }
 
 void
-BL::FilesPage::choose_local_directory()
+FilesPage::choose_local_directory()
 {
   QString dir = QFileDialog::getExistingDirectory(this, tr("Choose local result directory"),
                                                  "",
@@ -849,61 +992,63 @@ BL::FilesPage::choose_local_directory()
                                                  | QFileDialog::DontResolveSymlinks);
 
   if (dir != "")
-    _result_directory->setText(dir);
+    ui->line_result_dir->setText(dir);
 }
 
 void 
-BL::FilesPage::remove_input_files()
+FilesPage::remove_input_files()
 {
-  QList<QListWidgetItem *> list = _input_files_list->selectedItems();
+  QList<QListWidgetItem *> list = ui->input_files_list->selectedItems();
   for (int i = 0; i < list.size(); ++i)
   {
-    int row = _input_files_list->row( list.at(i) );
-    delete _input_files_list->takeItem(row);
+    int row = ui->input_files_list->row( list.at(i) );
+    delete ui->input_files_list->takeItem(row);
   }
 }
 
 void 
-BL::FilesPage::input_itemSelectionChanged()
+FilesPage::input_itemSelectionChanged()
 {
-  if (_input_files_list->selectedItems().size() > 0)
-    _remove_input_files_button->setEnabled(true);
+  if (ui->input_files_list->selectedItems().size() > 0)
+    ui->remove_input_files_button->setEnabled(true);
   else
-    _remove_input_files_button->setEnabled(false);
+    ui->remove_input_files_button->setEnabled(false);
 }
 
 void
-BL::FilesPage::add_output_file()
+FilesPage::add_output_file()
 {
   QListWidgetItem * new_item = new QListWidgetItem("TO EDIT!");
   new_item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
-  _output_files_list->addItem(new_item);
+  ui->output_files_list->addItem(new_item);
+  emit completeChanged();
 }
 
 void 
-BL::FilesPage::remove_output_files()
+FilesPage::remove_output_files()
 {
-  QList<QListWidgetItem *> list = _output_files_list->selectedItems();
+  QList<QListWidgetItem *> list = ui->output_files_list->selectedItems();
   for (int i = 0; i < list.size(); ++i)
   {
-    int row = _output_files_list->row( list.at(i) );
-    delete _output_files_list->takeItem(row);
+    int row = ui->output_files_list->row( list.at(i) );
+    delete ui->output_files_list->takeItem(row);
   }
+  emit completeChanged();
 }
 
 void 
-BL::FilesPage::output_itemSelectionChanged()
+FilesPage::output_itemSelectionChanged()
 {
-  if (_output_files_list->selectedItems().size() > 0)
-    _remove_output_files_button->setEnabled(true);
+  if (ui->output_files_list->selectedItems().size() > 0)
+    ui->remove_output_files_button->setEnabled(true);
   else
-    _remove_output_files_button->setEnabled(false);
+    ui->remove_output_files_button->setEnabled(false);
 }
 
 int 
-BL::FilesPage::nextId() const
+FilesPage::nextId() const
 {
-  return BL::CreateJobWizard::Page_Conclusion;
+  return BL::CreateJobWizard::Page_Advanced;
 }
 
 BL::ConclusionPage::ConclusionPage(QWidget * parent)
@@ -989,6 +1134,18 @@ BL::ResourcePage::initializePage()
     _ll_label->show();
     _ll_value->show();
   }
+
+  // Initialize resource_choosed with first resource in resource list
+  if (field("resource_choosed").toString() == "")
+  {
+    std::list<std::string> resource_list = _salome_services->getResourceList(true);
+    std::list<std::string>::iterator it = resource_list.begin();
+    if (it != resource_list.end())
+    {
+      QString first_resource((*it).c_str());
+      setField("resource_choosed", first_resource);
+    }
+  }
 }
 
 bool
@@ -1001,7 +1158,7 @@ BL::ResourcePage::validatePage()
     return false;
   }
 
-  BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(resource_choosed.toStdString());
+  BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(resource_choosed.toUtf8().constData());
   std::string batch = resource_descr.batch.c_str();
   if (batch == "ll")
   {
@@ -1023,7 +1180,7 @@ BL::ResourcePage::itemSelected(QListWidgetItem * item)
   _resource_choosed->setReadOnly(true);
 
   //Specific parameters for LoadLeveler
-  BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(item->text().toStdString());
+  BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(item->text().toUtf8().constData());
   std::string batch = resource_descr.batch.c_str();
   if (batch == "ll")
   {
@@ -1044,7 +1201,16 @@ BL::ResourcePage::itemSelected(QListWidgetItem * item)
 int 
 BL::ResourcePage::nextId() const
 {
-  return BL::CreateJobWizard::Page_BatchParameters;
+  BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(_resource_choosed->text().toUtf8().constData());
+  std::string batch = resource_descr.batch.c_str();
+  if (batch == "coorm")
+  {
+         return BL::CreateJobWizard::Page_COORM_BatchParameters;
+  }
+  else
+  {
+         return BL::CreateJobWizard::Page_BatchParameters;
+  }
 }
 
 BL::PythonSalomeMainPage::PythonSalomeMainPage(QWidget * parent)
@@ -1122,3 +1288,24 @@ BL::PythonSalomeMainPage::nextId() const
 {
   return BL::CreateJobWizard::Page_Resource;
 }
+
+
+
+AdvancedParametersPage::AdvancedParametersPage(CreateJobWizard * parent)
+: QWizardPage(parent),
+  ui(new Ui::AdvancedParametersWizardPage)
+{
+  ui->setupUi(this);
+  registerField("wckey", ui->line_wckey);
+};
+
+AdvancedParametersPage::~AdvancedParametersPage()
+{
+  delete ui;
+}
+
+int
+AdvancedParametersPage::nextId() const
+{
+  return BL::CreateJobWizard::Page_Conclusion;
+}