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