Salome HOME
Merge branch 'rbe/evol-job-newparams'
[modules/jobmanager.git] / src / genericgui / BL_CreateJobWizard.hxx
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 #ifndef _BL_CREATEJOBWIZARD_HXX_
21 #define _BL_CREATEJOBWIZARD_HXX_
22
23 #include <QtGui>
24
25 #include "BL_Traces.hxx"
26 #include "BL_SALOMEServices.hxx"
27 #include "JM_ResourceCatalog.hxx"
28
29 #include <string>
30 #include <list>
31
32 namespace Ui {
33   class ResourceRequirementsWizardPage;
34   class FilesWizardPage;
35   class AdvancedParametersWizardPage;
36 }
37
38 namespace BL{
39
40   class JobsManager_QT;
41   class JobNamePage;
42   class BatchParametersPage;
43   class CreateJobWizard: public QWizard
44   {
45     Q_OBJECT
46
47     public:
48       CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALOMEServices * salome_services);
49       virtual ~CreateJobWizard();
50
51       void setFilesList(QListWidget * input_files_list, QListWidget * output_files_list);
52
53       void clone(const std::string & name);
54
55     public slots:
56       void end(int result);
57
58     private:
59       BL::JobsManager_QT * _jobs_manager;
60       QListWidget * _input_files_list;
61       QListWidget * _output_files_list;
62
63       BL::JobNamePage * _job_name_page;
64       BL::BatchParametersPage * _batch_parameters_page;
65       BL::SALOMEServices * _salome_services;
66
67     public:
68       // Results
69       std::string job_name;
70
71       std::string yacs_file;
72       std::string command;
73       std::string python_salome_file;
74
75       std::string env_file;
76
77       std::string batch_directory;
78
79       // For COORM
80       std::string coorm_batch_directory;
81
82       std::string maximum_duration;
83       long mem_limit;
84       BL::Job::MemReqType mem_req_type;
85       int nb_proc;
86       bool exclusive;
87
88       // Parameters for COORM
89       std::string launcher_file;
90       std::string launcher_args;
91
92       std::string result_directory;
93       std::list<std::string> input_files_list;
94       std::list<std::string> output_files_list;
95
96       std::string resource_choosed;
97       std::string batch_queue;
98       std::string wckey;
99       std::string extra_params;
100
101       bool start_job;
102       int dump_yacs_state;
103       std::string ll_jobtype;
104
105     public:
106       enum {Page_JobName,
107             Page_YACSSchema,
108             Page_Command_Main_Definitions,
109             Page_PythonSalome_Main_Definitions,
110             Page_BatchParameters,
111             Page_COORM_BatchParameters,
112             Page_Files,
113             Page_Resource,
114             Page_Advanced,
115             Page_Conclusion};
116   };
117
118   class JobNamePage: public QWizardPage
119   {
120     Q_OBJECT
121
122     public:
123       JobNamePage(QWidget * parent, BL::JobsManager_QT * jobs_manager);
124       virtual ~JobNamePage();
125
126       virtual bool validatePage();
127       virtual int nextId() const ;
128       virtual void cleanupPage() {}
129
130     public slots:
131       void yacs_schema_button(bool checked);
132       void command_button(bool checked);
133       void python_salome_button(bool checked);
134
135     private:
136       BL::JobsManager_QT * _jobs_manager;
137       QLabel * _explanation;
138
139     public:
140       QRadioButton * _yacs_schema_button;
141       QRadioButton * _command_button;
142       QRadioButton * _python_salome_button;
143       bool _check_name;
144   };
145
146   class ConclusionPage: public QWizardPage
147   {
148     public:
149       ConclusionPage(QWidget * parent);
150       virtual ~ConclusionPage();
151
152       virtual bool validatePage();
153       virtual int nextId() const ;
154       virtual void cleanupPage() {}
155   };
156
157   class BatchParametersPage: public QWizardPage
158   {
159     Q_OBJECT
160
161     public:
162       enum MemUnit {MB, GB};
163
164       BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services);
165       virtual ~BatchParametersPage();
166
167       virtual void initializePage();
168       virtual int nextId() const;
169       virtual void cleanupPage();
170
171       MemUnit getMemUnit() const;
172       void setMemUnit(MemUnit mem_unit);
173
174       BL::Job::MemReqType getMemReqType() const;
175       void setMemReqType(BL::Job::MemReqType mem_req_type);
176
177     public slots:
178       void timeChanged();
179       void memChanged();
180
181     private:
182       Ui::ResourceRequirementsWizardPage * ui;
183       BL::SALOMEServices * _salome_services;
184       std::string resource_choosed;
185   };
186
187   // For COORM
188   class COORM_BatchParametersPage: public QWizardPage
189   {
190     Q_OBJECT
191
192     public:
193       COORM_BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services);
194       virtual ~COORM_BatchParametersPage();
195
196       virtual bool validatePage();
197       virtual int nextId() const;
198       virtual void cleanupPage();
199       virtual void initializePage();
200
201     public slots:
202       void choose_launcher_file();
203
204     private:
205       BL::SALOMEServices * _salome_services;
206       QLineEdit * _launcher_file_text;
207       QString resource_choosed;
208   };
209
210   class FilesPage: public QWizardPage
211   {
212     Q_OBJECT
213
214     public:
215       FilesPage(BL::CreateJobWizard * parent, BL::SALOMEServices * salome_services);
216       virtual ~FilesPage();
217
218       virtual void initializePage();
219       virtual int nextId() const;
220       virtual bool isComplete() const;
221       virtual void cleanupPage() {}
222
223     public slots:
224       void choose_input_files();
225       void remove_input_files();
226       void input_itemSelectionChanged();
227       void choose_local_directory();
228
229       void add_output_file();
230       void remove_output_files();
231       void output_itemSelectionChanged();
232
233     private:
234       Ui::FilesWizardPage * ui;
235       BL::SALOMEServices * _salome_services;
236       QString resource_choosed;
237   };
238
239   class ResourcePage: public QWizardPage
240   {
241     Q_OBJECT
242
243     public:
244       ResourcePage(BL::CreateJobWizard * parent, BL::SALOMEServices * salome_services);
245       virtual ~ResourcePage();
246
247       virtual int nextId() const;
248       virtual bool validatePage();
249       virtual void initializePage();
250       virtual void cleanupPage() {}
251
252     public slots:
253       void itemSelected(QListWidgetItem * item);
254
255     private:
256       JM::ResourceCatalog * _resource_list;
257       QLineEdit * _resource_choosed;
258       BL::SALOMEServices * _salome_services;
259
260       QLabel * _ll_label;
261       QLineEdit * _ll_value;
262       QGridLayout * _main_layout;
263   };
264
265   class YACSSchemaPage: public QWizardPage
266   {
267     Q_OBJECT
268
269     public:
270       YACSSchemaPage(QWidget * parent);
271       virtual ~YACSSchemaPage();
272
273       virtual bool validatePage();
274       virtual int nextId() const ;
275       virtual void cleanupPage() {}
276
277     public slots:
278       void choose_file();
279       void choose_env_file();
280
281     private:
282       QLineEdit * _yacs_file_text;
283       QLineEdit * _line_env_file;
284   };
285
286   class CommandMainPage: public QWizardPage
287   {
288     Q_OBJECT
289
290     public:
291       CommandMainPage(QWidget * parent);
292       virtual ~CommandMainPage();
293
294       virtual bool validatePage();
295       virtual int nextId() const ;
296       virtual void cleanupPage() {}
297
298     public slots:
299       void choose_command_file();
300       void choose_env_file();
301
302     private:
303       QLineEdit * _line_command;
304       QLineEdit * _line_env_file;
305   };
306
307   class PythonSalomeMainPage: public QWizardPage
308   {
309     Q_OBJECT
310
311     public:
312       PythonSalomeMainPage(QWidget * parent);
313       virtual ~PythonSalomeMainPage();
314
315       virtual bool validatePage();
316       virtual int nextId() const ;
317       virtual void cleanupPage() {}
318
319     public slots:
320       void choose_PythonSalome_file();
321       void choose_env_file();
322
323     private:
324       QLineEdit * _line_PythonSalome;
325       QLineEdit * _line_env_file;
326   };
327
328   class AdvancedParametersPage: public QWizardPage
329   {
330     Q_OBJECT
331
332     public:
333       AdvancedParametersPage(BL::CreateJobWizard * parent);
334       virtual ~AdvancedParametersPage();
335
336       virtual int nextId() const;
337       virtual void cleanupPage() {}
338
339     private:
340       Ui::AdvancedParametersWizardPage * ui;
341
342   };
343
344 }
345
346 #endif
347