Salome HOME
Fix bug preventing to change the type of a cloned job
[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       enum {YACS, COMMAND, PYTHON_SALOME} job_type;
71
72       std::string yacs_file;
73       std::string command;
74       std::string python_salome_file;
75
76       std::string env_file;
77
78       std::string batch_directory;
79
80       // For COORM
81       std::string coorm_batch_directory;
82
83       std::string maximum_duration;
84       long mem_limit;
85       BL::Job::MemReqType mem_req_type;
86       int nb_proc;
87       bool exclusive;
88
89       // Parameters for COORM
90       std::string launcher_file;
91       std::string launcher_args;
92
93       std::string result_directory;
94       std::list<std::string> input_files_list;
95       std::list<std::string> output_files_list;
96
97       std::string resource_choosed;
98       std::string batch_queue;
99       std::string wckey;
100       std::string extra_params;
101
102       bool start_job;
103       int dump_yacs_state;
104       std::string ll_jobtype;
105
106     public:
107       enum {Page_JobName,
108             Page_YACSSchema,
109             Page_Command_Main_Definitions,
110             Page_PythonSalome_Main_Definitions,
111             Page_BatchParameters,
112             Page_COORM_BatchParameters,
113             Page_Files,
114             Page_Resource,
115             Page_Advanced,
116             Page_Conclusion};
117   };
118
119   class JobNamePage: public QWizardPage
120   {
121     Q_OBJECT
122
123     public:
124       JobNamePage(QWidget * parent, BL::JobsManager_QT * jobs_manager);
125       virtual ~JobNamePage();
126
127       virtual bool validatePage();
128       virtual int nextId() const ;
129       virtual void cleanupPage() {}
130
131     public slots:
132       void yacs_schema_button(bool checked);
133       void command_button(bool checked);
134       void python_salome_button(bool checked);
135
136     private:
137       BL::JobsManager_QT * _jobs_manager;
138       QLabel * _explanation;
139
140     public:
141       bool _check_name;
142   };
143
144   class ConclusionPage: public QWizardPage
145   {
146     public:
147       ConclusionPage(QWidget * parent);
148       virtual ~ConclusionPage();
149
150       virtual bool validatePage();
151       virtual int nextId() const ;
152       virtual void cleanupPage() {}
153   };
154
155   class BatchParametersPage: public QWizardPage
156   {
157     Q_OBJECT
158
159     public:
160       enum MemUnit {MB, GB};
161
162       BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services);
163       virtual ~BatchParametersPage();
164
165       virtual void initializePage();
166       virtual int nextId() const;
167       virtual void cleanupPage();
168
169       MemUnit getMemUnit() const;
170       void setMemUnit(MemUnit mem_unit);
171
172       BL::Job::MemReqType getMemReqType() const;
173       void setMemReqType(BL::Job::MemReqType mem_req_type);
174
175     public slots:
176       void timeChanged();
177       void memChanged();
178
179     private:
180       Ui::ResourceRequirementsWizardPage * ui;
181       BL::SALOMEServices * _salome_services;
182       std::string resource_choosed;
183   };
184
185   // For COORM
186   class COORM_BatchParametersPage: public QWizardPage
187   {
188     Q_OBJECT
189
190     public:
191       COORM_BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services);
192       virtual ~COORM_BatchParametersPage();
193
194       virtual bool validatePage();
195       virtual int nextId() const;
196       virtual void cleanupPage();
197       virtual void initializePage();
198
199     public slots:
200       void choose_launcher_file();
201
202     private:
203       BL::SALOMEServices * _salome_services;
204       QLineEdit * _launcher_file_text;
205       QString resource_choosed;
206   };
207
208   class FilesPage: public QWizardPage
209   {
210     Q_OBJECT
211
212     public:
213       FilesPage(BL::CreateJobWizard * parent, BL::SALOMEServices * salome_services);
214       virtual ~FilesPage();
215
216       virtual void initializePage();
217       virtual int nextId() const;
218       virtual bool isComplete() const;
219       virtual void cleanupPage() {}
220
221     public slots:
222       void choose_input_files();
223       void remove_input_files();
224       void input_itemSelectionChanged();
225       void choose_local_directory();
226
227       void add_output_file();
228       void remove_output_files();
229       void output_itemSelectionChanged();
230
231     private:
232       Ui::FilesWizardPage * ui;
233       BL::SALOMEServices * _salome_services;
234       QString resource_choosed;
235   };
236
237   class ResourcePage: public QWizardPage
238   {
239     Q_OBJECT
240
241     public:
242       ResourcePage(BL::CreateJobWizard * parent, BL::SALOMEServices * salome_services);
243       virtual ~ResourcePage();
244
245       virtual int nextId() const;
246       virtual bool validatePage();
247       virtual void initializePage();
248       virtual void cleanupPage() {}
249
250     public slots:
251       void itemSelected(QListWidgetItem * item);
252
253     private:
254       JM::ResourceCatalog * _resource_list;
255       QLineEdit * _resource_choosed;
256       BL::SALOMEServices * _salome_services;
257
258       QLabel * _ll_label;
259       QLineEdit * _ll_value;
260       QGridLayout * _main_layout;
261   };
262
263   class YACSSchemaPage: public QWizardPage
264   {
265     Q_OBJECT
266
267     public:
268       YACSSchemaPage(QWidget * parent);
269       virtual ~YACSSchemaPage();
270
271       virtual bool validatePage();
272       virtual int nextId() const ;
273       virtual void cleanupPage() {}
274
275     public slots:
276       void choose_file();
277       void choose_env_file();
278
279     private:
280       QLineEdit * _yacs_file_text;
281       QLineEdit * _line_env_file;
282   };
283
284   class CommandMainPage: public QWizardPage
285   {
286     Q_OBJECT
287
288     public:
289       CommandMainPage(QWidget * parent);
290       virtual ~CommandMainPage();
291
292       virtual bool validatePage();
293       virtual int nextId() const ;
294       virtual void cleanupPage() {}
295
296     public slots:
297       void choose_command_file();
298       void choose_env_file();
299
300     private:
301       QLineEdit * _line_command;
302       QLineEdit * _line_env_file;
303   };
304
305   class PythonSalomeMainPage: public QWizardPage
306   {
307     Q_OBJECT
308
309     public:
310       PythonSalomeMainPage(QWidget * parent);
311       virtual ~PythonSalomeMainPage();
312
313       virtual bool validatePage();
314       virtual int nextId() const ;
315       virtual void cleanupPage() {}
316
317     public slots:
318       void choose_PythonSalome_file();
319       void choose_env_file();
320
321     private:
322       QLineEdit * _line_PythonSalome;
323       QLineEdit * _line_env_file;
324   };
325
326   class AdvancedParametersPage: public QWizardPage
327   {
328     Q_OBJECT
329
330     public:
331       AdvancedParametersPage(BL::CreateJobWizard * parent);
332       virtual ~AdvancedParametersPage();
333
334       virtual int nextId() const;
335       virtual void cleanupPage() {}
336
337     private:
338       Ui::AdvancedParametersWizardPage * ui;
339
340   };
341
342 }
343
344 #endif
345