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