#include <Fireworks/Core/interface/CmsShowSearchFiles.h>
Public Member Functions | |
std::string | chooseFileFromURL () |
This opens the dialog window and returns once the user has choosen, returns an empty string if canceled. | |
ClassDef (CmsShowSearchFiles, 0) | |
CmsShowSearchFiles (const char *filename, const char *windowname, const TGWindow *p=0, UInt_t w=1, UInt_t h=1) | |
void | fileEntryChanged (const char *) |
void | hyperlinkClicked (const char *) |
void | openClicked () |
void | prefixChoosen (Int_t) |
void | showPrefixes () |
void | updateBrowser () |
virtual | ~CmsShowSearchFiles () |
Private Member Functions | |
void | readError () |
void | readInfo () |
void | sendToWebBrowser (std::string &iWebFile) |
Private Attributes | |
TGTextButton * | m_choosePrefix |
TGTextEntry * | m_file |
TGTextButton * | m_openButton |
bool | m_openCalled |
std::vector< bool > | m_prefixComplete |
std::vector< std::string > | m_prefixes |
TGPopupMenu * | m_prefixMenu |
FWHtml * | m_webFile |
Description: <one line="" class="" summary>="">
Usage: <usage>
Definition at line 36 of file CmsShowSearchFiles.h.
CmsShowSearchFiles::CmsShowSearchFiles | ( | const char * | filename, |
const char * | windowname, | ||
const TGWindow * | p = 0 , |
||
UInt_t | w = 1 , |
||
UInt_t | h = 1 |
||
) |
Definition at line 72 of file CmsShowSearchFiles.cc.
References fwLog, fwlog::kInfo, m_choosePrefix, m_file, m_openButton, m_prefixMenu, m_webFile, scaleCards::path, sendToWebBrowser(), and fireworks::supportedDataFormatsVersion().
: TGTransientFrame(gClient->GetDefaultRoot(), p, w, h) { TGVerticalFrame* vf = new TGVerticalFrame(this); this->AddFrame(vf,new TGLayoutHints(kLHintsExpandX|kLHintsExpandY,5,5,5,5)); TGHorizontalFrame* urlFrame = new TGHorizontalFrame(this); vf->AddFrame(urlFrame,new TGLayoutHints(kLHintsExpandX,5,0,5,5)); TGLabel* urlLabel = new TGLabel(urlFrame,"URL"); urlFrame->AddFrame(urlLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY,1,1,1,1)); m_choosePrefix = new TGTextButton(urlFrame,"Choose Prefix"); urlFrame->AddFrame(m_choosePrefix, new TGLayoutHints(kLHintsLeft,1,1,1,1)); m_file= new TGTextEntry(urlFrame); urlFrame->AddFrame(m_file, new TGLayoutHints(kLHintsExpandX,1,0,1,1)); m_file->Connect("TextChanged(const char*)", "CmsShowSearchFiles",this,"fileEntryChanged(const char*)"); m_file->Connect("ReturnPressed()", "CmsShowSearchFiles",this,"updateBrowser()"); m_webFile = new FWHtml(vf,1,1); m_webFile->Connect("MouseDown(const char*)","CmsShowSearchFiles",this,"hyperlinkClicked(const char*)"); vf->AddFrame(m_webFile, new TGLayoutHints(kLHintsExpandX|kLHintsExpandY,1,1,1,1)); TGHorizontalFrame* buttonFrame = new TGHorizontalFrame(vf); vf->AddFrame(buttonFrame, new TGLayoutHints(kLHintsExpandX,1,10,1,10)); m_openButton = new TGTextButton(buttonFrame,"Open"); buttonFrame->AddFrame(m_openButton, new TGLayoutHints(kLHintsRight,5,5,1,1)); m_openButton->SetEnabled(kFALSE); m_openButton->Connect("Clicked()","CmsShowSearchFiles",this,"openClicked()"); TGTextButton* cancel = new TGTextButton(buttonFrame,"Cancel"); buttonFrame->AddFrame(cancel, new TGLayoutHints(kLHintsRight,5,5,1,1)); cancel->Connect("Clicked()","CmsShowSearchFiles",this,"UnmapWindow()"); SetWindowName(windowname); float x1 = getURLResponseTime("lxplus.cern.ch"); float x2 = getURLResponseTime("uaf-2.t2.ucsd.edu"); // printf("timtes %f %f \n", x1, x2); fflush(stdout); std::string path; if (x1 > 0 && x1 < x2) path = Form("http://fireworks.web.cern.ch/fireworks/%d/",fireworks::supportedDataFormatsVersion()[0] ); else if (x2 > 0) path = Form("http://uaf-2.t2.ucsd.edu/fireworks/%d/", fireworks::supportedDataFormatsVersion()[0]); if (!path.empty()) fwLog(fwlog::kInfo) << "Search files at " << path << "." << std::endl; sendToWebBrowser(path); MapSubwindows(); Layout(); m_prefixMenu=0; m_choosePrefix->Connect("Clicked()","CmsShowSearchFiles",this,"showPrefixes()"); }
CmsShowSearchFiles::~CmsShowSearchFiles | ( | ) | [virtual] |
Definition at line 131 of file CmsShowSearchFiles.cc.
References m_prefixMenu.
{ delete m_prefixMenu; }
std::string CmsShowSearchFiles::chooseFileFromURL | ( | ) |
This opens the dialog window and returns once the user has choosen, returns an empty string if canceled.
Definition at line 375 of file CmsShowSearchFiles.cc.
References m_file, and m_openCalled.
{ DontCallClose(); Connect("CloseWindow()","CmsShowSearchFiles",this,"UnmapWindow()"); m_openCalled = false; MapWindow(); gClient->WaitForUnmap(this); if(!m_openCalled) { return std::string(); } return m_file->GetText(); }
CmsShowSearchFiles::ClassDef | ( | CmsShowSearchFiles | , |
0 | |||
) |
void CmsShowSearchFiles::fileEntryChanged | ( | const char * | iFileName | ) |
Definition at line 161 of file CmsShowSearchFiles.cc.
References convertXMLtoSQLite_cfg::fileName, getHLTprescales::index, m_openButton, and s_rootPostfix().
{ std::string fileName =iFileName; size_t index = fileName.find_last_of("."); std::string postfix; if(index != std::string::npos) { postfix=fileName.substr(index,std::string::npos); } if(postfix ==s_rootPostfix) { m_openButton->SetEnabled(kTRUE); } else { m_openButton->SetEnabled(kFALSE); } }
void CmsShowSearchFiles::hyperlinkClicked | ( | const char * | iLink | ) |
Definition at line 189 of file CmsShowSearchFiles.cc.
References FWHtml::addToVisited(), convertXMLtoSQLite_cfg::fileName, getHLTprescales::index, m_file, m_webFile, openClicked(), s_rootPostfix(), and updateBrowser().
{ m_file->SetText(iLink,kTRUE); m_webFile->addToVisited(iLink); std::string fileName =iLink; size_t index = fileName.find_last_of("."); std::string postfix = fileName.substr(index,std::string::npos); if(postfix !=s_rootPostfix) { updateBrowser(); } else { openClicked(); } }
void CmsShowSearchFiles::openClicked | ( | ) |
Definition at line 208 of file CmsShowSearchFiles.cc.
References m_openCalled.
Referenced by hyperlinkClicked().
{ m_openCalled=true; this->UnmapWindow(); }
void CmsShowSearchFiles::prefixChoosen | ( | Int_t | iIndex | ) |
Definition at line 139 of file CmsShowSearchFiles.cc.
References m_choosePrefix, m_file, m_openButton, m_prefixComplete, m_prefixes, m_webFile, AlCaHLTBitMon_ParallelJobs::p, sendToWebBrowser(), and updateBrowser().
{ // printf ("pref chosen %d \n", iIndex); m_file->SetText(m_prefixes[iIndex].c_str(),kFALSE); m_openButton->SetEnabled(kFALSE); if(m_prefixComplete[iIndex]) { //gClient->NeedRedraw(this); gClient->NeedRedraw(m_choosePrefix); gClient->NeedRedraw(m_webFile); gClient->ProcessEventsFor(this); updateBrowser(); } else { std::string p; sendToWebBrowser(p); } }
void CmsShowSearchFiles::readError | ( | ) | [private] |
Definition at line 326 of file CmsShowSearchFiles.cc.
Referenced by sendToWebBrowser().
{ const static char *s_readError[] = { "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd\"> ", "<HTML><HEAD><TITLE>HTTP Read Error</TITLE> ", "<META http-equiv=Content-Type content=\"text/html; charset=UTF-8\"></HEAD> ", "<BODY> ", "<P>Unknown error while trying to get file via http</P>", "</BODY></HTML> ", 0 }; m_webFile->SetBaseUri(""); for (int i=0; s_readError[i]; i++) { m_webFile->ParseText(const_cast<char *>(s_readError[i])); } }
void CmsShowSearchFiles::readInfo | ( | ) | [private] |
Definition at line 346 of file CmsShowSearchFiles.cc.
References i, m_webFile, and fireworks::supportedDataFormatsVersion().
Referenced by sendToWebBrowser().
{ const static char *s_noBrowserMessage[] = { "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd\"> ", "<HTML><HEAD><TITLE>No Browser Available</TITLE> ", "<META http-equiv=Content-Type content=\"text/html; charset=UTF-8\"></HEAD> ", "<BODY> ", //"No file browser is available for this prefix. You can still type the full URL into the above text box to open the EDM ROOT file.<BR>", //"Only a prefix beginning in <STRONG>http:</STRONG> which contains a site name (e.g. http://www.site.org) is supported for browsing." "<b>Welcome....</b><BR>", "<BR>", "<b>You may look at examples:</b><BR>", "If you are in Europe, open example data files at CERN : ", " <a href=" , Form("http://fireworks.web.cern.ch/fireworks/%d/",fireworks::supportedDataFormatsVersion()[0] ),"> http://fireworks.web.cern.ch/fireworks/ </a><BR>", "If you are in US, open example data files at UCSD: ", " <a href=" , Form("http://uaf-2.t2.ucsd.edu/fireworks/%d/",fireworks::supportedDataFormatsVersion()[0] ),">http://uaf-2.t2.ucsd.edu/fireworks/ </a><BR>", "<BR>" "<b>You also may load files with Choose Prefix </b><BR>" "</BODY></HTML> ", 0 }; m_webFile->SetBaseUri(""); for (int i=0; s_noBrowserMessage[i]; i++) { m_webFile->ParseText((char *)s_noBrowserMessage[i]); } }
void CmsShowSearchFiles::sendToWebBrowser | ( | std::string & | iWebFile | ) | [private] |
Definition at line 286 of file CmsShowSearchFiles.cc.
References getHLTprescales::index, m_webFile, prof2calltree::prefix, readError(), readInfo(), readRemote(), s_httpPrefix(), and relmon_authenticated_wget::url.
Referenced by CmsShowSearchFiles(), prefixChoosen(), and updateBrowser().
{ // std::cout << "CmsShowSearchFiles::sendToWebBrowser " << fileName << std::endl ; size_t index = fileName.find_first_of(":"); if(index != std::string::npos) { ++index; } else { index = 0; } std::string prefix = fileName.substr(0,index); m_webFile->Clear(); if(prefix == s_httpPrefix) { gVirtualX->SetCursor(GetId(),gVirtualX->CreateCursor(kWatch)); //If you clicked a hyperlink then the cursor is still a hand but we now // want it to be a watch gVirtualX->SetCursor(m_webFile->GetId(),gVirtualX->CreateCursor(kWatch)); //If we don't call ProcessEventsFor then the cursor will not be updated gClient->ProcessEventsFor(this); TUrl url(fileName.c_str()); std::string buffer = readRemote(url.GetUrl()); if (buffer.size()) { m_webFile->SetBaseUri(url.GetUrl()); m_webFile->ParseText(const_cast<char*>(buffer.c_str())); } else { readError(); } gVirtualX->SetCursor(GetId(),gVirtualX->CreateCursor(kPointer)); gVirtualX->SetCursor(m_webFile->GetId(),gVirtualX->CreateCursor(kPointer)); } else { readInfo(); } m_webFile->Layout(); }
void CmsShowSearchFiles::showPrefixes | ( | ) |
Definition at line 217 of file CmsShowSearchFiles.cc.
References getHLTprescales::index, m_choosePrefix, m_prefixComplete, m_prefixes, m_prefixMenu, prof2calltree::prefix, s_columns, s_filePrefix(), s_httpPrefix(), and s_prefixes.
{ if(0==m_prefixMenu) { m_prefixMenu = new TGPopupMenu(this); const char* const (*itEnd)[s_columns] = s_prefixes+sizeof(s_prefixes)/sizeof(const char*[3]); int index = 0; for(const char* const (*it)[s_columns] = s_prefixes; it != itEnd; ++it,++index) { //only add the protocols this version of the code actually can load std::string prefix = std::string((*it)[0]).substr(0,std::string((*it)[0]).find_first_of(":")+1); if(s_httpPrefix==prefix || s_filePrefix==prefix || (gPluginMgr->FindHandler("TSystem",prefix.c_str()) && gPluginMgr->FindHandler("TSystem",prefix.c_str())->CheckPlugin() != -1)) { m_prefixMenu->AddEntry((std::string((*it)[0])+" ("+((*it)[1])+")").c_str(),index); m_prefixes.push_back((*it)[0]); m_prefixComplete.push_back(0!=(*it)[2]); } } m_prefixMenu->Connect("Activated(Int_t)","CmsShowSearchFiles",this,"prefixChoosen(Int_t)"); } m_prefixMenu->PlaceMenu(m_choosePrefix->GetX(),m_choosePrefix->GetY(),true,true); }
void CmsShowSearchFiles::updateBrowser | ( | ) |
Definition at line 179 of file CmsShowSearchFiles.cc.
References m_file, n, and sendToWebBrowser().
Referenced by hyperlinkClicked(), and prefixChoosen().
{ std::string n = m_file->GetText(); sendToWebBrowser(n); }
TGTextButton* CmsShowSearchFiles::m_choosePrefix [private] |
Definition at line 64 of file CmsShowSearchFiles.h.
Referenced by CmsShowSearchFiles(), prefixChoosen(), and showPrefixes().
TGTextEntry* CmsShowSearchFiles::m_file [private] |
Definition at line 66 of file CmsShowSearchFiles.h.
Referenced by chooseFileFromURL(), CmsShowSearchFiles(), hyperlinkClicked(), prefixChoosen(), and updateBrowser().
TGTextButton* CmsShowSearchFiles::m_openButton [private] |
Definition at line 70 of file CmsShowSearchFiles.h.
Referenced by CmsShowSearchFiles(), fileEntryChanged(), and prefixChoosen().
bool CmsShowSearchFiles::m_openCalled [private] |
Definition at line 71 of file CmsShowSearchFiles.h.
Referenced by chooseFileFromURL(), and openClicked().
std::vector<bool> CmsShowSearchFiles::m_prefixComplete [private] |
Definition at line 69 of file CmsShowSearchFiles.h.
Referenced by prefixChoosen(), and showPrefixes().
std::vector<std::string> CmsShowSearchFiles::m_prefixes [private] |
Definition at line 68 of file CmsShowSearchFiles.h.
Referenced by prefixChoosen(), and showPrefixes().
TGPopupMenu* CmsShowSearchFiles::m_prefixMenu [private] |
Definition at line 65 of file CmsShowSearchFiles.h.
Referenced by CmsShowSearchFiles(), showPrefixes(), and ~CmsShowSearchFiles().
FWHtml* CmsShowSearchFiles::m_webFile [private] |
Definition at line 67 of file CmsShowSearchFiles.h.
Referenced by CmsShowSearchFiles(), hyperlinkClicked(), prefixChoosen(), readError(), readInfo(), and sendToWebBrowser().