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

Last change on this file since 480 was 480, checked in by garnier, 10 years ago

BugFix d un memory leak quand on changeait les debut de section. Amelioration lors des changement de debut de sections

File size: 5.4 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(this,&GWt_sectionToExecute::changeFirstElement);
94//  lastElement->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
95  softElement_->activated().connect(this,&GWt_sectionToExecute::setSoftware);
96  this->redraw_.connect(UIsector_,&GWt_sector::displayWidgetBeamLine);
97 
98  manageWarningsAndErrors();
99}
100
101
102void GWt_sectionToExecute::setFirstElementCurrentSelection_deprecated(Wt::WString txt){
103    for (int a=0; a< firstElement_->count(); a++) {
104        if (firstElement_->itemText(a) == txt) {
105            firstElement_->setCurrentIndex (a);
106            return;
107        }
108    }
109}
110
111void GWt_sectionToExecute::setLastElementCurrentSelection_deprecated(Wt::WString txt){
112    for (int a=0; a< lastElement_->count(); a++) {
113        if (lastElement_->itemText(a) == txt) {
114            lastElement_->setCurrentIndex (a);
115            return;
116        }
117    }
118}
119
120void GWt_sectionToExecute::setSoftwareElementCurrentSelection_deprecated(Wt::WString txt){
121  for (int a=0; a< softElement_->count(); a++) {
122    if (softElement_->itemText(a) == txt) {
123      softElement_->setCurrentIndex (a);
124      return;
125    }
126  }
127}
128
129
130void GWt_sectionToExecute::manageWarningsAndErrors(){
131    if (warningsLabel_->text() == "") {
132        warningsContainer_->hide();
133    } else {
134        warningsContainer_->show();
135    }
136    if (errorsLabel_->text() == "") {
137        errorsContainer_->hide();
138    } else {
139        errorsContainer_->show();
140    }
141
142}
143
144
145 void GWt_sectionToExecute::setSoftware()
146{
147  section_->setSoftware(softElement_->currentText().toUTF8());
148  UIsector_->getBeamLineWidget()->buildBeamLineWidget();
149}
150
151
152void GWt_sectionToExecute::changeFirstElement()
153{
154  if (!section_) return;
155  if (!UIsector_) return;
156
157  section_->setFirstElement(firstElement_->currentIndex());
158  redraw_.emit();
159}
Note: See TracBrowser for help on using the repository browser.