]> SALOME platform Git repositories - modules/jobmanager.git/blob - src/genericgui/BL_CreateJobWizard.cxx
Salome HOME
You can now add options to the "driver" command of a YACS job.
[modules/jobmanager.git] / src / genericgui / BL_CreateJobWizard.cxx
1 // Copyright (C) 2009-2015  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "BL_CreateJobWizard.hxx"
21 #include "BL_JobsManager_QT.hxx"
22
23 #include <QFileDialog>
24 #include <QMessageBox>
25
26 #ifndef WNT
27 #include <unistd.h>
28 #include <pwd.h>
29 #endif
30 #include <sys/types.h>
31 #include <stdlib.h>
32 #include <time.h>
33
34 #include <ui_ResourceRequirementsWizardPage.h>
35 #include <ui_FilesWizardPage.h>
36 #include <ui_AdvancedParametersWizardPage.h>
37
38 #ifdef WNT
39 #undef ERROR
40 #endif
41
42 using namespace std;
43 using namespace BL;
44
45 BL::CreateJobWizard::CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALOMEServices * salome_services)
46 {
47   DEBTRACE("Creating BL::CreateJobWizard");
48   BL_ASSERT(jobs_manager);
49   BL_ASSERT(salome_services);
50   _jobs_manager = jobs_manager;
51   _salome_services = salome_services;
52
53   job_name = "";
54   job_type = YACS;
55   yacs_file = "";
56   command = "";
57   python_salome_file = "";
58   env_file = "";
59   batch_directory = "";
60
61   // For COORM
62   coorm_batch_directory = "";
63
64   maximum_duration = "";
65   mem_limit = 0;
66   mem_req_type = BL::Job::MEM_PER_NODE;
67   nb_proc = 1;
68
69   // Parameters for COORM
70   launcher_file = "";
71   launcher_args = "";
72
73   result_directory = "";
74
75   resource_choosed = "";
76   batch_queue = "";
77
78   start_job = false;
79   dump_yacs_state = -1;
80   yacs_driver_options = "";
81   ll_jobtype = "";
82
83   setOptions(QWizard::NoBackButtonOnStartPage);
84
85   // Common pages
86   _job_name_page = new BL::JobNamePage(this, _jobs_manager);
87   _batch_parameters_page = new BL::BatchParametersPage(this, salome_services);
88
89   setPage(Page_JobName, _job_name_page);
90   setPage(Page_BatchParameters, _batch_parameters_page);
91
92   // For COORM
93   setPage(Page_COORM_BatchParameters, new BL::COORM_BatchParametersPage(this, salome_services));
94
95   setPage(Page_Files, new BL::FilesPage(this, salome_services));
96   setPage(Page_Resource, new BL::ResourcePage(this, salome_services));
97   setPage(Page_Advanced, new BL::AdvancedParametersPage(this));
98   setPage(Page_Conclusion, new BL::ConclusionPage(this));
99
100   // Specific pages
101   setPage(Page_YACSSchema, new BL::YACSSchemaPage(this));
102   setPage(Page_Command_Main_Definitions, new BL::CommandMainPage(this));
103   setPage(Page_PythonSalome_Main_Definitions, new BL::PythonSalomeMainPage(this));
104
105   setWindowTitle("Create Job Wizard");
106   connect(this, SIGNAL(finished(int)), this, SLOT(end(int)));
107 }
108
109 BL::CreateJobWizard::~CreateJobWizard()
110 {
111   DEBTRACE("Destroying BL::CreateJobWizard");
112 }
113
114 void
115 BL::CreateJobWizard::clone(const std::string & name)
116 {
117   if (_jobs_manager->job_already_exist(name) == true)
118   {
119     BL::Job * job = _jobs_manager->getJob(name);
120
121     // We can only edit a job in CREATED, ERROR, FAILED and NOT_CREATED
122     if (job->getState() == BL::Job::CREATED ||
123         job->getState() == BL::Job::ERROR   ||
124         job->getState() == BL::Job::FAILED  ||
125         job->getState() == BL::Job::NOT_CREATED)
126     { 
127       setField("job_name", QString(name.c_str()));
128       _job_name_page->_check_name = false;
129     }
130
131     if (job->getType() == BL::Job::YACS_SCHEMA)
132     {
133       setField("yacs_file", QString(job->getJobFile().c_str()));
134       setField("job_type_yacs", true);
135       setField("env_yacs_file", QString(job->getEnvFile().c_str()));
136       if (job->getDumpYACSState() != -1)
137       {
138         QString value;
139         value.setNum(job->getDumpYACSState());
140         setField("dump_yacs_state", value);
141       }
142       if (not job->getYacsDriverOptions().empty())
143       {
144         setField("yacs_driver_options", job->getYacsDriverOptions().c_str());
145       }
146     }
147     else if (job->getType() == BL::Job::COMMAND)
148     {
149       setField("command", QString(job->getJobFile().c_str()));
150       setField("job_type_command", true);
151       setField("env_command_file", QString(job->getEnvFile().c_str()));
152     }
153     else if (job->getType() == BL::Job::PYTHON_SALOME)
154     {
155       setField("PythonSalome", QString(job->getJobFile().c_str()));
156       setField("job_type_python_salome", true);
157       setField("env_PythonSalome_file", QString(job->getEnvFile().c_str()));
158     }
159
160
161         // For COORM
162     BL::Job::BatchParam batch_params = job->getBatchParameters();
163         BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(job->getResource().c_str());
164         std::string batch = resource_descr.batch.c_str();
165         if (batch == "coorm")
166         {
167                 setField("coorm_batch_directory", QString(batch_params.batch_directory.c_str()));
168                 setField("launcher_file", QString(batch_params.launcher_file.c_str()));
169                 setField("launcher_args", QString(batch_params.launcher_args.c_str()));
170         }
171         else
172         {
173                 setField("batch_directory", QString(batch_params.batch_directory.c_str()));
174         }
175
176     QString proc_value;
177     proc_value.setNum(batch_params.nb_proc);
178     setField("proc_value", proc_value);
179
180     setField("exclusive", batch_params.exclusive);
181
182     if (batch_params.maximum_duration == "")
183     {
184       setField("default_time", true);
185       setField("duration_hour", 0);
186       setField("duration_min", 0);
187     }
188     else
189     {
190       setField("user_time", true);
191       std::size_t pos = batch_params.maximum_duration.find(":");
192       std::string hour_str = batch_params.maximum_duration.substr(0, pos);
193       int hour; 
194       std::istringstream iss_hour(hour_str);
195       iss_hour >> hour;
196       setField("duration_hour", hour);
197
198       std::string min_str = batch_params.maximum_duration.substr(pos + 1, batch_params.maximum_duration.npos);
199       int min; 
200       std::istringstream iss_min(min_str);
201       iss_min >> min;
202       setField("duration_min", min);
203     }
204
205     long long mem_mb = batch_params.mem_limit;
206     if (mem_mb < 1)
207     {
208       setField("default_mem", true);
209     }
210     else
211     {
212       setField("user_mem", true);
213       if (mem_mb % 1024 == 0)
214       {
215         setField("mem_value", mem_mb / 1024);
216         _batch_parameters_page->setMemUnit(BatchParametersPage::GB);
217       }
218       else
219       {
220         setField("mem_value", mem_mb);
221         _batch_parameters_page->setMemUnit(BatchParametersPage::MB);
222       }
223       _batch_parameters_page->setMemReqType(batch_params.mem_req_type);
224     }
225
226     BL::Job::FilesParam files_params = job->getFilesParameters();
227
228     std::list<std::string>::iterator it = files_params.input_files_list.begin();
229     for (; it != files_params.input_files_list.end(); it++)
230       _input_files_list->addItem(QString((*it).c_str()));
231     it = files_params.output_files_list.begin();
232     for (; it != files_params.output_files_list.end(); it++)
233       _output_files_list->addItem(QString((*it).c_str()));
234
235     setField("result_directory", QString(files_params.result_directory.c_str()));
236     setField("resource_choosed", QString(job->getResource().c_str()));
237     setField("batch_queue", QString(job->getBatchQueue().c_str()));
238     setField("ll_jobtype", QString(job->getLoadLevelerJobType().c_str()));
239     setField("wckey", QString(job->getWCKey().c_str()));
240     setField("extra_params", QString(job->getExtraParams().c_str()));
241   }
242 }
243
244 void
245 BL::CreateJobWizard::setFilesList(QListWidget * input_files_list, QListWidget * output_files_list)
246 {
247   _input_files_list = input_files_list;
248   _output_files_list = output_files_list;
249 }
250
251 void
252 BL::CreateJobWizard::end(int result)
253 {
254   DEBTRACE("End of BL::CreateJobWizard");
255   if (result)
256   {
257     // Job Name Panel
258     QString f_job_name = field("job_name").toString();
259     job_name = f_job_name.trimmed().toUtf8().constData();
260     if (field("job_type_yacs").toBool())
261       job_type = YACS;
262     else if (field("job_type_command").toBool())
263       job_type = COMMAND;
264     else
265       job_type = PYTHON_SALOME;
266
267     // YACS Schema Panel
268     QString f_yacs_file = field("yacs_file").toString();
269     yacs_file = f_yacs_file.trimmed().toUtf8().constData();
270     dump_yacs_state = field("dump_yacs_state").toInt();
271     yacs_driver_options = field("yacs_driver_options").toString().trimmed().toUtf8().constData();
272
273     // Command Panel
274     QString f_command = field("command").toString();
275     command = f_command.trimmed().toUtf8().constData();
276
277     // Command Panel
278     QString f_python_salome_file = field("PythonSalome").toString();
279     python_salome_file = f_python_salome_file.trimmed().toUtf8().constData();
280
281     QString f_env_file;
282     if (job_type == YACS)
283       f_env_file = field("env_yacs_file").toString();
284     else if (job_type == COMMAND)
285       f_env_file = field("env_command_file").toString();
286     else if (job_type == PYTHON_SALOME)
287       f_env_file = field("env_PythonSalome_file").toString();
288     env_file = f_env_file.trimmed().toUtf8().constData();
289
290     // Batch Panel
291     QString f_batch_directory = field("batch_directory").toString();
292     batch_directory = f_batch_directory.trimmed().toUtf8().constData();
293
294     // For COORM
295     QString f_coorm_batch_directory = field("coorm_batch_directory").toString();
296     coorm_batch_directory = f_coorm_batch_directory.toUtf8().constData();
297
298         // For COORM
299     QString f_launcher_file = field("launcher_file").toString();
300     launcher_file = f_launcher_file.toUtf8().constData();
301     QString f_launcher_args = field("launcher_args").toString();
302     launcher_args = f_launcher_args.toUtf8().constData();
303
304     QString time_hour;
305     QString time_min;
306     if (field("default_time").toBool() ||
307         (field("duration_hour").toInt() == 0 && field("duration_min").toInt() == 0))
308     {
309       maximum_duration = "";
310     }
311     else
312     {
313       if (field("duration_hour").toInt() < 10)
314         time_hour = "0" + field("duration_hour").toString().trimmed();
315       else
316         time_hour = field("duration_hour").toString().trimmed();
317       if (field("duration_min").toInt() < 10)
318         time_min = "0" + field("duration_min").toString().trimmed();
319       else
320         time_min = field("duration_min").toString().trimmed();
321       maximum_duration = time_hour.toStdString() + ":" + time_min.toStdString();
322     }
323
324     if(field("default_mem").toBool())
325     {
326       mem_limit = -1;
327     }
328     else
329     {
330       unsigned long mem = field("mem_value").toULongLong();
331       BatchParametersPage::MemUnit mem_unit = _batch_parameters_page->getMemUnit();
332       switch (mem_unit)
333       {
334       case BatchParametersPage::MB:
335         mem_limit = mem;
336         break;
337       case BatchParametersPage::GB:
338         mem_limit = mem * 1024;
339         break;
340       default:
341         throw Exception("Invalid memory unit");
342       }
343       mem_req_type = _batch_parameters_page->getMemReqType();
344     }
345
346     nb_proc = field("proc_value").toInt();
347     exclusive = field("exclusive").toBool();
348
349     // Files Panel
350     QString f_result_directory = field("result_directory").toString();
351     result_directory = f_result_directory.trimmed().toUtf8().constData();
352     for (int i = 0; i < _input_files_list->count(); ++i)
353     {
354       QListWidgetItem * item = _input_files_list->item(i);
355       QString item_text = item->text();
356       input_files_list.push_back(item_text.trimmed().toUtf8().constData());
357     }
358     for (int i = 0; i < _output_files_list->count(); ++i)
359     {
360       QListWidgetItem * item = _output_files_list->item(i);
361       QString item_text = item->text();
362       output_files_list.push_back(item_text.trimmed().toUtf8().constData());
363     }
364
365     // Resource list
366     QString f_resource_choosed = field("resource_choosed").toString();
367     resource_choosed = f_resource_choosed.trimmed().toUtf8().constData();
368
369     // Batch Queue
370     QString f_batch_queue = field("batch_queue").toString();
371     batch_queue = f_batch_queue.trimmed().toUtf8().constData();
372
373     // LoadLeveler JobType
374     BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(resource_choosed);
375     std::string batch = resource_descr.batch.c_str();
376     if (batch == "ll")
377     {
378       QString f_ll_jobtype = field("ll_jobtype").toString();
379       ll_jobtype = f_ll_jobtype.trimmed().toStdString();
380     }
381     else
382     {
383       ll_jobtype = "";
384     }
385
386     // WC Key
387     QString f_wckey = field("wckey").toString();
388     wckey = f_wckey.trimmed().toUtf8().constData();
389
390     // Extra params
391     QString f_extra_params = field("extra_params").toString();
392     extra_params = f_extra_params.trimmed().toUtf8().constData();
393
394     start_job = field("start_job").toBool();
395   }
396 }
397
398 // Job Name Page
399 BL::JobNamePage::JobNamePage(QWidget * parent, BL::JobsManager_QT * jobs_manager)
400 : QWizardPage(parent)
401 {
402   _jobs_manager = jobs_manager;
403   _check_name = true;
404   setTitle("Create a new job");
405
406   QLabel *label = new QLabel("Enter Job name, you cannot add two jobs with the same name");
407   label->setWordWrap(true);
408   QLabel * nameLabel = new QLabel("Job Name:");
409   QLineEdit * _nameLineEdit = new QLineEdit(this);
410   registerField("job_name", _nameLineEdit);
411
412   QLabel * label_type = new QLabel("Choose type of batch job:");
413   QGroupBox *groupBox = new QGroupBox("Type of job");
414   QRadioButton * _yacs_schema_button = new QRadioButton(tr("YACS Schema"));
415   _yacs_schema_button->setChecked(true);
416   QRadioButton * _command_button = new QRadioButton(tr("Command"));
417   QRadioButton * _python_salome_button = new QRadioButton(tr("Python script in SALOME"));
418   QVBoxLayout *vbox = new QVBoxLayout;
419   vbox->addWidget(_yacs_schema_button);
420   vbox->addWidget(_command_button);
421   vbox->addWidget(_python_salome_button);
422   vbox->addStretch(1);
423   groupBox->setLayout(vbox);
424   registerField("job_type_yacs", _yacs_schema_button);
425   registerField("job_type_command", _command_button);
426   registerField("job_type_python_salome", _python_salome_button);
427
428   QGroupBox * explanationBox = new QGroupBox("Explanation");
429   QVBoxLayout *explanationvbox = new QVBoxLayout;
430   _explanation = new QLabel();
431   _explanation->setWordWrap(true);
432   explanationvbox->addWidget(_explanation);
433   explanationvbox->addStretch(1);
434   explanationBox->setLayout(explanationvbox);
435
436   // Layouts
437   QVBoxLayout * main_layout = new QVBoxLayout;
438   main_layout->addWidget(label);
439   QGridLayout *layout = new QGridLayout;
440   layout->addWidget(nameLabel, 0, 0);
441   layout->addWidget(_nameLineEdit, 0, 1);
442   main_layout->insertLayout(-1, layout);
443   layout->addWidget(label_type, 2, 0);
444   layout->addWidget(groupBox, 3, 0, 1, -1);
445   layout->addWidget(explanationBox, 4, 0, 1, -1);
446   setLayout(main_layout);
447
448   connect(_yacs_schema_button, SIGNAL(toggled(bool)), this, SLOT(yacs_schema_button(bool)));
449   connect(_command_button, SIGNAL(toggled(bool)), this, SLOT(command_button(bool)));
450   connect(_python_salome_button, SIGNAL(toggled(bool)), this, SLOT(python_salome_button(bool)));
451
452   // Default button
453   yacs_schema_button(true);
454 }
455
456 BL::JobNamePage::~JobNamePage()
457 {}
458
459 void
460 BL::JobNamePage::yacs_schema_button(bool checked)
461 {
462   if (checked)
463   {
464     _explanation->setText("This job permits to launch a YACS schema into a SALOME application");
465     setField("exclusive", true);
466   }
467 }
468
469 void
470 BL::JobNamePage::command_button(bool checked)
471 {
472   if (checked)
473   {
474     _explanation->setText("This job permits to launch a script into a distributed resource. This script is not launched into a SALOME application");
475     setField("exclusive", false);
476   }
477 }
478
479 void
480 BL::JobNamePage::python_salome_button(bool checked)
481 {
482   if (checked)
483   {
484     _explanation->setText("This job permits to launch a python script into a SALOME application");
485     setField("exclusive", true);
486   }
487 }
488
489 bool
490 BL::JobNamePage::validatePage()
491 {
492   DEBTRACE("Calling validatePage of BL::JobNamePage");
493   bool return_value;
494   QString job_name = field("job_name").toString();
495
496   // Check if job name is empty
497   if (job_name == "")
498   {
499     QMessageBox::warning(NULL, "Job Name Error", "Job name entered is empty, enter a job name or cancel the wizard");
500     return_value = false;
501   }
502
503   // Check if job name already exists
504   else {
505     if (_jobs_manager->job_already_exist(job_name.toUtf8().constData()) == false || _check_name == false)
506     {
507       return_value = true;
508     }
509     else
510     {
511       QMessageBox::critical(NULL, "Job Name Error", "Job name entered is already used");
512       QString value("");
513       setField("job_name", value);
514       return_value = false;
515     }
516   }
517
518   return return_value;
519 }
520
521 int
522 BL::JobNamePage::nextId() const
523 {
524   if (field("job_type_yacs").toBool())
525   {
526     return BL::CreateJobWizard::Page_YACSSchema;
527   } 
528   else if (field("job_type_command").toBool())
529   {
530     return BL::CreateJobWizard::Page_Command_Main_Definitions;
531   }
532   else
533   {
534     return BL::CreateJobWizard::Page_PythonSalome_Main_Definitions;
535   }
536 }
537
538 BL::YACSSchemaPage::YACSSchemaPage(QWidget * parent)
539 : QWizardPage(parent)
540 {
541   setTitle("Configure YACS Execution");
542
543   QLabel *label = new QLabel("In this step you have to configure your YACS execution");
544   label->setWordWrap(true);
545
546   QGroupBox * files_param_box = new QGroupBox("YACS job files");
547   QPushButton * yacs_file_button = new QPushButton(tr("Choose YACS Schema file"));
548   connect(yacs_file_button, SIGNAL(clicked()), this, SLOT(choose_file()));
549   _yacs_file_text = new QLineEdit(this);
550   _yacs_file_text->setText("");
551   registerField("yacs_file", _yacs_file_text);
552   _yacs_file_text->setReadOnly(true);
553   QPushButton * command_env_file_button = new QPushButton(tr("Choose an environnement file"));
554   connect(command_env_file_button, SIGNAL(clicked()), this, SLOT(choose_env_file()));
555   _line_env_file = new QLineEdit(this);
556   registerField("env_yacs_file", _line_env_file);
557   _line_env_file->setReadOnly(true);
558   QGridLayout * files_layout = new QGridLayout;
559   files_layout->addWidget(yacs_file_button, 0, 0);
560   files_layout->addWidget(_yacs_file_text, 0, 1);
561   files_layout->addWidget(command_env_file_button, 1, 0);
562   files_layout->addWidget(_line_env_file, 1, 1);
563   files_param_box->setLayout(files_layout);
564
565   QGroupBox * spec_param_box = new QGroupBox("YACS specific parameters");
566   QLabel * label_dump =  new QLabel("Dump YACS state each secs (0 disable this feature)");
567   QLabel * label_driver_options = new QLabel("YACS driver options - see YACS driver documentation.");
568   QSpinBox * spin_dump = new QSpinBox(this);
569   spin_dump->setMinimum(0);
570   spin_dump->setMaximum(1000000);
571   registerField("dump_yacs_state", spin_dump);
572   QLineEdit* edit_yacs_driver_options = new QLineEdit(this);
573   registerField("yacs_driver_options", edit_yacs_driver_options);
574   QGridLayout * specific_layout = new QGridLayout;
575   specific_layout->addWidget(label_dump, 0, 0);
576   specific_layout->addWidget(spin_dump, 0, 1);
577   specific_layout->addWidget(label_driver_options, 1, 0);
578   specific_layout->addWidget(edit_yacs_driver_options, 1, 1);
579   spec_param_box->setLayout(specific_layout);
580
581   QVBoxLayout * main_layout = new QVBoxLayout;
582   main_layout->addWidget(label);
583   main_layout->addWidget(files_param_box);
584   main_layout->addWidget(spec_param_box);
585
586   setLayout(main_layout);
587 };
588
589 BL::YACSSchemaPage::~YACSSchemaPage()
590 {}
591
592 bool
593 BL::YACSSchemaPage::validatePage()
594 {
595   bool return_value;
596   QString yacs_file = field("yacs_file").toString();
597   if (yacs_file != "")
598   {
599     return_value = true;
600   }
601   else
602   {
603     QMessageBox::warning(NULL, "YACS File Error", "Please choose a YACS File");
604     return_value = false;
605   }
606   return return_value;
607 }
608
609 void
610 BL::YACSSchemaPage::choose_file()
611 {
612   QString yacs_file = QFileDialog::getOpenFileName(this,
613                                                    tr("Open YACS files"), "",
614                                                    tr("XML (*.xml);;All Files (*)"));
615   _yacs_file_text->setReadOnly(false);
616   _yacs_file_text->setText(yacs_file);
617   _yacs_file_text->setReadOnly(true);
618 }
619
620 void
621 BL::YACSSchemaPage::choose_env_file()
622 {
623   QString env_file = QFileDialog::getOpenFileName(this,
624                                                   tr("Open environnement file"), "",
625                                                   tr("sh (*.sh);;All Files (*)"));
626   _line_env_file->setReadOnly(false);
627   _line_env_file->setText(env_file);
628   _line_env_file->setReadOnly(true);
629 }
630
631
632 int 
633 BL::YACSSchemaPage::nextId() const
634 {
635   return BL::CreateJobWizard::Page_Resource;
636 }
637
638 BL::CommandMainPage::CommandMainPage(QWidget * parent)
639 : QWizardPage(parent)
640 {
641   setTitle("Define command job");
642   QLabel *label = new QLabel("Enter the command that will be executed into the resource");
643   label->setWordWrap(true);
644
645   // command
646   QPushButton * command_file_button = new QPushButton(tr("Choose a command file"));
647   connect(command_file_button, SIGNAL(clicked()), this, SLOT(choose_command_file()));
648   _line_command = new QLineEdit(this);
649   registerField("command", _line_command);
650   _line_command->setReadOnly(true);
651
652   QPushButton * command_env_file_button = new QPushButton(tr("Choose an environnement file"));
653   connect(command_env_file_button, SIGNAL(clicked()), this, SLOT(choose_env_file()));
654   _line_env_file = new QLineEdit(this);
655   registerField("env_command_file", _line_env_file);
656   _line_env_file->setReadOnly(true);
657
658   QGridLayout *layout = new QGridLayout;
659   layout->addWidget(command_file_button, 0, 0);
660   layout->addWidget(_line_command, 0, 1);
661   layout->addWidget(command_env_file_button, 1, 0);
662   layout->addWidget(_line_env_file, 1, 1);
663
664   QVBoxLayout * main_layout = new QVBoxLayout;
665   main_layout->addWidget(label);
666   main_layout->insertLayout(-1, layout);
667   setLayout(main_layout);
668 };
669
670 BL::CommandMainPage::~CommandMainPage()
671 {}
672
673 void
674 BL::CommandMainPage::choose_command_file()
675 {
676   QString command_file = QFileDialog::getOpenFileName(this,
677                                                       tr("Open command file"), "",
678                                                       tr("sh (*.sh);;All Files (*)"));
679   _line_command->setReadOnly(false);
680   _line_command->setText(command_file);
681   _line_command->setReadOnly(true);
682 }
683
684 void
685 BL::CommandMainPage::choose_env_file()
686 {
687   QString env_file = QFileDialog::getOpenFileName(this,
688                                                   tr("Open environnement file"), "",
689                                                   tr("sh (*.sh);;All Files (*)"));
690   _line_env_file->setReadOnly(false);
691   _line_env_file->setText(env_file);
692   _line_env_file->setReadOnly(true);
693 }
694
695 bool
696 BL::CommandMainPage::validatePage()
697 {
698   QString command = field("command").toString();
699   if (command == "")
700   {
701     QMessageBox::warning(NULL, "Command Error", "Please enter a command");
702     return false;
703   }
704
705   return true;
706 }
707
708 int 
709 BL::CommandMainPage::nextId() const
710 {
711   return BL::CreateJobWizard::Page_Resource;
712 }
713
714 BatchParametersPage::BatchParametersPage(QWidget * parent, SALOMEServices * salome_services)
715 : QWizardPage(parent),
716   ui(new Ui::ResourceRequirementsWizardPage),
717   _salome_services(salome_services),
718   resource_choosed()
719 {
720   ui->setupUi(this);
721
722   registerField("duration_hour", ui->spin_duration_hour);
723   registerField("duration_min", ui->spin_duration_min);
724   registerField("mem_value", ui->spin_memory);
725   registerField("proc_value", ui->spin_proc);
726   registerField("exclusive", ui->check_exclusive);
727   registerField("default_time", ui->rb_default_time);
728   registerField("user_time", ui->rb_user_time);
729   registerField("default_mem", ui->rb_default_mem);
730   registerField("user_mem", ui->rb_user_mem);
731
732   ui->combo_memory_unit->insertItem(ui->combo_memory_unit->count(), "MB", MB);
733   ui->combo_memory_unit->insertItem(ui->combo_memory_unit->count(), "GB", GB);
734   setMemUnit(GB);
735
736   ui->combo_memory_req_type->insertItem(ui->combo_memory_req_type->count(),
737                                         "per node", Job::MEM_PER_NODE);
738   ui->combo_memory_req_type->insertItem(ui->combo_memory_req_type->count(),
739                                         "per core", Job::MEM_PER_CPU);
740
741   connect(ui->spin_duration_hour, SIGNAL(valueChanged(int)), this, SLOT(timeChanged()));
742   connect(ui->spin_duration_min, SIGNAL(valueChanged(int)), this, SLOT(timeChanged()));
743   connect(ui->spin_memory, SIGNAL(valueChanged(int)), this, SLOT(memChanged()));
744   connect(ui->combo_memory_unit, SIGNAL(currentIndexChanged(int)), this, SLOT(memChanged()));
745   connect(ui->combo_memory_req_type, SIGNAL(currentIndexChanged(int)), this, SLOT(memChanged()));
746 };
747
748 BatchParametersPage::~BatchParametersPage()
749 {
750   delete ui;
751 }
752
753 void
754 BatchParametersPage::initializePage()
755 {
756   string f_resource_choosed = field("resource_choosed").toString().toUtf8().constData();
757   if (f_resource_choosed != resource_choosed)
758   {
759     resource_choosed = f_resource_choosed;
760     // If choosed resource has a SLURM batch manager, activate option "memory per cpu"
761     ResourceDescr resource_descr = _salome_services->getResourceDescr(resource_choosed);
762     if (resource_descr.batch == "slurm")
763     {
764       ui->combo_memory_req_type->setEnabled(true);
765     }
766     else
767     {
768       ui->combo_memory_req_type->setEnabled(false);
769       setMemReqType(Job::MEM_PER_NODE);
770     }
771   }
772 }
773
774 BatchParametersPage::MemUnit
775 BatchParametersPage::getMemUnit() const
776 {
777   int idx = ui->combo_memory_unit->currentIndex();
778   return (MemUnit)(ui->combo_memory_unit->itemData(idx).toInt());
779 }
780
781 void
782 BatchParametersPage::setMemUnit(MemUnit mem_unit)
783 {
784   ui->combo_memory_unit->setCurrentIndex(ui->combo_memory_unit->findData(mem_unit));
785 }
786
787 Job::MemReqType
788 BatchParametersPage::getMemReqType() const
789 {
790   int idx = ui->combo_memory_req_type->currentIndex();
791   return (Job::MemReqType)(ui->combo_memory_req_type->itemData(idx).toInt());
792 }
793
794 void
795 BatchParametersPage::setMemReqType(Job::MemReqType mem_req_type)
796 {
797   ui->combo_memory_req_type->setCurrentIndex(ui->combo_memory_req_type->findData(mem_req_type));
798 }
799
800 void
801 BatchParametersPage::timeChanged()
802 {
803   if (ui->spin_duration_hour->value() == 0 && ui->spin_duration_min->value() == 0)
804     ui->rb_default_time->setChecked(true);
805   else
806     ui->rb_user_time->setChecked(true);
807 }
808
809 void
810 BatchParametersPage::memChanged()
811 {
812   ui->rb_user_mem->setChecked(true);
813 }
814
815 void
816 BatchParametersPage::cleanupPage()
817 {
818 }
819
820 int 
821 BatchParametersPage::nextId() const
822 {
823   return CreateJobWizard::Page_Files;
824 }
825
826 BL::COORM_BatchParametersPage::COORM_BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services)
827 : QWizardPage(parent)
828 {
829   setTitle("Enter COORM Parameters");
830   resource_choosed = "";
831
832   _salome_services = salome_services;
833
834   QLabel *label = new QLabel("In this step you define the parameters for COORM");
835   label->setWordWrap(true);
836   QVBoxLayout * main_layout = new QVBoxLayout;
837   main_layout->addWidget(label);
838
839   // coorm_batch_directory
840   QLabel * label_directory = new QLabel("Remote work directory: ");
841   QLineEdit * line_directory = new QLineEdit(this);
842   registerField("coorm_batch_directory", line_directory);
843
844   // launcher_file
845   QPushButton * launcher_file_button = new QPushButton(tr("Choose a launcher file"));
846   connect(launcher_file_button, SIGNAL(clicked()), this, SLOT(choose_launcher_file()));
847   _launcher_file_text = new QLineEdit(this);
848   _launcher_file_text->setText("");
849   registerField("launcher_file", _launcher_file_text);
850   _launcher_file_text->setReadOnly(true);
851
852   // launcher_args
853   QLabel * launcher_args_label = new QLabel("Launcher args:");
854   QLineEdit * launcher_args_text = new QLineEdit(this);
855   registerField("launcher_args", launcher_args_text);
856
857   QGridLayout * layout = new QGridLayout;
858   layout->addWidget(label_directory, 0, 0);
859   layout->addWidget(line_directory, 0, 1);
860   layout->addWidget(launcher_file_button, 1, 0);
861   layout->addWidget(_launcher_file_text, 1, 1);
862   layout->addWidget(launcher_args_label, 2, 0);
863   layout->addWidget(launcher_args_text, 2, 1);
864
865   main_layout->insertLayout(-1, layout);
866
867   setLayout(main_layout);
868 };
869
870 BL::COORM_BatchParametersPage::~COORM_BatchParametersPage()
871 {}
872
873 bool
874 BL::COORM_BatchParametersPage::validatePage()
875 {
876   QString coorm_batch_directory = field("coorm_batch_directory").toString();
877   if (coorm_batch_directory == "")
878   {
879     QMessageBox::warning(NULL, "Batch Directory Error", "Please enter a batch directory");
880     return false;
881   }
882
883   QString launcher_file = field("launcher_file").toString();
884   if (launcher_file == "")
885   {
886     QMessageBox::warning(NULL, "Launcher File Error", "Please enter a launcher file");
887     return false;
888   }
889
890   return true;
891 }
892
893 int
894 BL::COORM_BatchParametersPage::nextId() const
895 {
896   return BL::CreateJobWizard::Page_Files;
897 }
898
899 void
900 BL::COORM_BatchParametersPage::choose_launcher_file()
901 {
902   QString launcher_file = QFileDialog::getOpenFileName(this,
903                                                    tr("Open launcher files"), "",
904                                                    tr("Py (*.py);;All Files (*)"));
905   _launcher_file_text->setReadOnly(false);
906   _launcher_file_text->setText(launcher_file);
907   _launcher_file_text->setReadOnly(true);
908 }
909
910 void BL::COORM_BatchParametersPage::cleanupPage()
911 {}
912
913 void
914 BL::COORM_BatchParametersPage::initializePage()
915 {
916   QString f_resource_choosed = field("resource_choosed").toString();
917   if (f_resource_choosed != resource_choosed)
918   {
919     resource_choosed = f_resource_choosed;
920     // If choosed resource has a working_directory set
921     // Generates a default remote working directory
922     BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(resource_choosed.toUtf8().constData());
923     QString res_work_dir = resource_descr.working_directory.c_str();
924     if (res_work_dir != "")
925     {
926       time_t rawtime;
927       time(&rawtime);
928       std::string launch_date = ctime(&rawtime);
929       for (int i = 0; i < launch_date.size(); i++)
930         if (launch_date[i] == '/' ||
931             launch_date[i] == '-' ||
932             launch_date[i] == ':' ||
933             launch_date[i] == ' ')
934           launch_date[i] = '_';
935       launch_date.erase(--launch_date.end()); // Last caracter is a \n
936       QString date = launch_date.c_str();
937       setField("coorm_batch_directory", res_work_dir + "/" + date);
938     }
939   }
940 }
941
942 FilesPage::FilesPage(CreateJobWizard * parent, SALOMEServices * salome_services)
943 : QWizardPage(parent),
944   ui(new Ui::FilesWizardPage)
945 {
946   ui->setupUi(this);
947
948   resource_choosed = "";
949   _salome_services = salome_services;
950
951   connect(ui->add_input_files_button, SIGNAL(clicked()), this, SLOT(choose_input_files()));
952   connect(ui->remove_input_files_button, SIGNAL(clicked()), this, SLOT(remove_input_files()));
953   connect(ui->input_files_list, SIGNAL(itemSelectionChanged()), this, SLOT(input_itemSelectionChanged()));
954   connect(ui->add_output_files_button, SIGNAL(clicked()), this, SLOT(add_output_file()));
955   connect(ui->remove_output_files_button, SIGNAL(clicked()), this, SLOT(remove_output_files()));
956   connect(ui->output_files_list, SIGNAL(itemSelectionChanged()), this, SLOT(output_itemSelectionChanged()));
957   connect(ui->button_choose_result_dir, SIGNAL(clicked()), this, SLOT(choose_local_directory()));
958
959   registerField("batch_directory", ui->line_remote_working_dir);
960   registerField("result_directory", ui->line_result_dir);
961
962   // Default result directory is home directory (if we found it)
963   // First try -> HOME
964 #ifdef WNT
965   ui->line_result_dir->setText(getenv("HOME"));
966 #else
967   if (getenv("HOME"))
968     ui->line_result_dir->setText(getenv("HOME"));
969   else {
970     // Second try -> getpwuid
971     struct passwd * pass_struct = getpwuid(getuid());
972     if (pass_struct)
973       ui->line_result_dir->setText(pass_struct->pw_dir);
974   }
975 #endif
976
977   parent->setFilesList(ui->input_files_list, ui->output_files_list);
978
979   // Check for warning messages
980   ui->label_warning_icon->setPixmap(QIcon::fromTheme("dialog-error").pixmap(16, 16));
981   connect(ui->line_remote_working_dir, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged()));
982   connect(ui->line_result_dir, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged()));
983 };
984
985 FilesPage::~FilesPage()
986 {
987   delete ui;
988 }
989
990 void
991 FilesPage::initializePage()
992 {
993   QString f_resource_choosed = field("resource_choosed").toString();
994   if (f_resource_choosed != resource_choosed)
995   {
996     resource_choosed = f_resource_choosed;
997     // If choosed resource has a working_directory set
998     // Generates a default remote working directory
999     BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(resource_choosed.toUtf8().constData());
1000     QString res_work_dir = resource_descr.working_directory.c_str();
1001     if (res_work_dir != "")
1002     {
1003       time_t rawtime;
1004       time(&rawtime);
1005       std::string launch_date = ctime(&rawtime);
1006       for (int i = 0; i < launch_date.size(); i++)
1007         if (launch_date[i] == '/' ||
1008             launch_date[i] == '-' ||
1009             launch_date[i] == ':' ||
1010             launch_date[i] == ' ')
1011           launch_date[i] = '_';
1012       launch_date.erase(--launch_date.end()); // Last caracter is a \n
1013       QString date = launch_date.c_str();
1014       setField("batch_directory", res_work_dir + "/" + date);
1015     }
1016   }
1017 }
1018
1019 bool
1020 FilesPage::isComplete() const
1021 {
1022   QString warn_msg;
1023   if (field("batch_directory").toString().isEmpty())
1024     warn_msg = "Remote working directory is mandatory.";
1025   if (field("result_directory").toString().isEmpty() && ui->output_files_list->count() != 0)
1026   {
1027     if (!warn_msg.isEmpty()) warn_msg += "\n";
1028     warn_msg += "Result directory is mandatory if there are output files.";
1029   }
1030
1031   ui->label_warning_text->setText(warn_msg);
1032   if (warn_msg.isEmpty())
1033   {
1034     ui->label_warning_icon->hide();
1035     return true;
1036   }
1037   else
1038   {
1039     ui->label_warning_icon->show();
1040     return false;
1041   }
1042 }
1043
1044 void
1045 FilesPage::choose_input_files()
1046 {
1047   QStringList files = QFileDialog::getOpenFileNames(this,
1048                                                     tr("Add input files"), "",
1049                                                     tr("All Files (*)"));
1050   for (int i = 0; i < files.size(); ++i) 
1051   {
1052     if (ui->input_files_list->findItems(files.at(i), Qt::MatchFixedString).size() == 0)
1053       ui->input_files_list->addItem(files.at(i));
1054   }
1055 }
1056
1057 void
1058 FilesPage::choose_local_directory()
1059 {
1060   QString dir = QFileDialog::getExistingDirectory(this, tr("Choose local result directory"),
1061                                                  "",
1062                                                  QFileDialog::ShowDirsOnly
1063                                                  | QFileDialog::DontResolveSymlinks);
1064
1065   if (dir != "")
1066     ui->line_result_dir->setText(dir);
1067 }
1068
1069 void 
1070 FilesPage::remove_input_files()
1071 {
1072   QList<QListWidgetItem *> list = ui->input_files_list->selectedItems();
1073   for (int i = 0; i < list.size(); ++i)
1074   {
1075     int row = ui->input_files_list->row( list.at(i) );
1076     delete ui->input_files_list->takeItem(row);
1077   }
1078 }
1079
1080 void 
1081 FilesPage::input_itemSelectionChanged()
1082 {
1083   if (ui->input_files_list->selectedItems().size() > 0)
1084     ui->remove_input_files_button->setEnabled(true);
1085   else
1086     ui->remove_input_files_button->setEnabled(false);
1087 }
1088
1089 void
1090 FilesPage::add_output_file()
1091 {
1092   QListWidgetItem * new_item = new QListWidgetItem("TO EDIT!");
1093   new_item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
1094   ui->output_files_list->addItem(new_item);
1095   emit completeChanged();
1096 }
1097
1098 void 
1099 FilesPage::remove_output_files()
1100 {
1101   QList<QListWidgetItem *> list = ui->output_files_list->selectedItems();
1102   for (int i = 0; i < list.size(); ++i)
1103   {
1104     int row = ui->output_files_list->row( list.at(i) );
1105     delete ui->output_files_list->takeItem(row);
1106   }
1107   emit completeChanged();
1108 }
1109
1110 void 
1111 FilesPage::output_itemSelectionChanged()
1112 {
1113   if (ui->output_files_list->selectedItems().size() > 0)
1114     ui->remove_output_files_button->setEnabled(true);
1115   else
1116     ui->remove_output_files_button->setEnabled(false);
1117 }
1118
1119 int 
1120 FilesPage::nextId() const
1121 {
1122   return BL::CreateJobWizard::Page_Advanced;
1123 }
1124
1125 BL::ConclusionPage::ConclusionPage(QWidget * parent)
1126 : QWizardPage(parent)
1127 {
1128   setTitle("Job definition is finished");
1129   QCheckBox * check_box =  new QCheckBox("Start job after creation");
1130   registerField("start_job", check_box);
1131   QVBoxLayout * main_layout = new QVBoxLayout;
1132   main_layout->addWidget(check_box);
1133   setLayout(main_layout);
1134 };
1135
1136 BL::ConclusionPage::~ConclusionPage()
1137 {}
1138
1139 bool
1140 BL::ConclusionPage::validatePage()
1141 {
1142   return true;
1143 }
1144
1145 int 
1146 BL::ConclusionPage::nextId() const
1147 {
1148   return -1;
1149 }
1150
1151 BL::ResourcePage::ResourcePage(BL::CreateJobWizard * parent, BL::SALOMEServices * salome_services)
1152 : QWizardPage(parent)
1153 {
1154   _salome_services = salome_services;
1155   setTitle("Select a Resource");
1156
1157   QLabel * main_label = new QLabel("In this step you select the resource of your job");
1158   main_label->setWordWrap(true);
1159
1160   // input_Resource
1161   QGroupBox * resource_group_box = new QGroupBox("Resource List");
1162   _resource_list = new JM::ResourceCatalog(this, _salome_services, true);
1163   connect(_resource_list->getQListWidget(), SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem*)));
1164
1165   QVBoxLayout * resource_list_layout = new QVBoxLayout();
1166   resource_list_layout->addWidget(_resource_list);
1167   resource_group_box->setLayout(resource_list_layout);
1168
1169   QLabel * resource_label = new QLabel("Resource selected: ");
1170   _resource_choosed = new QLineEdit();
1171   _resource_choosed->setText("");
1172   _resource_choosed->setReadOnly(true);
1173   registerField("resource_choosed", _resource_choosed);
1174
1175   QLabel * bqLabel = new QLabel("Batch Queue (could be optional):");
1176   QLineEdit * _bqLineEdit = new QLineEdit(this);
1177   registerField("batch_queue", _bqLineEdit);
1178
1179   _ll_label = new QLabel("LoadLeveler JobType:", this);
1180   _ll_value = new QLineEdit(this);
1181   registerField("ll_jobtype", _ll_value);
1182   _ll_label->hide();
1183   _ll_value->hide();
1184
1185   _main_layout = new QGridLayout;
1186   _main_layout->addWidget(resource_group_box, 0, 0, 1, -1);
1187   _main_layout->addWidget(resource_label, 1, 0);
1188   _main_layout->addWidget(_resource_choosed, 1, 1);
1189   _main_layout->addWidget(bqLabel, 2, 0);
1190   _main_layout->addWidget(_bqLineEdit, 2, 1);
1191   setLayout(_main_layout);
1192
1193 };
1194
1195 BL::ResourcePage::~ResourcePage()
1196 {}
1197
1198 void
1199 BL::ResourcePage::initializePage()
1200 {
1201   if (field("ll_jobtype").toString() != "")
1202   {
1203     _main_layout->addWidget(_ll_label, 3, 0);
1204     _main_layout->addWidget(_ll_value, 3, 1);
1205     _ll_label->show();
1206     _ll_value->show();
1207   }
1208
1209   // Initialize resource_choosed with first resource in resource list
1210   if (field("resource_choosed").toString() == "")
1211   {
1212     std::list<std::string> resource_list = _salome_services->getResourceList(true);
1213     std::list<std::string>::iterator it = resource_list.begin();
1214     if (it != resource_list.end())
1215     {
1216       QString first_resource((*it).c_str());
1217       setField("resource_choosed", first_resource);
1218     }
1219   }
1220 }
1221
1222 bool
1223 BL::ResourcePage::validatePage()
1224 {
1225   QString resource_choosed = field("resource_choosed").toString();
1226   if (resource_choosed == "")
1227   {
1228     QMessageBox::warning(NULL, "Resource Error", "Please choose a resource");
1229     return false;
1230   }
1231
1232   BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(resource_choosed.toUtf8().constData());
1233   std::string batch = resource_descr.batch.c_str();
1234   if (batch == "ll")
1235   {
1236     QString ll_jobtype = field("ll_jobtype").toString();
1237     if (ll_jobtype == "")
1238     {
1239       QMessageBox::warning(NULL, "LoadLeveler Error", "Please define a LoadLeveler JobType");
1240       return false;
1241     }
1242   }
1243   return true;
1244 }
1245
1246 void 
1247 BL::ResourcePage::itemSelected(QListWidgetItem * item)
1248 {
1249   _resource_choosed->setReadOnly(false);
1250   _resource_choosed->setText(item->text());
1251   _resource_choosed->setReadOnly(true);
1252
1253   //Specific parameters for LoadLeveler
1254   BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(item->text().toUtf8().constData());
1255   std::string batch = resource_descr.batch.c_str();
1256   if (batch == "ll")
1257   {
1258     _main_layout->addWidget(_ll_label, 3, 0);
1259     _main_layout->addWidget(_ll_value, 3, 1);
1260     _ll_label->show();
1261     _ll_value->show();
1262   }
1263   else
1264   {
1265     _main_layout->removeWidget(_ll_value);
1266     _main_layout->removeWidget(_ll_label);
1267     _ll_label->hide();
1268     _ll_value->hide();
1269   }
1270 }
1271
1272 int 
1273 BL::ResourcePage::nextId() const
1274 {
1275   BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(_resource_choosed->text().toUtf8().constData());
1276   std::string batch = resource_descr.batch.c_str();
1277   if (batch == "coorm")
1278   {
1279           return BL::CreateJobWizard::Page_COORM_BatchParameters;
1280   }
1281   else
1282   {
1283           return BL::CreateJobWizard::Page_BatchParameters;
1284   }
1285 }
1286
1287 BL::PythonSalomeMainPage::PythonSalomeMainPage(QWidget * parent)
1288 : QWizardPage(parent)
1289 {
1290   setTitle("Define a Python script in SALOME job");
1291   QLabel *label = new QLabel("Enter the Python script that will be executed into the resource");
1292   label->setWordWrap(true);
1293
1294   // PythonSalome
1295   QPushButton * PythonSalome_file_button = new QPushButton(tr("Choose a Python file"));
1296   connect(PythonSalome_file_button, SIGNAL(clicked()), this, SLOT(choose_PythonSalome_file()));
1297   _line_PythonSalome = new QLineEdit(this);
1298   registerField("PythonSalome", _line_PythonSalome);
1299   _line_PythonSalome->setReadOnly(true);
1300
1301   QPushButton * PythonSalome_env_file_button = new QPushButton(tr("Choose an environnement file"));
1302   connect(PythonSalome_env_file_button, SIGNAL(clicked()), this, SLOT(choose_env_file()));
1303   _line_env_file = new QLineEdit(this);
1304   registerField("env_PythonSalome_file", _line_env_file);
1305   _line_env_file->setReadOnly(true);
1306
1307   QGridLayout *layout = new QGridLayout;
1308   layout->addWidget(PythonSalome_file_button, 0, 0);
1309   layout->addWidget(_line_PythonSalome, 0, 1);
1310   layout->addWidget(PythonSalome_env_file_button, 1, 0);
1311   layout->addWidget(_line_env_file, 1, 1);
1312
1313   QVBoxLayout * main_layout = new QVBoxLayout;
1314   main_layout->addWidget(label);
1315   main_layout->insertLayout(-1, layout);
1316   setLayout(main_layout);
1317 };
1318
1319 BL::PythonSalomeMainPage::~PythonSalomeMainPage()
1320 {}
1321
1322 void
1323 BL::PythonSalomeMainPage::choose_PythonSalome_file()
1324 {
1325   QString PythonSalome_file = QFileDialog::getOpenFileName(this,
1326                                                       tr("Open Python script file"), "",
1327                                                       tr("py (*.py);;All Files (*)"));
1328   _line_PythonSalome->setReadOnly(false);
1329   _line_PythonSalome->setText(PythonSalome_file);
1330   _line_PythonSalome->setReadOnly(true);
1331 }
1332
1333 void
1334 BL::PythonSalomeMainPage::choose_env_file()
1335 {
1336   QString env_file = QFileDialog::getOpenFileName(this,
1337                                                       tr("Open environnement file"), "",
1338                                                       tr("sh (*.sh);;All Files (*)"));
1339   _line_env_file->setReadOnly(false);
1340   _line_env_file->setText(env_file);
1341   _line_env_file->setReadOnly(true);
1342 }
1343
1344 bool
1345 BL::PythonSalomeMainPage::validatePage()
1346 {
1347   QString PythonSalome = field("PythonSalome").toString();
1348   if (PythonSalome == "")
1349   {
1350     QMessageBox::warning(NULL, "Python script in SALOME Error", "Please enter a Python script");
1351     return false;
1352   }
1353
1354   return true;
1355 }
1356
1357 int 
1358 BL::PythonSalomeMainPage::nextId() const
1359 {
1360   return BL::CreateJobWizard::Page_Resource;
1361 }
1362
1363
1364
1365 AdvancedParametersPage::AdvancedParametersPage(CreateJobWizard * parent)
1366 : QWizardPage(parent),
1367   ui(new Ui::AdvancedParametersWizardPage)
1368 {
1369   ui->setupUi(this);
1370   registerField("wckey", ui->line_wckey);
1371   registerField("extra_params", ui->text_extra_params, "plainText", "textChanged()");
1372 };
1373
1374 AdvancedParametersPage::~AdvancedParametersPage()
1375 {
1376   delete ui;
1377 }
1378
1379 int
1380 AdvancedParametersPage::nextId() const
1381 {
1382   return BL::CreateJobWizard::Page_Conclusion;
1383 }