source: PSPA/Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_sectionToExecute.cc @ 469

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

Désormais il est de nouveau possible d'ajouter des sections et dy affecter des softwares (ne marche pour le moment quavec la 1ere sectionToExecute. Autres améliorations et renommages

File size: 5.1 KB
Line 
1#include <Wt/WText>
2#include <Wt/WVBoxLayout>
3#include <Wt/WHBoxLayout>
4#include <Wt/WGridLayout>
5#include <Wt/WContainerWidget>
6#include <Wt/WImage>
7
8#include "GWt_sectionToExecute.h"
9#include "GWt_softwarePanel.h"
10#include "GWt_sector.h"
11
12GWt_sectionToExecute::GWt_sectionToExecute(Wt::WComboBox* first,Wt::WComboBox* last,Wt::WComboBox* soft,Wt::WContainerWidget* buttonPanel, sectionToExecute* section,GWt_sector* sector)
13:WContainerWidget(),
14firstElement_(first),
15lastElement_(last),
16softElement_(soft),
17section_(section),
18UIsector_(sector)
19{
20  Wt::WGridLayout* mainContainerLayout = new Wt::WGridLayout();
21  mainContainerLayout->setContentsMargins(0,0,0,0);
22
23  Wt::WContainerWidget* labelAndComboContainer = new Wt::WContainerWidget();
24  Wt::WVBoxLayout* labelAndComboContainerLayout = new Wt::WVBoxLayout();
25  labelAndComboContainerLayout->setContentsMargins(0,0,0,0);
26
27  Wt::WContainerWidget* labelAndComboInsideContainer = new Wt::WContainerWidget();
28  Wt::WHBoxLayout* labelAndComboInsideContainerLayout = new Wt::WHBoxLayout();
29  labelAndComboInsideContainerLayout->setContentsMargins(0,0,0,0);
30 
31  labelAndComboInsideContainerLayout->addWidget(new Wt::WText("from&nbsp;:&nbsp;"));
32  labelAndComboInsideContainerLayout->addWidget(firstElement_);
33  labelAndComboInsideContainerLayout->addWidget(new Wt::WText("to&nbsp;:&nbsp;"));
34  labelAndComboInsideContainerLayout->addWidget(lastElement_);
35  labelAndComboInsideContainerLayout->addWidget(softElement_);
36 
37    // add buttons
38  labelAndComboInsideContainerLayout->addWidget(buttonPanel);
39  labelAndComboInsideContainer->setLayout(labelAndComboInsideContainerLayout);
40  labelAndComboContainerLayout->addWidget(labelAndComboInsideContainer);
41  labelAndComboContainerLayout->addStretch (10);
42  labelAndComboContainer->setLayout(labelAndComboContainerLayout);
43 
44  // add errors and warning layout
45  warningsContainer_ = new Wt::WContainerWidget();
46  errorsContainer_ = new Wt::WContainerWidget();
47 
48  Wt::WContainerWidget* warningsAndErrorsContainer = new Wt::WContainerWidget();
49  Wt::WVBoxLayout* vWarningsAndErrorsLayoutContainer = new Wt::WVBoxLayout();
50 
51  Wt::WHBoxLayout* hLayoutContainerWarnings = new Wt::WHBoxLayout();
52  Wt::WHBoxLayout* hLayoutContainerErrors = new Wt::WHBoxLayout();
53 
54 
55  warningsLabel_ = new Wt::WText("",XHTMLText);
56  errorsLabel_ = new Wt::WText("",XHTMLText);
57  hLayoutContainerWarnings->addWidget(warningsLabel_);
58  hLayoutContainerErrors->addWidget(errorsLabel_);
59
60  warningsAndErrorsContainer->addWidget(warningsLabel_);
61  warningsAndErrorsContainer->addWidget(errorsLabel_);
62 
63 
64  // set Layouts
65  warningsContainer_->setLayout(hLayoutContainerWarnings);
66  errorsContainer_->setLayout(hLayoutContainerErrors);
67 
68  vWarningsAndErrorsLayoutContainer->addWidget(errorsContainer_);
69  vWarningsAndErrorsLayoutContainer->addWidget(warningsContainer_);
70  vWarningsAndErrorsLayoutContainer->addStretch (100);
71 
72  warningsAndErrorsContainer->setLayout(vWarningsAndErrorsLayoutContainer);
73 
74  // add label and Combo containers
75  mainContainerLayout->addWidget(labelAndComboContainer,0,0);
76  // add warnings and errors containers
77  mainContainerLayout->addWidget(warningsAndErrorsContainer,1,0);
78 
79  // manage margins
80  vWarningsAndErrorsLayoutContainer->setContentsMargins(20,0,0,0);
81  hLayoutContainerWarnings->setContentsMargins(0,0,0,0);
82  hLayoutContainerErrors->setContentsMargins(0,0,0,0);
83 
84  setLayout(mainContainerLayout);
85  warningsContainer_->setStyleClass("warningsContainer");
86  errorsContainer_->setStyleClass("errorsContainer");
87 
88  // resize combo
89  firstElement_->setMinimumSize(80,12);
90  lastElement_->setMinimumSize(80,12);
91  softElement_->setMinimumSize(80,12);
92 
93//  firstElement_->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
94//  lastElement->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
95  softElement_->activated().connect(this,&GWt_sectionToExecute::setSoftware);
96 
97  manageWarningsAndErrors();
98}
99
100
101void GWt_sectionToExecute::setFirstElementCurrentSelection(Wt::WString txt){
102    for (int a=0; a< firstElement_->count(); a++) {
103        if (firstElement_->itemText(a) == txt) {
104            firstElement_->setCurrentIndex (a);
105            return;
106        }
107    }
108}
109
110void GWt_sectionToExecute::setLastElementCurrentSelection(Wt::WString txt){
111    for (int a=0; a< lastElement_->count(); a++) {
112        if (lastElement_->itemText(a) == txt) {
113            lastElement_->setCurrentIndex (a);
114            return;
115        }
116    }
117}
118
119void GWt_sectionToExecute::setSoftwareElementCurrentSelection(Wt::WString txt){
120  for (int a=0; a< softElement_->count(); a++) {
121    if (softElement_->itemText(a) == txt) {
122      softElement_->setCurrentIndex (a);
123      return;
124    }
125  }
126}
127
128
129void GWt_sectionToExecute::manageWarningsAndErrors(){
130    if (warningsLabel_->text() == "") {
131        warningsContainer_->hide();
132    } else {
133        warningsContainer_->show();
134    }
135    if (errorsLabel_->text() == "") {
136        errorsContainer_->hide();
137    } else {
138        errorsContainer_->show();
139    }
140
141}
142
143
144 void GWt_sectionToExecute::setSoftware()
145{
146  section_->setSoftware(softElement_->currentText().toUTF8());
147  UIsector_->getBeamLineWidget()->buildBeamLineWidget();
148}
149
Note: See TracBrowser for help on using the repository browser.