34 #include <QMessageBox>
35 #include <QPushButton>
36 #include <QTableWidget>
40 using namespace YACS::HMI;
41 using namespace YACS::ENGINE;
43 BatchJobsListDialog::BatchJobsListDialog(QString title,
GenericGui* genericGui):
QWidget(),_genericGui(genericGui),_proc(NULL) {
45 setWindowTitle(title);
51 QBoxLayout*
box =
new QBoxLayout(QBoxLayout::TopToBottom,
this);
54 _table =
new QTableWidget(
this);
64 box->addWidget(buttons);
67 _ok->setEnabled(
false);
83 SALOME_NamingService* NS =
new SALOME_NamingService(orb);
84 CORBA::Object_var obj = NS->Resolve(
"/SalomeLauncher");
99 int nblines = joblist->length();
100 _table->setRowCount(nblines);
103 titres <<
"Job Name" <<
"State" <<
"Resource" <<
"Launcher Id";
104 _table->setHorizontalHeaderLabels(titres);
106 for(
int i=0;
i<nblines;
i++){
107 Engines::JobDescription descr = (*joblist)[
i];
108 string jobType = CORBA::string_dup(descr.job_parameters.job_type);
110 if(jobType.find(
"yacs_file")!=string::npos){
111 long jobId = descr.job_id;
114 string jobName = CORBA::string_dup(descr.job_parameters.job_name);
116 string jobMachine = CORBA::string_dup(descr.job_parameters.resource_required.name);
117 QTableWidgetItem* item0 =
new QTableWidgetItem(jobName.c_str() ,
type_job);
118 QTableWidgetItem* item1 =
new QTableWidgetItem(jobState.c_str() ,
type_state);
119 QTableWidgetItem* item2 =
new QTableWidgetItem(jobMachine.c_str() ,
type_res );
120 QTableWidgetItem* item3 =
new QTableWidgetItem(sstId.str().c_str(),
type_id );
121 _table->setItem(irow, 0, item0);
122 _table->setItem(irow, 1, item1);
123 _table->setItem(irow, 2, item2);
124 _table->setItem(irow, 3, item3);
125 if(jobState !=
"RUNNING"){
126 item0->setFlags(Qt::NoItemFlags);
127 item1->setFlags(Qt::NoItemFlags);
128 item2->setFlags(Qt::NoItemFlags);
129 item3->setFlags(Qt::NoItemFlags);
131 else if(jobId ==
_id){
132 item0->setSelected(
true);
133 item1->setSelected(
true);
134 item2->setSelected(
true);
135 item3->setSelected(
true);
141 connect(
_table, SIGNAL( itemClicked(QTableWidgetItem*) ),
this, SLOT(
userCell(QTableWidgetItem*) ));
149 _ok =
new QPushButton(
"OK" ,
this);
150 QPushButton* cancel =
new QPushButton(
"Cancel",
this);
152 connect(
_ok , SIGNAL(clicked()),
this, SLOT(
userOK ()));
153 connect(cancel, SIGNAL(clicked()),
this, SLOT(
userCancel()));
155 QBoxLayout* layout =
new QBoxLayout(QBoxLayout::LeftToRight,
this);
157 layout->addWidget(
_ok);
158 layout->addWidget(cancel);
161 buttons->setLayout(layout);
170 if ( cell->flags() ) {
171 int line = cell->row();
172 string sid =
_table->item(line,3)->text().toStdString();
173 _id = atoi(sid.c_str());
174 _ok->setEnabled(
true);
176 QTableWidget* table = cell->tableWidget();
177 for (
int c=0;
c<4;
c++) {
178 QTableWidgetItem* it = table->item(line,
c);
179 it->setSelected(
true);
191 _jobFile = CORBA::string_dup(jobParam->job_file);
192 _dumpStateFile = QString(
"/tmp/%1/dumpState_%2.xml").arg(getenv(
"USER")).arg(QFileInfo(
_jobFile).baseName());
205 QMessageBox msgBox(QMessageBox::Critical,
"Import Batch Schema, native YACS XML format",
206 "The xml graph has not the native YACS XML format or is not readable." );
260 ifstream infile(
_jobFile.toStdString().c_str());
262 string errmsg =
"File " +
_jobFile.toStdString() +
" doesn't exist!!";
266 vector<string> objref;
267 while( !infile.eof() ){
268 getline(infile,buffer);
270 if( (buffer.find(
"objref") != string::npos) && (buffer.find(
"IDL") != string::npos) ){
271 size_t pos1 = buffer.find(
"\"");
272 size_t pos2 = buffer.find(
"\"",pos1+1);
273 objref.push_back(buffer.substr(pos1+1,pos2-pos1-1));
278 infile.open(
_jobFile.toStdString().c_str());
282 string errmsg =
"Impossible to create the file " +
_filteredJobFile.toStdString() +
"!!";
285 while( !infile.eof() ){
286 getline(infile,buffer);
288 if( ((buffer.find(
"objref") == string::npos) || (buffer.find(
"IDL") == string::npos)) && (buffer.find(
"/objref") == string::npos) ){
290 for(
int i=0;
i<objref.size();
i++){
291 size_t pos = buffer.find(objref[
i]);
292 if(pos != string::npos)
293 tmp = buffer.substr(0,pos) +
"string" + buffer.substr(pos+objref[i].size());
295 outfile << tmp << endl;
307 string errmsg =
"File " +
_dumpStateFile.toStdString() +
" doesn't exist!!";
316 while( !infile.eof() ){
317 getline(infile,buffer);
318 size_t pos = buffer.find(
"objref");
319 while(pos != string::npos){
320 buffer.replace(pos,6,
"string");
321 pos = buffer.find(
"objref");
323 outfile << buffer << endl;