Salome HOME
b66491436886177bd8418330c7b0d8eb6418ddf3
[modules/jobmanager.git] / src / genericgui / BL_CreateJobWizard.hxx
1 // Copyright (C) 2009-2012  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.
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 BL{
33
34   class JobsManager_QT;
35   class JobNamePage;
36   class CreateJobWizard: virtual public QWizard
37   {
38     Q_OBJECT
39
40     public:
41       CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALOMEServices * salome_services);
42       virtual ~CreateJobWizard();
43
44       void setFilesList(QListWidget * input_files_list, QListWidget * output_files_list);
45
46       void clone(const std::string & name);
47
48     public slots:
49       void end(int result);
50
51     private:
52       //Page Name
53       QLineEdit * _nameLineEdit;
54       BL::JobsManager_QT * _jobs_manager;
55       QListWidget * _input_files_list;
56       QListWidget * _output_files_list;
57
58       BL::JobNamePage * _job_name_page;
59       BL::SALOMEServices * _salome_services;
60
61     public:
62       // Results
63       std::string job_name;
64
65       std::string yacs_file;
66       std::string command;
67       std::string python_salome_file;
68
69       std::string env_file;
70
71       std::string batch_directory;
72       std::string maximum_duration;
73       std::string expected_memory;
74       int nb_proc;
75
76       std::string result_directory;
77       std::list<std::string> input_files_list;
78       std::list<std::string> output_files_list;
79
80       std::string resource_choosed;
81       std::string batch_queue;
82
83       bool start_job;
84       int dump_yacs_state;
85       std::string ll_jobtype;
86
87     public:
88       enum {Page_JobName,
89             Page_YACSSchema,
90             Page_Command_Main_Definitions,
91             Page_PythonSalome_Main_Definitions,
92             Page_BatchParameters,
93             Page_Files,
94             Page_Resource,
95             Page_Conclusion};
96   };
97
98   class JobNamePage: virtual public QWizardPage
99   {
100     Q_OBJECT
101
102     public:
103       JobNamePage(QWidget * parent, BL::JobsManager_QT * jobs_manager);
104       virtual ~JobNamePage();
105
106       virtual bool validatePage();
107       virtual int nextId() const ;
108       virtual void cleanupPage() {}
109
110     public slots:
111       void yacs_schema_button(bool checked);
112       void command_button(bool checked);
113       void python_salome_button(bool checked);
114
115     private:
116       BL::JobsManager_QT * _jobs_manager;
117       QLabel * _explanation;
118
119     public:
120       QRadioButton * _yacs_schema_button;
121       QRadioButton * _command_button;
122       QRadioButton * _python_salome_button;
123       bool _check_name;
124   };
125
126   class ConclusionPage: virtual public QWizardPage
127   {
128     public:
129       ConclusionPage(QWidget * parent);
130       virtual ~ConclusionPage();
131
132       virtual bool validatePage();
133       virtual int nextId() const ;
134       virtual void cleanupPage() {}
135   };
136
137   class BatchParametersPage: virtual public QWizardPage
138   {
139     Q_OBJECT
140
141     public:
142       BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services);
143       virtual ~BatchParametersPage();
144
145       virtual bool validatePage();
146       virtual int nextId() const;
147       virtual void cleanupPage();
148       virtual void initializePage();
149
150     private:
151       BL::SALOMEServices * _salome_services;
152       QString resource_choosed;
153   };
154
155   class FilesPage: virtual public QWizardPage
156   {
157     Q_OBJECT
158
159     public:
160       FilesPage(BL::CreateJobWizard * parent);
161       virtual ~FilesPage();
162
163       virtual int nextId() const;
164       virtual bool validatePage();
165       virtual void cleanupPage() {}
166
167     public slots:
168       void choose_input_files();
169       void remove_input_files();
170       void input_itemSelectionChanged();
171       void choose_local_directory();
172
173       void add_output_file();
174       void remove_output_files();
175       void output_itemSelectionChanged();
176
177     private:
178       QPushButton * _input_files_button;
179       QPushButton * _remove_input_files_button;
180       QListWidget * _input_files_list;
181       QLineEdit * _result_directory;
182
183       QPushButton * _output_files_button;
184       QPushButton * _remove_output_files_button;
185       QListWidget * _output_files_list;
186   };
187
188   class ResourcePage: virtual public QWizardPage
189   {
190     Q_OBJECT
191
192     public:
193       ResourcePage(BL::CreateJobWizard * parent, BL::SALOMEServices * salome_services);
194       virtual ~ResourcePage();
195
196       virtual int nextId() const;
197       virtual bool validatePage();
198       virtual void initializePage();
199       virtual void cleanupPage() {}
200
201     public slots:
202       void itemSelected(QListWidgetItem * item);
203
204     private:
205       JM::ResourceCatalog * _resource_list;
206       QLineEdit * _resource_choosed;
207       BL::SALOMEServices * _salome_services;
208
209       QLabel * _ll_label;
210       QLineEdit * _ll_value;
211       QGridLayout * _main_layout;
212   };
213
214   class YACSSchemaPage: virtual public QWizardPage
215   {
216     Q_OBJECT
217
218     public:
219       YACSSchemaPage(QWidget * parent);
220       virtual ~YACSSchemaPage();
221
222       virtual bool validatePage();
223       virtual int nextId() const ;
224       virtual void cleanupPage() {}
225
226     public slots:
227       void choose_file();
228       void choose_env_file();
229
230     private:
231       QLineEdit * _yacs_file_text;
232       QLineEdit * _line_env_file;
233   };
234
235   class CommandMainPage: virtual public QWizardPage
236   {
237     Q_OBJECT
238
239     public:
240       CommandMainPage(QWidget * parent);
241       virtual ~CommandMainPage();
242
243       virtual bool validatePage();
244       virtual int nextId() const ;
245       virtual void cleanupPage() {}
246
247     public slots:
248       void choose_command_file();
249       void choose_env_file();
250
251     private:
252       QLineEdit * _line_command;
253       QLineEdit * _line_env_file;
254   };
255
256   class PythonSalomeMainPage: virtual public QWizardPage
257   {
258     Q_OBJECT
259
260     public:
261       PythonSalomeMainPage(QWidget * parent);
262       virtual ~PythonSalomeMainPage();
263
264       virtual bool validatePage();
265       virtual int nextId() const ;
266       virtual void cleanupPage() {}
267
268     public slots:
269       void choose_PythonSalome_file();
270       void choose_env_file();
271
272     private:
273       QLineEdit * _line_PythonSalome;
274       QLineEdit * _line_env_file;
275   };
276 }
277
278 #endif
279