Changeset 396 in PSPA for Interface_Web


Ignore:
Timestamp:
Mar 22, 2013, 9:37:45 AM (11 years ago)
Author:
garnier
Message:

Passage a la version avec uniqquement des ComboBox. Tests en cours

Location:
Interface_Web/branches/12_03_12-managerComboBox/pspaWT/sources/userInterface
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/branches/12_03_12-managerComboBox/pspaWT/sources/userInterface/include/GWt_sectionToExecute.h

    r395 r396  
    44#include <Wt/WContainerWidget>
    55#include <Wt/WComboBox>
    6 #include <Wt/WLineEdit>
     6#include <Wt/WLabel>
     7
     8class GWt_softwarePanel;
    79
    810class GWt_sectionToExecute : public Wt::WContainerWidget
    911{
    1012    public :
    11     GWt_sectionToExecute(Wt::WComboBox*,Wt::WComboBox*,Wt::WComboBox*);
    12 
    13     /** DEPRECATED */
    14     GWt_sectionToExecute(Wt::WLineEdit*,Wt::WLineEdit*,Wt::WComboBox*);
     13    GWt_sectionToExecute(Wt::WComboBox*,Wt::WComboBox*,Wt::WComboBox*,GWt_softwarePanel* sPanel);
    1514
    1615    ~GWt_sectionToExecute() {;}
     
    2221    inline Wt::WString getLastElementCurrentText() {
    2322        return lastElement->currentText();
    24     }
    25    
    26     inline Wt::WString getFirstElementLineEditCurrentText() {
    27         return firstElementLineEdit->text();
    28     }
    29    
    30     inline Wt::WString getLastElementLineEditCurrentText() {
    31         return lastElementLineEdit->text();
    3223    }
    3324   
     
    5142    void setSoftwareElementCurrentSelection(Wt::WString);
    5243   
    53     void setFirstElementLineEditCurrentText(Wt::WString);
    54     void setLastElementLineEditCurrentText(Wt::WString);
     44    inline void setWarnings(Wt::WString warn){
     45        warningsLabel_->setText(warn);
     46        manageWarningsAndErrors();
     47    }
     48
     49    inline void setErrors(Wt::WString err){
     50        errorsLabel_->setText(err);
     51        manageWarningsAndErrors();
     52    }
    5553
    5654    private :
     55   
     56    void manageWarningsAndErrors();
    5757    Wt::WComboBox*  firstElement;
    5858    Wt::WComboBox*  lastElement;
    5959    Wt::WComboBox* software;
     60    GWt_softwarePanel* softwarePanel;
    6061
    61     /** DEPRECATED */
    62     Wt::WLineEdit*  firstElementLineEdit;
    63     Wt::WLineEdit*  lastElementLineEdit;
     62    Wt::WLabel* errorsLabel_;
     63    Wt::WLabel* warningsLabel_;
    6464
     65    Wt::WContainerWidget* warningsContainer_;
     66    Wt::WContainerWidget* errorsContainer_;
    6567};
    6668
  • Interface_Web/branches/12_03_12-managerComboBox/pspaWT/sources/userInterface/src/GWt_elementLigneFaisceau.cc

    r382 r396  
    1818#include <Wt/WSignalMapper>
    1919#include <Wt/WText>
    20 #include <Wt/WImage>
    2120#include <Wt/WHBoxLayout>
    2221#include <Wt/WGridLayout>
  • Interface_Web/branches/12_03_12-managerComboBox/pspaWT/sources/userInterface/src/GWt_sectionToExecute.cc

    r390 r396  
    11#include <Wt/WText>
     2#include <Wt/WVBoxLayout>
     3#include <Wt/WHBoxLayout>
     4#include <Wt/WContainerWidget>
     5#include <Wt/WImage>
     6
    27#include "GWt_sectionToExecute.h"
     8#include "GWt_softwarePanel.h"
    39
    4 
    5 GWt_sectionToExecute::GWt_sectionToExecute(Wt::WComboBox* first,Wt::WComboBox* last,Wt::WComboBox* soft)
     10GWt_sectionToExecute::GWt_sectionToExecute(Wt::WComboBox* first,Wt::WComboBox* last,Wt::WComboBox* soft,GWt_softwarePanel* sPanel)
    611:WContainerWidget(),
    712firstElement(first),
    813lastElement(last),
    9 software(soft)
     14software(soft),
     15softwarePanel(sPanel)
    1016{
    11     addWidget(new Wt::WText(" fromC : "));
    12     addWidget(first);
    13     addWidget(new Wt::WText(" toC : "));
    14     addWidget(last);
    15     addWidget(soft);
     17    Wt::WGridLayout* mainContainerLayout = new Wt::WGridLayout();
     18   
     19    mainContainerLayout->addWidget(new Wt::WText(" from : "),0,0);
     20    mainContainerLayout->addWidget(first,0,1);
     21    mainContainerLayout->addWidget(new Wt::WText(" to : "),0,2);
     22    mainContainerLayout->addWidget(last,0,3);
     23    mainContainerLayout->addWidget(soft,0,4);
     24
     25    // add errors and warning layout
     26    warningsContainer_ = new Wt::WContainerWidget();
     27    errorsContainer_ = new Wt::WContainerWidget();
     28
     29    Wt::WContainerWidget* warningsAndErrorsContainer = new Wt::WContainerWidget();
     30    Wt::WVBoxLayout* vLayoutContainer = new Wt::WVBoxLayout();
     31
     32    vLayoutContainer->addWidget(warningsContainer_);
     33    vLayoutContainer->addWidget(errorsContainer_);
     34    vLayoutContainer->addStretch (100);
     35   
     36    Wt::WHBoxLayout* hLayoutContainerWarnings = new Wt::WHBoxLayout();
     37    Wt::WHBoxLayout* hLayoutContainerErrors = new Wt::WHBoxLayout();
     38
     39   
     40    // fill containers
     41    Wt::WImage* imgWarning = new WImage ("/htdocs/warning.png");
     42    Wt::WImage* imgError = new WImage ("/htdocs/error.png");
     43
     44    // resize images
     45    imgWarning->resize(20,20);
     46    imgError->resize(20,20);
     47   
     48    warningsLabel_ = new Wt::WLabel("--warnings---");
     49    errorsLabel_ = new Wt::WLabel("---errors--");
     50
     51    hLayoutContainerWarnings->addWidget(imgWarning);
     52    hLayoutContainerWarnings->addWidget(warningsLabel_);
     53    hLayoutContainerErrors->addWidget(imgError);
     54    hLayoutContainerErrors->addWidget(errorsLabel_);
     55
     56    warningsAndErrorsContainer->addWidget(warningsLabel_);
     57    warningsAndErrorsContainer->addWidget(errorsLabel_);
     58   
     59   
     60    // set Layouts
     61    warningsContainer_->setLayout(hLayoutContainerWarnings);
     62    errorsContainer_->setLayout(hLayoutContainerErrors);
     63   
     64    warningsAndErrorsContainer->setLayout(vLayoutContainer);
     65
     66    // add warnings and errors containers
     67    mainContainerLayout->addWidget(warningsAndErrorsContainer,0,5,2,1);
     68    mainContainerLayout->addWidget(new WLabel("--"),1,1);
     69
     70    this->setLayout(mainContainerLayout);
     71   
     72   
     73    firstElement->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
     74    lastElement->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
     75    software->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
    1676}
    1777
    1878
    19 GWt_sectionToExecute::GWt_sectionToExecute(Wt::WLineEdit* first,Wt::WLineEdit* last,Wt::WComboBox* soft)
    20 :WContainerWidget(),
    21 firstElementLineEdit(first),
    22 lastElementLineEdit(last),
    23 software(soft)
    24 {;
    25     addWidget(new Wt::WText(" fromLE : "));
    26     addWidget(first);
    27     addWidget(new Wt::WText(" toLE : "));
    28     addWidget(last);
    29     addWidget(soft);
    30 }
    31 
    32 
    33 
    3479void GWt_sectionToExecute::setFirstElementCurrentSelection(Wt::WString txt){
     80    for (int a=0; a< firstElement->count(); a++) {
     81        if (firstElement->itemText(a) == txt) {
     82            firstElement->setCurrentIndex (a);
     83            return;
     84        }
     85    }
    3586}
    3687
    3788void GWt_sectionToExecute::setLastElementCurrentSelection(Wt::WString txt){
     89    for (int a=0; a< lastElement->count(); a++) {
     90        if (lastElement->itemText(a) == txt) {
     91            lastElement->setCurrentIndex (a);
     92            return;
     93        }
     94    }
    3895}
    3996
     
    48105
    49106
    50 void GWt_sectionToExecute::setFirstElementLineEditCurrentText(Wt::WString txt){
    51     firstElementLineEdit->setText(txt);
     107void GWt_sectionToExecute::manageWarningsAndErrors(){
     108    if (warningsLabel_->text() == "") {
     109        warningsContainer_->hide();
     110    } else {
     111        warningsContainer_->show();
     112    }
     113    if (errorsLabel_->text() == "") {
     114        errorsContainer_->hide();
     115    } else {
     116        errorsContainer_->show();
     117    }
     118
    52119}
    53 
    54 void GWt_sectionToExecute::setLastElementLineEditCurrentText(Wt::WString txt){
    55     lastElementLineEdit->setText(txt);
    56 }
    57 
  • Interface_Web/branches/12_03_12-managerComboBox/pspaWT/sources/userInterface/src/GWt_softwarePanel.cc

    r395 r396  
    128128  fillComboWithSoftwares(softCombo);
    129129
    130   GWt_sectionToExecute* newSectionOld = new GWt_sectionToExecute(lineFrom, lineTo, softCombo);
    131   GWt_sectionToExecute* newSection = new GWt_sectionToExecute(lineFromCombo, lineToCombo, softCombo);
     130  GWt_sectionToExecute* newSection = new GWt_sectionToExecute(lineFromCombo, lineToCombo, softCombo,this);
    132131
    133132  // push back on sections vector
    134   sections.push_back(newSectionOld);
    135133  sections.push_back(newSection);
    136134
    137135  // push back on User interface
    138   contenuSections_->addWidget(newSectionOld);
    139136  contenuSections_->addWidget(newSection);
    140 
    141    
    142137
    143138}
     
    244239  string premier = dtmanage_->getLabelFromElementNumero(1);
    245240  if (sections.size() > 0) {
    246     sections[0]->setFirstElementLineEditCurrentText(premier);
    247 //...
    248   }
    249  
    250   Wt::WString currentString =  sections[0]->getLastElementLineEditCurrentText();
     241    sections[0]->setFirstElementCurrentSelection(premier);
     242  }
     243 
     244  Wt::WString currentString =  sections[0]->getLastElementCurrentText();
    251245  int current = dtmanage_->getNumeroFromElementLabel(currentString.toUTF8());
    252246 
     
    257251    currentString =  dtmanage_->getLabelFromElementNumero(current);
    258252    if (sections.size() > 0) {
    259       sections[0]->setLastElementLineEditCurrentText(currentString);
     253      sections[0]->setLastElementCurrentSelection(currentString);
    260254//...
    261255    }
     
    275269        }
    276270     
    277       sections[a]->setFirstElementLineEditCurrentText(currentString);
    278 //...
     271      sections[a]->setFirstElementCurrentSelection(currentString);
     272
    279273      // fin
    280       string finString =  sections[a]->getLastElementLineEditCurrentText().toUTF8();
     274      string finString =  sections[a]->getLastElementCurrentText().toUTF8();
    281275     
    282276      int numeroFin = dtmanage_->getNumeroFromElementLabel( finString);
     
    294288    }
    295289  //  exec_go_->setDisabled(false);
     290
     291  if (!areDataCoherent()) {
     292    exec_go_->disable();
     293  } else {
     294    exec_go_->enable();
     295  }
     296
    296297  return true;
    297298}
     
    306307   
    307308  for (int a = 0; a< sections.size(); a++)
    308     {
    309       string debString = sections[a]->getFirstElementLineEditCurrentText().toUTF8();
    310       string finString = sections[a]->getLastElementLineEditCurrentText().toUTF8();
    311      
    312       int debut = pspa_->getBeamLine()->getAbstractElementIndexFromLabel(debString)+1; // FIXME : Should NOT be +1
    313         int fin = pspa_->getBeamLine()->getAbstractElementIndexFromLabel(finString)+1; // FIXME : Should NOT be +1
    314 
    315       nomDeLogiciel prog = nomDeLogiciel ( sections[a]->getSoftwareCurrentText().toUTF8());
    316       dtmanage_->addSectionToExecute(pspa_->getBeamLine()->getAbstractElement(debut),
    317                                      debut,
    318                                      pspa_->getBeamLine()->getAbstractElement(fin),
    319                                      fin,
    320                                      dtmanage_->createSoftwareConnexion(prog));
    321        
    322       // check sections
    323       for (int i=debut-1; i<fin; i++) {
    324         if (pspa_->getBeamLine()) {
    325           if (pspa_->getBeamLine()->getAbstractElement(i)) {
    326             trivaluedBool tb = pspa_->getBeamLine()->getAbstractElement(i)->setSoftware(prog.getString());
    327             if (tb  == TBoolError ) {
    328               diagnostic += pspa_->getBeamLine()->getAbstractElement(i)->getNomdElement().getElementName() + " is not allowed with "+ prog.getString()+"\n ";
    329               caMarche = false;
    330               tbResume = tb;
    331             } else if ( tb == TBoolIgnore ) {
    332               diagnostic += pspa_->getBeamLine()->getAbstractElement(i)->getNomdElement().getElementName() + " will be ignored by  "+ prog.getString()+"\n ";
    333               if ( tbResume != TBoolError ) tbResume = tb;
    334             } else {
    335               pspa_->getBeamLine()->update(i);
    336             }
    337           }
    338         }
     309  {
     310    string debString = sections[a]->getFirstElementCurrentText().toUTF8();
     311    string finString = sections[a]->getLastElementCurrentText().toUTF8();
     312   
     313    int debut = pspa_->getBeamLine()->getAbstractElementIndexFromLabel(debString)+1; // FIXME : Should NOT be +1
     314    int fin = pspa_->getBeamLine()->getAbstractElementIndexFromLabel(finString)+1; // FIXME : Should NOT be +1
     315   
     316    nomDeLogiciel prog = nomDeLogiciel ( sections[a]->getSoftwareCurrentText().toUTF8());
     317    dtmanage_->addSectionToExecute(pspa_->getBeamLine()->getAbstractElement(debut),
     318                                   debut,
     319                                   pspa_->getBeamLine()->getAbstractElement(fin),
     320                                   fin,
     321                                   dtmanage_->createSoftwareConnexion(prog));
     322   
     323    // check sections
     324    for (int i=debut-1; i<fin; i++) {
     325      if (pspa_->getBeamLine()) {
     326        if (pspa_->getBeamLine()->getAbstractElement(i)) {
     327          trivaluedBool tb = pspa_->getBeamLine()->getAbstractElement(i)->setSoftware(prog.getString());
     328          if (tb  == TBoolError ) {
     329            diagnostic += pspa_->getBeamLine()->getAbstractElement(i)->getNomdElement().getElementName() + " is not allowed with "+ prog.getString()+"\n ";
     330            caMarche = false;
     331            tbResume = tb;
     332          } else if ( tb == TBoolIgnore ) {
     333            diagnostic += pspa_->getBeamLine()->getAbstractElement(i)->getNomdElement().getElementName() + " will be ignored by  "+ prog.getString()+"\n ";
     334            if ( tbResume != TBoolError ) tbResume = tb;
     335          } else {
     336            pspa_->getBeamLine()->update(i);
     337          }
     338        }
    339339      }
    340340    }
    341 
     341  }
     342 
    342343  if ( tbResume == TBoolError ) {
    343344    GWt_dialog calculDialog("PSPA check execute : ERROR", diagnostic , GWt_dialog::Error,true,true);
     
    375376    fillComboWithElements(sections[a]->getLastElement());
    376377  }
    377  
    378   string premierText, dernierText;
    379   if ( dtmanage_->getJobListSize() > 0 )
    380   {
    381     premierText = dtmanage_->getLabelFromElementNumero(1);
    382       dernierText = dtmanage_->getLabelFromElementNumero( dtmanage_->getBeamLineSize() );
    383       sections[0]->setFirstElementLineEditCurrentText(premierText);
    384       sections[0]->setLastElementLineEditCurrentText(dernierText);
    385 //...
    386     }
     378  if (sections.size() == 0) {
     379    return;
     380  }
     381  // the first element will always be the first element of the beamLine
     382  sections[0]->getFirstElement()->setCurrentIndex(0);
     383 
     384  // the last element will always be the last element of the beamLine
     385  sections[sections.size()-1]->getLastElement()->setCurrentIndex(sections[sections.size()-1]->getLastElement()->count());
     386
     387  // set default values
     388
     389  // update
     390  updateSectionSelection();
    387391}
    388392
     
    401405{
    402406
    403   if ( !updateSectionSelection() ) return;
    404 
    405 
    406     if (!areDataCoherent()) {
    407       //    GWt_dialog warningDialog("PSPA : verification des sections", " donnees incoherentes !", GWt_dialog::Error,true,true);
    408       //    warningDialog.exec();
    409       //    exec_go_->setDisabled(true);
     407  if (!areDataCoherent()) {
     408    //    GWt_dialog warningDialog("PSPA : verification des sections", " donnees incoherentes !", GWt_dialog::Error,true,true);
     409    //    warningDialog.exec();
     410    //    exec_go_->setDisabled(true);
    410411    return;
    411     }
    412 
     412  }
     413 
    413414  GWt_console* console = NULL;
    414415  if (static_cast<GWt_console*> (wApp->findWidget ("console"))) {
     
    437438void GWt_softwarePanel::fillComboWithElements(Wt::WComboBox* cBox) {
    438439  if (cBox == NULL) return;
     440
     441  // get the last item selected
     442  WString selectedString = cBox->currentText ();
    439443  cBox->clear();
    440444
     
    445449    }
    446450  }
     451 
     452  for (int a=0; a<cBox->count(); a++) {
     453    if (cBox->itemText (a) == selectedString) {
     454      cBox->setCurrentIndex(a);
     455    }
     456  }
    447457}
    448458
Note: See TracChangeset for help on using the changeset viewer.