Changeset 336 in PSPA for Interface_Web
- Timestamp:
- Feb 20, 2013, 2:55:48 PM (12 years ago)
- Location:
- Interface_Web/trunk/pspaWT
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/History
r329 r336 5 5 PSPA - Plateforme de simulation en physique des accélérateurs 6 6 ========================================================= 7 8 20 Février 2013 Laurent Garnier 9 - requierements : Remise mise en place d'une seule librarie, encore du travail 10 à faire avant de séparer tout en M-V-C 11 - Ajout de la classe GWt_serverFileSelector pour permettre la lecture de fichiers 12 de config sur le serveur 7 13 8 14 19 Février 2013 Laurent Garnier -
Interface_Web/trunk/pspaWT/cmt/requirements
r335 r336 52 52 ../sources/userInterface/src/GWt_softwarePanel.cc \ 53 53 ../sources/userInterface/src/GWt_draggableImage.cc \ 54 ../sources/userInterface/src/GWt_serverFileSelector 54 ../sources/userInterface/src/GWt_serverFileSelector.cc 55 55 56 56 … … 59 59 macro PSPA_Lib_shlibflags " ${Wt_linkopts} ${boost_linkopts} ${dld_linkopts}" 60 60 61 macro PSPA_Lib_linkopts " -L${PSPAWTROOT}/${Platform_bin} -lPSPA_ userInterfaceLib "61 macro PSPA_Lib_linkopts " -L${PSPAWTROOT}/${Platform_bin} -lPSPA_Lib " 62 62 63 63 -
Interface_Web/trunk/pspaWT/sources/controler/src/beam2Moments.cc
r257 r336 90 90 getline(inp, buf); 91 91 stringstream str(buf); 92 test = str >> bidon >> bidString >> bidon >> ( rij_secondOrderMoments_.at(0) ).at(0) >> bidString;92 test = str >> bidon >> bidString >> bidon >> ( rij_secondOrderMoments_.at(0) ).at(0) >> bidString; 93 93 cout << " beam2Moments::readFromTransportOutput TEST= " << test << endl; 94 94 } -
Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc
r316 r336 240 240 cout << "dataManager::restoreElements() fichier " << inputFileName << endl; 241 241 ifstream infile; 242 string name = workingDir_ + inputFileName + ".save";242 string name = inputFileName; 243 243 infile.open(name.c_str(), ios::in); 244 244 if (!infile) { -
Interface_Web/trunk/pspaWT/sources/controler/src/particleBeam.cc
r324 r336 8 8 #include <sstream> 9 9 //#include "environmentVariables.h" 10 #include <Wt/WApplication>11 12 10 using namespace std; 13 11 -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_dialog.h
r299 r336 9 9 10 10 /** 11 Cr éer une fenêtre de dialogue et permet de la paramètres facilement12 @param titre : titre de la fen être13 @param icon : icone àafficher dans le corps de la boite (Warning, Error, Info, Wait, NoIcon)14 @param modal : true si cette fen être doit être bloquante15 @param okButton : true pour fermer cette fen être avec un bouton "ok". false n'affiche aucun bouton11 CrÃer une fenÃtre de dialogue et permet de la paramÃtres facilement 12 @param titre : titre de la fenÃtre 13 @param icon : icone â¡ afficher dans le corps de la boite (Warning, Error, Info, Wait, NoIcon) 14 @param modal : true si cette fenÃtre doit Ãtre bloquante 15 @param okButton : true pour fermer cette fenÃtre avec un bouton "ok". false n'affiche aucun bouton 16 16 */ 17 17 -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_pspaApplication.h
r333 r336 67 67 WWidget* createExecuteWidget(); 68 68 WContainerWidget* createDrawingWidget(); 69 69 70 void closeGraphicDialog(); 70 71 … … 72 73 void sauver(); 73 74 void dialogSaveDone(WDialog::DialogCode code); 74 void dialogOpenDone(WDialog::DialogCode code);75 75 void restaurer(); 76 76 void chargerConfig(); … … 90 90 void dessinerPhaseSpace(); 91 91 void dessinerHistogramme(); 92 93 94 95 92 96 97 public : 93 public : 98 94 99 95 PspaApplication(const WEnvironment& env); -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_serverFileSelector.h
r330 r336 1 #ifndef GWt_serverFileSelector 2 #define GWt_serverFileSelector 1 #ifndef GWT_SERVERFILESELECTOR 2 #define GWT_SERVERFILESELECTOR 3 4 #include "GWt_dialog.h" 3 5 4 6 #include <Wt/WDialog> 5 7 #include <Wt/WString> 6 8 #include <Wt/WContainerWidget> 9 #include <Wt/WTree> 7 10 8 11 using namespace Wt; … … 16 19 */ 17 20 18 class GWt_serverFileSelector : public WDialog21 class GWt_serverFileSelector : public GWt_dialog 19 22 { 20 23 21 24 public : 22 23 enum iconType { Warning, Error, Info, Wait, NoIcon };24 25 25 26 /** Add a dialog with the given container inside … … 28 29 @param container: a valid WContainer 29 30 */ 30 GWt_serverFileSelector(WString titre, WContainerWidget* container, bool modal=false); 31 GWt_serverFileSelector(WString titre, std::string wd); 32 33 /** open this dialog and return the selected file or "" if not 34 */ 35 std::string exec(); 31 36 32 /** Add a full dialog window configure with title, message, iconType and button 33 @param titre: A title displayed on the window title bar 34 @param message: The message inside this dialog 35 @param icon: IconType, could be Warning, Error, Info, Wait or NoIcon 36 @param modal: true for a blocking dialog, false for a non-blocking dialog 37 @param okButton: true if you want a "ok" button at the end 37 private : 38 void buildConfigurationFileTree(Wt::WTreeNode *root, const char* folder, const char* pattern); 39 Wt::WTree *treeRoot_; 40 41 /** working directory for this file selector 38 42 */ 39 GWt_serverFileSelector(WString titre, WString message, iconType icon=NoIcon, bool modal=false, bool okButton=false);43 std::string workingDir_; 40 44 }; 41 45 #endif -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_dialog.cc
r301 r336 13 13 bool modal 14 14 ): 15 WDialog(titre )15 WDialog(titre+" ") 16 16 { 17 17 … … 19 19 titleBar()->decorationStyle().setBackgroundColor (WColor(70,180,220)); 20 20 21 WContainerWidget* widgt = new WContainerWidget(contents()); 22 WHBoxLayout* hLayout = new WHBoxLayout(); 23 hLayout->addWidget(wc); 24 widgt->setLayout(hLayout); 21 if (wc != NULL) { 22 WContainerWidget* widgt = new WContainerWidget(contents()); 23 WHBoxLayout* hLayout = new WHBoxLayout(); 24 hLayout->addWidget(wc); 25 widgt->setLayout(hLayout); 26 } 25 27 26 28 setClosable(true); … … 109 111 110 112 113 -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_elementLigneFaisceau.cc
r310 r336 183 183 184 184 if (static_cast <GWt_abstractElement*> (wc->widget (a))->getElement()->getName().getElementType() == elem.getElementType()) { 185 pspa_->addConsoleMessage("type trouv é");185 pspa_->addConsoleMessage("type trouvÃ"); 186 186 } else { 187 pspa_->addConsoleMessage("type trouv éNOT ");187 pspa_->addConsoleMessage("type trouvà NOT "); 188 188 } 189 189 */ -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc
r333 r336 16 16 #include "environmentVariables.h" 17 17 #include "GWt_console.h" 18 #include "GWt_serverFileSelector.h" 18 19 #include "trivaluedBool.h" 19 20 … … 348 349 } 349 350 351 350 352 void PspaApplication::restaurer() 351 353 { 352 console_->addConsoleMessage(string("on va recharger...")); 353 dialogOpen_ = new WDialog("open"); 354 new WText("name of case : ",dialogOpen_->contents()); 355 openNameEdit_ = new WLineEdit(nameOfCase_.c_str(), dialogOpen_->contents()); 356 WPushButton *annule = new WPushButton("cancel",dialogOpen_->contents()); 357 WPushButton *submit = new WPushButton("OK",dialogOpen_->contents()); 358 annule->clicked().connect(dialogOpen_, &Wt::WDialog::reject); 359 submit->clicked().connect(dialogOpen_, &Wt::WDialog::accept); 360 dialogOpen_->finished().connect(this, &PspaApplication::dialogOpenDone); 361 dialogOpen_->show(); 362 } 363 364 void PspaApplication::dialogOpenDone(WDialog::DialogCode code) 365 { 366 if (code != Wt::WDialog::Accepted) { 367 console_->addConsoleMessage(" pas de restauration"); 368 return; 369 } else { 370 console_->addConsoleMessage("restauration depuis le repertoire " + workingDir_ ); 371 } 372 373 nameOfCase_ = openNameEdit_->text().toUTF8(); 374 cout << " PspaApplication::dialogOpenDone() nameOfCase_= " << nameOfCase_ << endl; 375 delete dialogOpen_; 376 dialogSave_ = NULL; 377 378 bool test = dtmanage_->restoreElements(nameOfCase_); 379 if ( !test ) { 380 GWt_dialog restoreWarning(" element restoring", "failure in restoring elements !", GWt_dialog::Error, false,true); 381 restoreWarning.exec(); 382 } 383 384 GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_); 385 bibi->renew(); 386 387 console_->addConsoleMessage(string("...terminee")); 388 } 354 GWt_serverFileSelector * fs = new GWt_serverFileSelector("Select a configuration file",workingDir_); 355 nameOfCase_ = fs->exec(); 356 357 dialogSave_ = NULL; 358 359 bool test = dtmanage_->restoreElements(nameOfCase_); 360 if ( !test ) { 361 GWt_dialog restoreWarning(" element restoring", "failure in restoring elements !", GWt_dialog::Error, false,true); 362 restoreWarning.exec(); 363 } 364 365 GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_); 366 bibi->renew(); 367 368 console_->addConsoleMessage(string("...terminee")); 369 } 370 389 371 390 372 void PspaApplication::openFileSelector() -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_serverFileSelector.cc
r330 r336 1 1 #include <Wt/WVBoxLayout> 2 #include <Wt/WHBoxLayout> 2 3 #include <Wt/WImage> 3 4 #include <Wt/WText> … … 6 7 #include <Wt/WPushButton> 7 8 #include <Wt/WCssDecorationStyle> 9 #include <Wt/WTree> 10 #include <Wt/WTreeNode> 11 #include <Wt/WIconPair> 12 #include <boost/algorithm/string.hpp> 13 #include <dirent.h> /* readdir(), etc. */ 14 #include <sys/stat.h> /* stat(), etc. */ 15 8 16 #include "GWt_serverFileSelector.h" 9 17 18 10 19 GWt_serverFileSelector::GWt_serverFileSelector( 11 WString titre, 12 WContainerWidget* wc, 13 bool modal 14 ): 15 WDialog(titre) 20 WString titre, 21 std::string wd): 22 GWt_dialog(titre, NULL, true) 16 23 { 17 24 18 // change the title bar style 19 titleBar()->decorationStyle().setBackgroundColor (WColor(70,180,220)); 25 workingDir_ = wd; 26 27 Wt::WIconPair *folderIcon = new Wt::WIconPair("htdocs/yellow-folder-closed.png", 28 "htdocs/yellow-folder-open.png", false); 29 30 treeRoot_ = new Wt::WTree(); 31 treeRoot_->setSelectionMode(Wt::SingleSelection); 32 33 /* this structure is used for storing the name of each entry in turn. */ 34 struct dirent* entry; 35 36 /* read the directory's contents, print out the name of each entry. */ 37 printf("Directory contents:\n"); 38 DIR* dir = opendir(workingDir_.c_str()); 39 if (!dir) { 40 perror("opendir"); 41 exit(1); 42 } 43 struct stat dir_stat; /* used by stat(). */ 44 while ( (entry = readdir(dir)) != NULL) { 45 /* check if the given entry is a directory. */ 46 if (stat(entry->d_name, &dir_stat) == -1) { 47 perror("stat:"); 48 printf("stat:%s\n",entry->d_name); 49 continue; 50 } else { 51 printf("false%s\n", entry->d_name); 52 } 53 } 54 55 56 Wt::WTreeNode* treeFileRoot = new Wt::WTreeNode("Workspace", folderIcon); 57 58 treeFileRoot->setStyleClass("example-tree"); 59 treeRoot_->setTreeRoot(treeFileRoot); 60 treeFileRoot->label()->setTextFormat(Wt::PlainText); 61 treeFileRoot->setImagePack("resources/"); 62 treeFileRoot->setLoadPolicy(Wt::WTreeNode::NextLevelLoading); 63 64 buildConfigurationFileTree(treeFileRoot, workingDir_.c_str(), ".save"); 65 66 treeFileRoot->expand(); 67 WContainerWidget *treeContainer = new WContainerWidget(); 68 treeContainer->addWidget(treeRoot_); 69 70 WContainerWidget *buttonContainer = new WContainerWidget(); 71 WHBoxLayout* hButtonLayout = new WHBoxLayout(); 72 buttonContainer->setLayout(hButtonLayout); 73 74 WPushButton *annule = new WPushButton("cancel"); 75 WPushButton *submit = new WPushButton("OK"); 76 hButtonLayout->addWidget(annule); 77 hButtonLayout->addWidget(submit); 78 79 annule->clicked().connect(this, &Wt::WDialog::reject); 80 submit->clicked().connect(this, &Wt::WDialog::accept); 81 82 83 // overload the container already present 20 84 21 85 WContainerWidget* widgt = new WContainerWidget(contents()); 22 WHBoxLayout* hLayout = new WHBoxLayout(); 23 hLayout->addWidget(wc); 24 widgt->setLayout(hLayout); 86 WVBoxLayout* vLayout = new WVBoxLayout(); 87 vLayout->addWidget(treeContainer); 88 vLayout->addWidget(buttonContainer); 89 widgt->setLayout(vLayout); 25 90 26 setClosable(true);27 setModal (modal);28 91 } 29 92 30 93 31 94 32 GWt_serverFileSelector::GWt_serverFileSelector( 33 WString titre, 34 WString message, 35 iconType icon, 36 bool modal, 37 bool ok 38 ): 39 WDialog(titre) 95 /* 96 * function: findfile. recusively traverse the current directory, searching 97 * for files with a given string in their name. 98 * input: string to match. 99 * output: any file found, printed to the screen with a full path. 100 */ 101 void GWt_serverFileSelector::buildConfigurationFileTree(Wt::WTreeNode *treeFileRoot, const char* folder, const char* pattern) 40 102 { 103 #define MAX_DIR_PATH 2048 /* maximal full path we support. */ 41 104 42 // change the title bar style 43 titleBar()->decorationStyle().setBackgroundColor (WColor(70,180,220)); 105 DIR* dir; /* pointer to the scanned directory. */ 106 struct dirent* entry; /* pointer to one directory entry. */ 107 char cwd[MAX_DIR_PATH+1]; /* current working directory. */ 108 struct stat dir_stat; /* used by stat(). */ 44 109 45 WContainerWidget* widgt = new WContainerWidget(contents()); 46 WHBoxLayout* hLayout = new WHBoxLayout(); 47 48 WImage* tImg = new WImage("icons/error.png"); 49 switch (icon) { 50 case Warning: 51 tImg->setImageLink ("icons/warning.png"); 52 tImg->setMaximumSize (70,70); 53 hLayout->addWidget(tImg); 54 break; 55 case Error: 56 tImg->setImageLink ("icons/error.png"); 57 tImg->setMaximumSize (70,70); 58 hLayout->addWidget(tImg); 59 break; 60 case Info: 61 tImg->setImageLink ("icons/info.png"); 62 tImg->setMaximumSize (70,70); 63 hLayout->addWidget(tImg); 64 break; 65 case Wait: 66 tImg->setImageLink ("icons/patientez.gif"); 67 tImg->setMaximumSize (70,70); 68 hLayout->addWidget(tImg); 69 break; 70 case NoIcon: 71 break; 72 default: 73 break; 110 /* first, save path of current working directory */ 111 if (!getcwd(cwd, MAX_DIR_PATH+1)) { 112 perror("getcwd:"); 113 return; 74 114 } 75 115 76 WContainerWidget* right = new WContainerWidget();77 WVBoxLayout* vLayout = new WVBoxLayout();78 116 79 // changement des "\n" par des <br> 80 size_t pos = message.toUTF8().find("\n", 0); 81 82 while(pos != std::string::npos) { 83 vLayout->addWidget(new Wt::WText(WString::fromUTF8(message.toUTF8 ().substr(0,pos)))); 84 message = message.toUTF8 ().substr(pos+1); 85 pos = message.toUTF8 ().find("\n"); 86 vLayout->addWidget(new Wt::WBreak()); 87 } 88 vLayout->addWidget(new Wt::WText(message)); 89 90 91 if (ok) { 92 vLayout->addWidget(new Wt::WBreak); 93 94 Wt::WPushButton *ok = new Wt::WPushButton("Ok"); 95 vLayout->addWidget(ok); 96 97 // this event will accept() the Dialog 98 ok->clicked().connect(this, &Wt::WDialog::accept); 117 /* open the directory for reading */ 118 dir = opendir(folder); 119 if (!dir) { 120 fprintf(stderr, "Cannot read directory '%s': ", cwd); 121 perror(""); 122 return; 99 123 } 100 124 101 right->setLayout(vLayout); 102 hLayout->addWidget(right); 103 104 widgt->setLayout(hLayout); 105 106 setClosable(true); 107 setModal (modal); 125 /* scan the directory, traversing each sub-directory, and */ 126 /* matching the pattern for each file name. */ 127 while ((entry = readdir(dir))) { 128 129 /* skip the "." and ".." entries, to avoid loops. */ 130 if (strcmp(entry->d_name, ".") == 0) 131 continue; 132 if (strcmp(entry->d_name, "..") == 0) 133 continue; 134 if (strcmp(entry->d_name, ".svn") == 0) 135 continue; 136 /* check if the given entry is a directory. */ 137 if (entry->d_type == DT_DIR) { 138 printf("++DIR %s\n",entry->d_name); 139 Wt::WIconPair *folderIcon = new Wt::WIconPair("htdocs/yellow-folder-closed.png", 140 "htdocs/yellow-folder-open.png", false); 141 Wt::WTreeNode *child = new Wt::WTreeNode(entry->d_name, folderIcon); 142 treeFileRoot->addChildNode(child); 143 buildConfigurationFileTree(child,(std::string(folder)+entry->d_name).c_str(), pattern); 144 145 } else { 146 printf("++FILE %s\n",entry->d_name); 147 148 /* check if the pattern matchs. */ 149 if (boost::algorithm::ends_with(entry->d_name, pattern)) { 150 treeFileRoot->addChildNode(new Wt::WTreeNode(entry->d_name)); 151 printf("-----%s/%s\n", cwd, entry->d_name); 152 } 153 } 154 } 108 155 } 109 156 157 std::string GWt_serverFileSelector::exec() { 158 159 Wt::WDialog::DialogCode dc = WDialog::exec(); 160 if (dc == Rejected) { 161 return ""; 162 } 163 const Wt::WTree::WTreeNodeSet& tr = treeRoot_->selectedNodes(); 164 if (tr.empty()) { 165 return ""; 166 } 167 std::string path = (*tr.begin())->label()->text().toUTF8(); 110 168 169 Wt::WTreeNode* parent = (*tr.begin())->parentNode(); 170 while (parent) { 171 parent = parent->parentNode(); 172 if( parent) { 173 path = parent->label()->text().toUTF8()+"/"+path; 174 } 175 } 176 return workingDir_+path; 177 }
Note: See TracChangeset
for help on using the changeset viewer.