[388] | 1 | #include <Wt/WText> |
---|
[396] | 2 | #include <Wt/WVBoxLayout> |
---|
| 3 | #include <Wt/WHBoxLayout> |
---|
[399] | 4 | #include <Wt/WGridLayout> |
---|
[396] | 5 | #include <Wt/WContainerWidget> |
---|
| 6 | #include <Wt/WImage> |
---|
| 7 | |
---|
[388] | 8 | #include "GWt_sectionToExecute.h" |
---|
[396] | 9 | #include "GWt_softwarePanel.h" |
---|
[469] | 10 | #include "GWt_sector.h" |
---|
[388] | 11 | |
---|
[469] | 12 | GWt_sectionToExecute::GWt_sectionToExecute(Wt::WComboBox* first,Wt::WComboBox* last,Wt::WComboBox* soft,Wt::WContainerWidget* buttonPanel, sectionToExecute* section,GWt_sector* sector) |
---|
[388] | 13 | :WContainerWidget(), |
---|
[469] | 14 | firstElement_(first), |
---|
| 15 | lastElement_(last), |
---|
| 16 | softElement_(soft), |
---|
| 17 | section_(section), |
---|
| 18 | UIsector_(sector) |
---|
[388] | 19 | { |
---|
[431] | 20 | Wt::WGridLayout* mainContainerLayout = new Wt::WGridLayout(); |
---|
| 21 | mainContainerLayout->setContentsMargins(0,0,0,0); |
---|
[397] | 22 | |
---|
[431] | 23 | Wt::WContainerWidget* labelAndComboContainer = new Wt::WContainerWidget(); |
---|
| 24 | Wt::WVBoxLayout* labelAndComboContainerLayout = new Wt::WVBoxLayout(); |
---|
| 25 | labelAndComboContainerLayout->setContentsMargins(0,0,0,0); |
---|
[397] | 26 | |
---|
[431] | 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 : ")); |
---|
[469] | 32 | labelAndComboInsideContainerLayout->addWidget(firstElement_); |
---|
[431] | 33 | labelAndComboInsideContainerLayout->addWidget(new Wt::WText("to : ")); |
---|
[469] | 34 | labelAndComboInsideContainerLayout->addWidget(lastElement_); |
---|
| 35 | labelAndComboInsideContainerLayout->addWidget(softElement_); |
---|
[431] | 36 | |
---|
[407] | 37 | // add buttons |
---|
[431] | 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_); |
---|
[407] | 59 | |
---|
[431] | 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 |
---|
[469] | 89 | firstElement_->setMinimumSize(80,12); |
---|
| 90 | lastElement_->setMinimumSize(80,12); |
---|
| 91 | softElement_->setMinimumSize(80,12); |
---|
[431] | 92 | |
---|
[474] | 93 | firstElement_->activated().connect(this,&GWt_sectionToExecute::changeFirstElement); |
---|
[469] | 94 | // lastElement->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections); |
---|
| 95 | softElement_->activated().connect(this,&GWt_sectionToExecute::setSoftware); |
---|
[431] | 96 | |
---|
| 97 | manageWarningsAndErrors(); |
---|
[388] | 98 | } |
---|
| 99 | |
---|
| 100 | |
---|
[476] | 101 | void GWt_sectionToExecute::setFirstElementCurrentSelection_deprecated(Wt::WString txt){ |
---|
[469] | 102 | for (int a=0; a< firstElement_->count(); a++) { |
---|
| 103 | if (firstElement_->itemText(a) == txt) { |
---|
| 104 | firstElement_->setCurrentIndex (a); |
---|
[396] | 105 | return; |
---|
| 106 | } |
---|
| 107 | } |
---|
[388] | 108 | } |
---|
| 109 | |
---|
[476] | 110 | void GWt_sectionToExecute::setLastElementCurrentSelection_deprecated(Wt::WString txt){ |
---|
[469] | 111 | for (int a=0; a< lastElement_->count(); a++) { |
---|
| 112 | if (lastElement_->itemText(a) == txt) { |
---|
| 113 | lastElement_->setCurrentIndex (a); |
---|
[396] | 114 | return; |
---|
| 115 | } |
---|
| 116 | } |
---|
[388] | 117 | } |
---|
| 118 | |
---|
[476] | 119 | void GWt_sectionToExecute::setSoftwareElementCurrentSelection_deprecated(Wt::WString txt){ |
---|
[469] | 120 | for (int a=0; a< softElement_->count(); a++) { |
---|
| 121 | if (softElement_->itemText(a) == txt) { |
---|
| 122 | softElement_->setCurrentIndex (a); |
---|
[388] | 123 | return; |
---|
| 124 | } |
---|
| 125 | } |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | |
---|
[396] | 129 | void 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 | } |
---|
[388] | 140 | |
---|
| 141 | } |
---|
[455] | 142 | |
---|
[469] | 143 | |
---|
| 144 | void GWt_sectionToExecute::setSoftware() |
---|
[455] | 145 | { |
---|
[469] | 146 | section_->setSoftware(softElement_->currentText().toUTF8()); |
---|
| 147 | UIsector_->getBeamLineWidget()->buildBeamLineWidget(); |
---|
[455] | 148 | } |
---|
| 149 | |
---|
[474] | 150 | |
---|
| 151 | void GWt_sectionToExecute::changeFirstElement() |
---|
| 152 | { |
---|
[476] | 153 | if (!section_) return; |
---|
| 154 | if (!UIsector_) return; |
---|
| 155 | |
---|
| 156 | section_->setFirstElement(firstElement_->currentIndex()); |
---|
[474] | 157 | UIsector_->getExecuteWidget()->displayFromControler(); |
---|
[476] | 158 | UIsector_->getBeamLineWidget()->buildBeamLineWidget(); |
---|
[474] | 159 | } |
---|