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