[302] | 1 | // GWt_softwarePanel.cpp |
---|
| 2 | // PSPA |
---|
| 3 | // |
---|
| 4 | // Created by Garnier Laurent on 30/01/13. |
---|
| 5 | // Copyright (c) 2013 Garnier Laurent. All rights reserved. |
---|
| 6 | // |
---|
| 7 | |
---|
| 8 | #include <Wt/WLineEdit> |
---|
| 9 | #include <Wt/WText> |
---|
| 10 | #include <Wt/WComboBox> |
---|
| 11 | #include <Wt/WPanel> |
---|
| 12 | #include <Wt/WBreak> |
---|
| 13 | #include <Wt/WApplication> |
---|
[401] | 14 | #include <Wt/WVBoxLayout> |
---|
[302] | 15 | |
---|
| 16 | #include "GWt_softwarePanel.h" |
---|
| 17 | #include "GWt_dialog.h" |
---|
| 18 | #include "GWt_console.h" |
---|
| 19 | #include "GWt_globalParameters.h" |
---|
[401] | 20 | #include "GWt_sectionToExecute.h" |
---|
[302] | 21 | |
---|
| 22 | |
---|
| 23 | GWt_softwarePanel::GWt_softwarePanel(dataManager* dataManager,PspaApplication* pspa) |
---|
[343] | 24 | : WContainerWidget() |
---|
| 25 | { |
---|
| 26 | dtmanage_ = dataManager; |
---|
| 27 | pspa_ = pspa; |
---|
[401] | 28 | |
---|
[343] | 29 | // bouton execute |
---|
| 30 | exec_go_ = new WPushButton("execute!"); |
---|
| 31 | // exec_go_->setMinimumSize(300,300); |
---|
[367] | 32 | // exec_go_->setDisabled(true); |
---|
[343] | 33 | exec_go_->clicked().connect(this, &GWt_softwarePanel::executer); |
---|
| 34 | |
---|
[302] | 35 | |
---|
[343] | 36 | // preparation du bouton push_ok |
---|
[367] | 37 | // WPushButton* exec_ok = new WPushButton("ok"); |
---|
| 38 | // exec_ok->clicked().connect(this, &GWt_softwarePanel::updateSectionSelection); |
---|
[343] | 39 | |
---|
| 40 | // le panel |
---|
| 41 | WPanel *panelLogiciels = new WPanel(this); |
---|
[401] | 42 | panelLogiciels->setTitle(" sections of beam line for executing softwares "); |
---|
[343] | 43 | |
---|
| 44 | contenuSections_ = new WContainerWidget(); |
---|
[367] | 45 | // contenuSections_->addWidget(exec_ok); |
---|
[343] | 46 | contenuSections_->addWidget(exec_go_); |
---|
| 47 | contenuSections_->addWidget(new WBreak()); |
---|
| 48 | contenuSections_->addWidget(new WBreak()); |
---|
| 49 | addSectionToExecuteW(); |
---|
| 50 | |
---|
| 51 | panelLogiciels->setCentralWidget(contenuSections_); |
---|
[302] | 52 | } |
---|
| 53 | |
---|
| 54 | GWt_softwarePanel::~GWt_softwarePanel() { |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | void GWt_softwarePanel::addSectionToExecuteW() |
---|
[343] | 58 | { |
---|
| 59 | |
---|
[401] | 60 | abstractElement* premierElement; |
---|
| 61 | abstractElement* dernierElement; |
---|
| 62 | |
---|
| 63 | int premierIndex = 0; |
---|
| 64 | int dernierIndex = 0; |
---|
| 65 | |
---|
[405] | 66 | // if there is no section |
---|
| 67 | if(sections_.size() == 0) { |
---|
[401] | 68 | premierElement = pspa_->getBeamLine()->getAbstractElement(0); |
---|
| 69 | premierIndex = 0; |
---|
| 70 | |
---|
| 71 | // if this is not the first : |
---|
| 72 | // - first element will be the last of the previous section |
---|
| 73 | // (or the same if it is the last of the beam line) |
---|
| 74 | // - lastElement will be the last of the beam line |
---|
| 75 | // - software will be the first of the list |
---|
| 76 | |
---|
[343] | 77 | } else { |
---|
[405] | 78 | dernierElement = pspa_->getBeamLine()->getAbstractElement(pspa_->getBeamLine()->getBeamLineSize()-1); |
---|
| 79 | dernierIndex = pspa_->getBeamLine()->getBeamLineSize()-1; |
---|
| 80 | |
---|
| 81 | premierElement = dernierElement; |
---|
| 82 | premierIndex = dernierIndex; |
---|
| 83 | |
---|
| 84 | /* int indexOfLastElementOfLastSection = dtmanage_->getJobListAt(dtmanage_->getJobListSize()-1)->getLastElementNumberInSection(); |
---|
| 85 | |
---|
| 86 | |
---|
| 87 | // if there are still elements at the end |
---|
[401] | 88 | if (pspa_->getBeamLine()->getAbstractElement(indexOfLastElementOfLastSection+1) != NULL ) { |
---|
| 89 | premierIndex = indexOfLastElementOfLastSection+1; |
---|
| 90 | premierElement = pspa_->getBeamLine()->getAbstractElement(indexOfLastElementOfLastSection+1); |
---|
[405] | 91 | |
---|
| 92 | // if this is the last element |
---|
[343] | 93 | } else { |
---|
[401] | 94 | premierIndex = indexOfLastElementOfLastSection; |
---|
| 95 | premierElement = pspa_->getBeamLine()->getAbstractElement(indexOfLastElementOfLastSection); |
---|
| 96 | |
---|
[302] | 97 | } |
---|
[405] | 98 | */ |
---|
[343] | 99 | } |
---|
| 100 | |
---|
[405] | 101 | dernierElement = pspa_->getBeamLine()->getAbstractElement(pspa_->getBeamLine()->getBeamLineSize()-1); |
---|
| 102 | dernierIndex = pspa_->getBeamLine()->getBeamLineSize()-1; |
---|
[343] | 103 | // cout << "PspaApplication::addSectionToExecute() : " << premierText << " ââ " << dernierText << endl; |
---|
| 104 | |
---|
| 105 | |
---|
[401] | 106 | abstractSoftware* soft = NULL; |
---|
| 107 | dtmanage_->addSectionToExecute(premierElement,premierIndex, dernierElement, dernierIndex, soft); |
---|
| 108 | |
---|
| 109 | std::string premierElementLabel = ""; |
---|
| 110 | std::string dernierElementLabel = ""; |
---|
| 111 | if (premierElement) { |
---|
| 112 | premierElementLabel = premierElement->getLabel(); |
---|
[343] | 113 | } |
---|
[401] | 114 | |
---|
| 115 | if (dernierElement) { |
---|
| 116 | dernierElementLabel = dernierElement->getLabel(); |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | WComboBox* lineFromCombo = new WComboBox(); |
---|
| 120 | WComboBox* lineToCombo = new WComboBox(); |
---|
| 121 | fillComboWithElements(lineFromCombo); |
---|
| 122 | fillComboWithElements(lineToCombo); |
---|
| 123 | |
---|
[405] | 124 | // set selection |
---|
| 125 | lineFromCombo->setCurrentIndex(premierIndex); |
---|
| 126 | lineToCombo->setCurrentIndex(dernierIndex); |
---|
| 127 | |
---|
[401] | 128 | WComboBox* softCombo = new WComboBox(); |
---|
| 129 | fillComboWithSoftwares(softCombo); |
---|
| 130 | |
---|
[407] | 131 | GWt_sectionToExecute* newSection = new GWt_sectionToExecute(lineFromCombo, lineToCombo, softCombo,createAddDeletePushButtons(sections_.size()),this); |
---|
[401] | 132 | |
---|
[407] | 133 | stringstream st; |
---|
| 134 | st << sections_.size(); |
---|
| 135 | |
---|
| 136 | // this is the mean to identify this section! |
---|
| 137 | newSection->setObjectName(st.str()); |
---|
| 138 | |
---|
[401] | 139 | // push back on sections vector |
---|
[405] | 140 | sections_.push_back(newSection); |
---|
[401] | 141 | |
---|
[411] | 142 | contenuSections_->addWidget(newSection); |
---|
[401] | 143 | |
---|
[411] | 144 | updateSections(); |
---|
[302] | 145 | } |
---|
| 146 | |
---|
| 147 | |
---|
[367] | 148 | // void GWt_softwarePanel::disableSectionExecute() |
---|
| 149 | // { |
---|
| 150 | // exec_go_->setDisabled(true); |
---|
| 151 | // } |
---|
[302] | 152 | |
---|
| 153 | |
---|
[358] | 154 | // void GWt_softwarePanel::checkSectionSelection() |
---|
| 155 | // { |
---|
| 156 | // if ( selectedSections_.empty() ) return; |
---|
| 157 | |
---|
| 158 | // // traitement de la premiere ligne |
---|
| 159 | // // on impose le depart du calcul au premier element |
---|
| 160 | // string premier = dtmanage_->getLabelFromElementNumero(1); |
---|
| 161 | // (*selectedSections_.begin())->debut->setText(premier); |
---|
| 162 | |
---|
| 163 | // string currentString = (*selectedSections_.begin())->fin->text().toUTF8(); |
---|
| 164 | // int current = dtmanage_->getNumeroFromElementLabel(currentString); |
---|
| 165 | |
---|
| 166 | // // si la fin est mal definie on prend toute la config par defaut |
---|
| 167 | // if ( current <= 0 || current > dtmanage_->getBeamLineSize() ) |
---|
| 168 | // { |
---|
| 169 | // current = dtmanage_->getBeamLineSize(); |
---|
| 170 | // currentString = dtmanage_->getLabelFromElementNumero(current); |
---|
| 171 | // (*selectedSections_.begin())->fin->setText(currentString); |
---|
| 172 | // } |
---|
| 173 | // current++; |
---|
| 174 | // currentString = dtmanage_->getLabelFromElementNumero(current); |
---|
| 175 | |
---|
| 176 | // // traitement des suivantes (on avance d'un cran dans la liste) |
---|
| 177 | // list<GWt_sectionToExecute*>::iterator itr, itr0; |
---|
| 178 | // itr0 = selectedSections_.begin(); |
---|
| 179 | // itr0++; |
---|
| 180 | // for (itr = itr0; itr != selectedSections_.end(); itr++) |
---|
| 181 | // { |
---|
| 182 | // // debut |
---|
| 183 | // if ( current > dtmanage_->getBeamLineSize() ) |
---|
| 184 | // { |
---|
| 185 | // GWt_dialog warningDialog("PSPA :: verification des sections", " bad section definition !", GWt_dialog::Error,true,true); |
---|
| 186 | // warningDialog.exec(); |
---|
| 187 | // return; |
---|
| 188 | // } |
---|
| 189 | |
---|
| 190 | // (*itr)->debut->setText(currentString); |
---|
| 191 | // // fin |
---|
| 192 | // string finString = (*itr)->fin->text().toUTF8(); |
---|
| 193 | |
---|
| 194 | // int numeroFin = dtmanage_->getNumeroFromElementLabel( finString); |
---|
| 195 | |
---|
| 196 | // if ( numeroFin < current || numeroFin > dtmanage_->getBeamLineSize()) |
---|
| 197 | // { |
---|
| 198 | // GWt_dialog warningDialog("PSPA : Checking of sections", " bad section definition !", GWt_dialog::Error, true,true); |
---|
| 199 | // warningDialog.exec(); |
---|
| 200 | // return; |
---|
| 201 | // } |
---|
| 202 | |
---|
| 203 | // // preparation de la ligne suivante |
---|
| 204 | // current = numeroFin +1; |
---|
| 205 | // currentString = dtmanage_->getLabelFromElementNumero(current); |
---|
| 206 | // } |
---|
| 207 | |
---|
| 208 | // if (!areDataCoherent()) { |
---|
| 209 | // GWt_dialog warningDialog("PSPA : verification des sections", " donnees incoherentes !", GWt_dialog::Error,true,true); |
---|
| 210 | // warningDialog.exec(); |
---|
| 211 | // } |
---|
| 212 | // else |
---|
| 213 | // { |
---|
| 214 | // exec_go_->setDisabled(false); |
---|
| 215 | |
---|
| 216 | // // All ok, then put colors on beamLine |
---|
| 217 | // list<GWt_sectionToExecute*>::iterator itr2; |
---|
| 218 | // for(itr2 = selectedSections_.begin();itr2 != selectedSections_.end(); itr2++) |
---|
| 219 | // { |
---|
| 220 | // string debString = (*itr2)->debut->text().toUTF8(); |
---|
| 221 | // string finString = (*itr2)->fin->text().toUTF8(); |
---|
| 222 | |
---|
| 223 | |
---|
| 224 | // int debut = dtmanage_->getNumeroFromElementLabel(debString); |
---|
| 225 | // int fin = dtmanage_->getNumeroFromElementLabel(finString); |
---|
| 226 | // /** |
---|
| 227 | // for (int i=debut; i=<fin; i++) { |
---|
| 228 | // getBeamLine()->getAbstractElement(i)->setBGColor( |
---|
| 229 | |
---|
| 230 | // } |
---|
| 231 | // nomDeLogiciel prog = nomDeLogiciel ( (*itr)->selection->currentIndex() ); |
---|
| 232 | // dtmanage_->addSectionToExecute(debut,fin,prog); |
---|
| 233 | // */ |
---|
| 234 | // } |
---|
| 235 | // } |
---|
| 236 | |
---|
| 237 | |
---|
| 238 | // } |
---|
| 239 | |
---|
[367] | 240 | bool GWt_softwarePanel::updateSectionSelection() |
---|
[302] | 241 | { |
---|
[401] | 242 | if ( dtmanage_->getJobListSize() == 0 ) return false; |
---|
[343] | 243 | |
---|
| 244 | // traitement de la premiere ligne |
---|
| 245 | // on impose le depart du calcul au premier element |
---|
| 246 | string premier = dtmanage_->getLabelFromElementNumero(1); |
---|
[405] | 247 | if (sections_.size() > 0) { |
---|
| 248 | sections_[0]->setFirstElementCurrentSelection(premier); |
---|
[401] | 249 | } |
---|
[343] | 250 | |
---|
[405] | 251 | Wt::WString currentString = sections_[0]->getLastElementCurrentText(); |
---|
[401] | 252 | int current = dtmanage_->getNumeroFromElementLabel(currentString.toUTF8()); |
---|
| 253 | |
---|
[343] | 254 | // si la fin est mal definie on prend toute la config par defaut |
---|
| 255 | if ( current <= 0 || current > dtmanage_->getBeamLineSize() ) |
---|
[401] | 256 | { |
---|
| 257 | current = dtmanage_->getBeamLineSize(); |
---|
| 258 | currentString = dtmanage_->getLabelFromElementNumero(current); |
---|
[405] | 259 | if (sections_.size() > 0) { |
---|
| 260 | sections_[0]->setLastElementCurrentSelection(currentString); |
---|
[401] | 261 | //... |
---|
[302] | 262 | } |
---|
[401] | 263 | } |
---|
[343] | 264 | current++; |
---|
| 265 | currentString = dtmanage_->getLabelFromElementNumero(current); |
---|
| 266 | |
---|
| 267 | // traitement des suivantes (on avance d'un cran dans la liste) |
---|
[405] | 268 | for (int a = 1; a< sections_.size(); a++) |
---|
[302] | 269 | { |
---|
[343] | 270 | // debut |
---|
| 271 | if ( current > dtmanage_->getBeamLineSize() ) |
---|
[302] | 272 | { |
---|
[412] | 273 | sections_[a]->setErrors("This section element could not be after previous session last element"); |
---|
| 274 | exec_go_->disable(); |
---|
| 275 | return false; |
---|
[302] | 276 | } |
---|
[343] | 277 | |
---|
[405] | 278 | sections_[a]->setFirstElementCurrentSelection(currentString); |
---|
[401] | 279 | |
---|
[343] | 280 | // fin |
---|
[405] | 281 | string finString = sections_[a]->getLastElementCurrentText().toUTF8(); |
---|
[343] | 282 | |
---|
| 283 | int numeroFin = dtmanage_->getNumeroFromElementLabel( finString); |
---|
| 284 | |
---|
[412] | 285 | if ( numeroFin < current) |
---|
| 286 | { |
---|
| 287 | sections_[a]->setErrors("Last section element should be after first section element"); |
---|
| 288 | exec_go_->disable(); |
---|
| 289 | return false; |
---|
| 290 | } |
---|
| 291 | |
---|
| 292 | if (numeroFin > dtmanage_->getBeamLineSize()) |
---|
| 293 | { |
---|
| 294 | sections_[a]->setErrors("Last section element number is greater than the beam line size"); |
---|
| 295 | exec_go_->disable(); |
---|
| 296 | return false; |
---|
| 297 | } |
---|
[343] | 298 | |
---|
| 299 | // preparation de la ligne suivante |
---|
| 300 | current = numeroFin +1; |
---|
| 301 | currentString = dtmanage_->getLabelFromElementNumero(current); |
---|
[302] | 302 | } |
---|
[367] | 303 | // exec_go_->setDisabled(false); |
---|
[401] | 304 | |
---|
| 305 | if (!areDataCoherent()) { |
---|
| 306 | exec_go_->disable(); |
---|
| 307 | } else { |
---|
| 308 | exec_go_->enable(); |
---|
| 309 | } |
---|
| 310 | |
---|
[367] | 311 | return true; |
---|
[302] | 312 | } |
---|
| 313 | |
---|
| 314 | |
---|
| 315 | bool GWt_softwarePanel::areDataCoherent() |
---|
| 316 | { |
---|
[371] | 317 | bool caMarche = true; |
---|
[401] | 318 | |
---|
| 319 | // initialize dataManager |
---|
[371] | 320 | dtmanage_->initializeExecution(); |
---|
[401] | 321 | |
---|
| 322 | // intialize User Interface |
---|
| 323 | if (pspa_->getBeamLine()) { |
---|
| 324 | pspa_->getBeamLine()->initializeSoftwares(); |
---|
| 325 | } |
---|
| 326 | |
---|
| 327 | string diagnosticErrors; |
---|
| 328 | string diagnosticWarnings; |
---|
| 329 | |
---|
[405] | 330 | for (int a = 0; a< sections_.size(); a++) |
---|
[401] | 331 | { |
---|
[405] | 332 | string debString = sections_[a]->getFirstElementCurrentText().toUTF8(); |
---|
| 333 | string finString = sections_[a]->getLastElementCurrentText().toUTF8(); |
---|
[359] | 334 | |
---|
[401] | 335 | int debut = pspa_->getBeamLine()->getAbstractElementIndexFromLabel(debString)+1; // FIXME : Should NOT be +1 |
---|
| 336 | int fin = pspa_->getBeamLine()->getAbstractElementIndexFromLabel(finString)+1; // FIXME : Should NOT be +1 |
---|
| 337 | |
---|
[405] | 338 | nomDeLogiciel prog = nomDeLogiciel ( sections_[a]->getSoftwareCurrentText().toUTF8()); |
---|
[401] | 339 | dtmanage_->addSectionToExecute(pspa_->getBeamLine()->getAbstractElement(debut), |
---|
| 340 | debut, |
---|
| 341 | pspa_->getBeamLine()->getAbstractElement(fin), |
---|
| 342 | fin, |
---|
| 343 | dtmanage_->createSoftwareConnexion(prog)); |
---|
| 344 | |
---|
| 345 | diagnosticErrors = ""; |
---|
| 346 | diagnosticWarnings = ""; |
---|
| 347 | |
---|
| 348 | // check sections |
---|
| 349 | for (int i=debut-1; i<fin; i++) { |
---|
| 350 | if (pspa_->getBeamLine()) { |
---|
| 351 | if (pspa_->getBeamLine()->getAbstractElement(i)) { |
---|
| 352 | trivaluedBool tb = pspa_->getBeamLine()->getAbstractElement(i)->setSoftware(prog.getString()); |
---|
| 353 | if (tb == TBoolError ) { |
---|
| 354 | diagnosticErrors += pspa_->getBeamLine()->getAbstractElement(i)->getLabel() + " is not allowed with "+ prog.getString()+"<br /> "; |
---|
| 355 | |
---|
| 356 | caMarche = false; |
---|
| 357 | |
---|
| 358 | // intialize thissoftware |
---|
| 359 | pspa_->getBeamLine()->getAbstractElement(i)->setSoftware(nomDeLogiciel::unknownSoftware); |
---|
| 360 | |
---|
| 361 | } else if ( tb == TBoolIgnore ) { |
---|
| 362 | diagnosticWarnings += pspa_->getBeamLine()->getAbstractElement(i)->getLabel() + " will be ignored by "+ prog.getString()+"<br /> "; |
---|
| 363 | |
---|
| 364 | |
---|
| 365 | } |
---|
| 366 | pspa_->getBeamLine()->update(i); |
---|
| 367 | } |
---|
[371] | 368 | } |
---|
[302] | 369 | } |
---|
[401] | 370 | // set errors and warnings |
---|
[405] | 371 | sections_[a]->setErrors(diagnosticErrors); |
---|
| 372 | sections_[a]->setWarnings(diagnosticWarnings); |
---|
[371] | 373 | } |
---|
[359] | 374 | |
---|
[371] | 375 | return caMarche; |
---|
[302] | 376 | } |
---|
| 377 | |
---|
[407] | 378 | void GWt_softwarePanel::deleteSectionToExecuteW(int sectionLabel) |
---|
[302] | 379 | { |
---|
[407] | 380 | stringstream st; |
---|
| 381 | st << sectionLabel; |
---|
| 382 | std::string sectionName = st.str(); |
---|
| 383 | |
---|
| 384 | if ( dtmanage_->getJobListSize() == 0 ) return; |
---|
| 385 | for (unsigned int sectionIndex = 0; sectionIndex< sections_.size(); sectionIndex++) { |
---|
| 386 | if (sections_[sectionIndex]->objectName() == sectionName) { |
---|
[401] | 387 | |
---|
[407] | 388 | // delete from dataManager |
---|
| 389 | dtmanage_->clearSectionToExecute(sectionIndex); |
---|
| 390 | |
---|
| 391 | // delete from User Interface |
---|
| 392 | contenuSections_->removeWidget(sections_[sectionIndex]); |
---|
| 393 | delete sections_[sectionIndex]; |
---|
| 394 | sections_.erase (sections_.begin()+sectionIndex); |
---|
| 395 | } |
---|
| 396 | } |
---|
[302] | 397 | } |
---|
| 398 | |
---|
| 399 | |
---|
[401] | 400 | void GWt_softwarePanel::updateSections() |
---|
[302] | 401 | { |
---|
[401] | 402 | // update all sections in order to manage new/deleted items |
---|
[405] | 403 | for (int a = 0; a< sections_.size(); a++) { |
---|
| 404 | fillComboWithElements(sections_[a]->getFirstElement()); |
---|
| 405 | fillComboWithElements(sections_[a]->getLastElement()); |
---|
| 406 | |
---|
| 407 | sections_[a]->getFirstElement()->setEnabled (true); |
---|
| 408 | sections_[a]->getLastElement()->setEnabled (true); |
---|
[401] | 409 | } |
---|
[405] | 410 | if (sections_.size() == 0) { |
---|
[401] | 411 | return; |
---|
| 412 | } |
---|
| 413 | // the first element will always be the first element of the beamLine |
---|
[405] | 414 | sections_[0]->getFirstElement()->setCurrentIndex(0); |
---|
| 415 | sections_[0]->getFirstElement()->setEnabled (false); |
---|
| 416 | |
---|
[401] | 417 | // the last element will always be the last element of the beamLine |
---|
[405] | 418 | sections_[sections_.size()-1]->getLastElement()->setCurrentIndex(sections_[sections_.size()-1]->getLastElement()->count()); |
---|
| 419 | sections_[sections_.size()-1]->getLastElement()->setEnabled (false); |
---|
[401] | 420 | |
---|
| 421 | // set default values |
---|
| 422 | |
---|
| 423 | // update |
---|
| 424 | updateSectionSelection(); |
---|
[302] | 425 | } |
---|
| 426 | |
---|
| 427 | |
---|
[401] | 428 | |
---|
| 429 | /* |
---|
| 430 | string GWt_softwarePanel::getSelection() |
---|
[302] | 431 | { |
---|
[343] | 432 | list<GWt_sectionToExecute*>::iterator itr = selectedSections_.begin(); |
---|
| 433 | string str = (*itr)->fin->text().toUTF8(); |
---|
| 434 | return str; |
---|
[302] | 435 | } |
---|
[401] | 436 | */ |
---|
[302] | 437 | |
---|
| 438 | void GWt_softwarePanel::executer() |
---|
| 439 | { |
---|
[367] | 440 | |
---|
[401] | 441 | if (!areDataCoherent()) { |
---|
| 442 | // GWt_dialog warningDialog("PSPA : verification des sections", " donnees incoherentes !", GWt_dialog::Error,true,true); |
---|
| 443 | // warningDialog.exec(); |
---|
| 444 | // exec_go_->setDisabled(true); |
---|
[358] | 445 | return; |
---|
[401] | 446 | } |
---|
| 447 | |
---|
[398] | 448 | // GWt_console* console = NULL; |
---|
| 449 | // if (static_cast<GWt_console*> (wApp->findWidget ("console"))) { |
---|
| 450 | // console = static_cast<GWt_console*> (wApp->findWidget ("console")); |
---|
| 451 | // console->addConsoleMessage(string("on va peut etre y arriver")); |
---|
| 452 | // } |
---|
[343] | 453 | |
---|
| 454 | static_cast<GWt_globalParameters*>(pspa_->getGlobalParam())->updateGlobals(); |
---|
| 455 | |
---|
| 456 | GWt_dialog calculDialog("Calcul en cours", "Veuillez patienter...", GWt_dialog::Wait, true,false); |
---|
| 457 | calculDialog.show(); |
---|
[302] | 458 | |
---|
[343] | 459 | wApp->processEvents(); |
---|
| 460 | |
---|
| 461 | if (!dtmanage_->executeAll()) { |
---|
| 462 | GWt_dialog warningDialog("PSPA : Echec", " echec lors de l'exÃcution !", GWt_dialog::Error, true,true); |
---|
| 463 | warningDialog.exec(); |
---|
| 464 | } |
---|
| 465 | |
---|
[367] | 466 | // exec_go_->setDisabled(true); |
---|
[343] | 467 | calculDialog.hide(); |
---|
| 468 | pspa_->faireDessin(); |
---|
[302] | 469 | } |
---|
[401] | 470 | |
---|
| 471 | |
---|
| 472 | void GWt_softwarePanel::fillComboWithElements(Wt::WComboBox* cBox) { |
---|
| 473 | if (cBox == NULL) return; |
---|
| 474 | |
---|
| 475 | // get the last item selected |
---|
| 476 | WString selectedString = cBox->currentText (); |
---|
| 477 | cBox->clear(); |
---|
| 478 | |
---|
| 479 | for (int a=0; a< pspa_->getBeamLine()->getBeamLineSize(); a++) { |
---|
| 480 | abstractElement* abs = pspa_->getBeamLine()->getAbstractElement(a); |
---|
| 481 | if (abs != NULL){ |
---|
| 482 | cBox->addItem(abs->getLabel()); |
---|
| 483 | } |
---|
| 484 | } |
---|
| 485 | |
---|
| 486 | for (int a=0; a<cBox->count(); a++) { |
---|
| 487 | if (cBox->itemText (a) == selectedString) { |
---|
| 488 | cBox->setCurrentIndex(a); |
---|
| 489 | } |
---|
| 490 | } |
---|
[405] | 491 | cBox->refresh(); |
---|
[401] | 492 | } |
---|
| 493 | |
---|
| 494 | |
---|
| 495 | void GWt_softwarePanel::fillComboWithSoftwares(Wt::WComboBox* cBox) { |
---|
| 496 | if (cBox == NULL) return; |
---|
| 497 | cBox->clear(); |
---|
| 498 | |
---|
| 499 | unsigned nb = nomDeLogiciel::getNumberOfSoftwares(); |
---|
| 500 | unsigned k; |
---|
| 501 | for(k = 0; k < nb; k++) { |
---|
| 502 | cBox->addItem(nomDeLogiciel(k).getString()); |
---|
| 503 | } |
---|
[405] | 504 | cBox->refresh(); |
---|
[401] | 505 | } |
---|
| 506 | |
---|
| 507 | |
---|
[407] | 508 | Wt::WContainerWidget* GWt_softwarePanel::createAddDeletePushButtons(int sectionNumber) { |
---|
[401] | 509 | |
---|
| 510 | WContainerWidget* buttonContainer= new WContainerWidget(); |
---|
| 511 | |
---|
| 512 | Wt::WHBoxLayout* buttonContainerLayout = new Wt::WHBoxLayout(); |
---|
| 513 | buttonContainerLayout->setContentsMargins(0,0,0,0); |
---|
| 514 | // preparation du bouton add |
---|
| 515 | WPushButton* exec_add = new WPushButton("+"); |
---|
| 516 | exec_add->clicked().connect(this, &GWt_softwarePanel::addSectionToExecuteW); |
---|
| 517 | exec_add->setStyleClass("roundButton"); |
---|
| 518 | exec_add->setMaximumSize(20,20); |
---|
| 519 | exec_add->setToolTip("Add new section"); |
---|
| 520 | |
---|
| 521 | // preparation du bouton delete |
---|
| 522 | WPushButton* exec_delete = new WPushButton("-"); |
---|
| 523 | // warningsContainer_->setStyleClass("warningsContainer"); |
---|
[407] | 524 | |
---|
| 525 | exec_delete->clicked().connect(boost::bind(&GWt_softwarePanel::deleteSectionToExecuteW, this, sectionNumber)); |
---|
[401] | 526 | exec_delete->setStyleClass("roundButton"); |
---|
| 527 | exec_delete->setMaximumSize(20,20); |
---|
[405] | 528 | exec_delete->setToolTip("Remove this section"); |
---|
[401] | 529 | |
---|
| 530 | buttonContainerLayout->addWidget(exec_add); |
---|
| 531 | buttonContainerLayout->addWidget(exec_delete); |
---|
| 532 | |
---|
| 533 | buttonContainer->setLayout(buttonContainerLayout); |
---|
| 534 | |
---|
| 535 | return buttonContainer; |
---|
| 536 | } |
---|