source: PSPA/Interface_Web/branches/12_03_12-managerComboBox/pspaWT/sources/userInterface/src/GWt_sectionToExecute.cc @ 396

Last change on this file since 396 was 396, checked in by garnier, 11 years ago

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

File size: 3.7 KB
Line 
1#include <Wt/WText>
2#include <Wt/WVBoxLayout>
3#include <Wt/WHBoxLayout>
4#include <Wt/WContainerWidget>
5#include <Wt/WImage>
6
7#include "GWt_sectionToExecute.h"
8#include "GWt_softwarePanel.h"
9
10GWt_sectionToExecute::GWt_sectionToExecute(Wt::WComboBox* first,Wt::WComboBox* last,Wt::WComboBox* soft,GWt_softwarePanel* sPanel)
11:WContainerWidget(),
12firstElement(first),
13lastElement(last),
14software(soft),
15softwarePanel(sPanel)
16{
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);
76}
77
78
79void 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    }
86}
87
88void 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    }
95}
96
97void GWt_sectionToExecute::setSoftwareElementCurrentSelection(Wt::WString txt){
98  for (int a=0; a< software->count(); a++) {
99    if (software->itemText(a) == txt) {
100      software->setCurrentIndex (a);
101      return;
102    }
103  }
104}
105
106
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
119}
Note: See TracBrowser for help on using the repository browser.