Salome HOME
Copyright update: 2016
[modules/jobmanager.git] / src / genericgui / BL_CreateJobWizard.hxx
1 // Copyright (C) 2009-2016  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef _BL_CREATEJOBWIZARD_HXX_
21 #define _BL_CREATEJOBWIZARD_HXX_
22
23 #include "BL_Traces.hxx"
24 #include "BL_SALOMEServices.hxx"
25 #include "JM_ResourceCatalog.hxx"
26
27 #include <QWizard>
28 #include <QWizardPage>
29 #include <string>
30 #include <list>
31
32 class QGridLayout;
33 class QLabel;
34 class QLineEdit;
35 class QListWidget;
36
37 namespace Ui {
38   class ResourceRequirementsWizardPage;
39   class FilesWizardPage;
40   class AdvancedParametersWizardPage;
41 }
42
43 namespace BL {
44
45   class JobsManager_QT;
46   class JobNamePage;
47   class BatchParametersPage;
48   class CreateJobWizard: public QWizard
49   {
50     Q_OBJECT
51
52     public:
53       CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALOMEServices * salome_services);
54       virtual ~CreateJobWizard();
55
56       void setFilesList(QListWidget * input_files_list, QListWidget * output_files_list);
57
58       void clone(const std::string & name);
59
60     public slots:
61       void end(int result);
62
63     private:
64       BL::JobsManager_QT * _jobs_manager;
65       QListWidget * _input_files_list;
66       QListWidget * _output_files_list;
67
68       BL::JobNamePage * _job_name_page;
69       BL::BatchParametersPage * _batch_parameters_page;
70       BL::SALOMEServices * _salome_services;
71
72     public:
73       // Results
74       std::string job_name;
75       enum {YACS, COMMAND, PYTHON_SALOME} job_type;
76
77       std::string yacs_file;
78       std::string command;
79       std::string python_salome_file;
80
81       std::string env_file;
82
83       std::string batch_directory;
84
85       // For COORM
86       std::string coorm_batch_directory;
87
88       std::string maximum_duration;
89       long mem_limit;
90       BL::Job::MemReqType mem_req_type;
91       int nb_proc;
92       bool exclusive;
93
94       // Parameters for COORM
95       std::string launcher_file;
96       std::string launcher_args;
97
98       std::string result_directory;
99       std::list<std::string> input_files_list;
100       std::list<std::string> output_files_list;
101
102       std::string resource_choosed;
103       std::string batch_queue;
104       std::string wckey;
105       std::string extra_params;
106
107       bool start_job;
108       int dump_yacs_state;
109       std::string ll_jobtype;
110
111     public:
112       enum {Page_JobName,
113             Page_YACSSchema,
114             Page_Command_Main_Definitions,
115             Page_PythonSalome_Main_Definitions,
116             Page_BatchParameters,
117             Page_COORM_BatchParameters,
118             Page_Files,
119             Page_Resource,
120             Page_Advanced,
121             Page_Conclusion};
122   };
123
124   class JobNamePage: public QWizardPage
125   {
126     Q_OBJECT
127
128     public:
129       JobNamePage(QWidget * parent, BL::JobsManager_QT * jobs_manager);
130       virtual ~JobNamePage();
131
132       virtual bool validatePage();
133       virtual int nextId() const ;
134       virtual void cleanupPage() {}
135
136     public slots:
137       void yacs_schema_button(bool checked);
138       void command_button(bool checked);
139       void python_salome_button(bool checked);
140
141     private:
142       BL::JobsManager_QT * _jobs_manager;
143       QLabel * _explanation;
144
145     public:
146       bool _check_name;
147   };
148
149   class ConclusionPage: public QWizardPage
150   {
151     public:
152       ConclusionPage(QWidget * parent);
153       virtual ~ConclusionPage();
154
155       virtual bool validatePage();
156       virtual int nextId() const ;
157       virtual void cleanupPage() {}
158   };
159
160   class BatchParametersPage: public QWizardPage
161   {
162     Q_OBJECT
163
164     public:
165       enum MemUnit {MB, GB};
166
167       BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services);
168       virtual ~BatchParametersPage();
169
170       virtual void initializePage();
171       virtual int nextId() const;
172       virtual void cleanupPage();
173
174       MemUnit getMemUnit() const;
175       void setMemUnit(MemUnit mem_unit);
176
177       BL::Job::MemReqType getMemReqType() const;
178       void setMemReqType(BL::Job::MemReqType mem_req_type);
179
180     public slots:
181       void timeChanged();
182       void memChanged();
183
184     private:
185       Ui::ResourceRequirementsWizardPage * ui;
186       BL::SALOMEServices * _salome_services;
187       std::string resource_choosed;
188   };
189
190   // For COORM
191   class COORM_BatchParametersPage: public QWizardPage
192   {
193     Q_OBJECT
194
195     public:
196       COORM_BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services);
197       virtual ~COORM_BatchParametersPage();
198
199       virtual bool validatePage();
200       virtual int nextId() const;
201       virtual void cleanupPage();
202       virtual void initializePage();
203
204     public slots:
205       void choose_launcher_file();
206
207     private:
208       BL::SALOMEServices * _salome_services;
209       QLineEdit * _launcher_file_text;
210       QString resource_choosed;
211   };
212
213   class FilesPage: public QWizardPage
214   {
215     Q_OBJECT
216
217     public:
218       FilesPage(BL::CreateJobWizard * parent, BL::SALOMEServices * salome_services);
219       virtual ~FilesPage();
220
221       virtual void initializePage();
222       virtual int nextId() const;
223       virtual bool isComplete() const;
224       virtual void cleanupPage() {}
225
226     public slots:
227       void choose_input_files();
228       void remove_input_files();
229       void input_itemSelectionChanged();
230       void choose_local_directory();
231
232       void add_output_file();
233       void remove_output_files();
234       void output_itemSelectionChanged();
235
236     private:
237       Ui::FilesWizardPage * ui;
238       BL::SALOMEServices * _salome_services;
239       QString resource_choosed;
240   };
241
242   class ResourcePage: public QWizardPage
243   {
244     Q_OBJECT
245
246     public:
247       ResourcePage(BL::CreateJobWizard * parent, BL::SALOMEServices * salome_services);
248       virtual ~ResourcePage();
249
250       virtual int nextId() const;
251       virtual bool validatePage();
252       virtual void initializePage();
253       virtual void cleanupPage() {}
254
255     public slots:
256       void itemSelected(QListWidgetItem * item);
257
258     private:
259       JM::ResourceCatalog * _resource_list;
260       QLineEdit * _resource_choosed;
261       BL::SALOMEServices * _salome_services;
262
263       QLabel * _ll_label;
264       QLineEdit * _ll_value;
265       QGridLayout * _main_layout;
266   };
267
268   class YACSSchemaPage: public QWizardPage
269   {
270     Q_OBJECT
271
272     public:
273       YACSSchemaPage(QWidget * parent);
274       virtual ~YACSSchemaPage();
275
276       virtual bool validatePage();
277       virtual int nextId() const ;
278       virtual void cleanupPage() {}
279
280     public slots:
281       void choose_file();
282       void choose_env_file();
283
284     private:
285       QLineEdit * _yacs_file_text;
286       QLineEdit * _line_env_file;
287   };
288
289   class CommandMainPage: public QWizardPage
290   {
291     Q_OBJECT
292
293     public:
294       CommandMainPage(QWidget * parent);
295       virtual ~CommandMainPage();
296
297       virtual bool validatePage();
298       virtual int nextId() const ;
299       virtual void cleanupPage() {}
300
301     public slots:
302       void choose_command_file();
303       void choose_env_file();
304
305     private:
306       QLineEdit * _line_command;
307       QLineEdit * _line_env_file;
308   };
309
310   class PythonSalomeMainPage: public QWizardPage
311   {
312     Q_OBJECT
313
314     public:
315       PythonSalomeMainPage(QWidget * parent);
316       virtual ~PythonSalomeMainPage();
317
318       virtual bool validatePage();
319       virtual int nextId() const ;
320       virtual void cleanupPage() {}
321
322     public slots:
323       void choose_PythonSalome_file();
324       void choose_env_file();
325
326     private:
327       QLineEdit * _line_PythonSalome;
328       QLineEdit * _line_env_file;
329   };
330
331   class AdvancedParametersPage: public QWizardPage
332   {
333     Q_OBJECT
334
335     public:
336       AdvancedParametersPage(BL::CreateJobWizard * parent);
337       virtual ~AdvancedParametersPage();
338
339       virtual int nextId() const;
340       virtual void cleanupPage() {}
341
342     private:
343       Ui::AdvancedParametersWizardPage * ui;
344
345   };
346
347 }
348
349 #endif
350