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