CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
CmsShowSearchFiles Class Reference

#include <Fireworks/Core/interface/CmsShowSearchFiles.h>

Inheritance diagram for CmsShowSearchFiles:

Public Member Functions

std::string chooseFileFromURL ()
 This opens the dialog window and returns once the user has choosen, returns an empty string if canceled. More...
 
 ClassDefOverride (CmsShowSearchFiles, 0)
 
 CmsShowSearchFiles (const char *filename, const char *windowname, const TGWindow *p=nullptr, 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 ()
 
 ~CmsShowSearchFiles () override
 

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
 
FWHtmlm_webFile
 

Detailed Description

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 35 of file CmsShowSearchFiles.h.

Constructor & Destructor Documentation

◆ CmsShowSearchFiles()

CmsShowSearchFiles::CmsShowSearchFiles ( const char *  filename,
const char *  windowname,
const TGWindow *  p = nullptr,
UInt_t  w = 1,
UInt_t  h = 1 
)

Definition at line 51 of file CmsShowSearchFiles.cc.

53  : TGTransientFrame(gClient->GetDefaultRoot(), p, w, h) {
54  TGVerticalFrame* vf = new TGVerticalFrame(this);
55  this->AddFrame(vf, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5));
56  TGHorizontalFrame* urlFrame = new TGHorizontalFrame(this);
57  vf->AddFrame(urlFrame, new TGLayoutHints(kLHintsExpandX, 5, 0, 5, 5));
58 
59  TGLabel* urlLabel = new TGLabel(urlFrame, "URL");
60  urlFrame->AddFrame(urlLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 1, 1, 1, 1));
61  m_choosePrefix = new TGTextButton(urlFrame, "Choose Prefix");
62  urlFrame->AddFrame(m_choosePrefix, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
63 
64  m_file = new TGTextEntry(urlFrame);
65  urlFrame->AddFrame(m_file, new TGLayoutHints(kLHintsExpandX, 1, 0, 1, 1));
66  m_file->Connect("TextChanged(const char*)", "CmsShowSearchFiles", this, "fileEntryChanged(const char*)");
67  m_file->Connect("ReturnPressed()", "CmsShowSearchFiles", this, "updateBrowser()");
68 
69  m_webFile = new FWHtml(vf, 1, 1);
70  m_webFile->Connect("MouseDown(const char*)", "CmsShowSearchFiles", this, "hyperlinkClicked(const char*)");
71  vf->AddFrame(m_webFile, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 1, 1, 1, 1));
72 
73  TGHorizontalFrame* buttonFrame = new TGHorizontalFrame(vf);
74  vf->AddFrame(buttonFrame, new TGLayoutHints(kLHintsExpandX, 1, 10, 1, 10));
75 
76  m_openButton = new TGTextButton(buttonFrame, "Open");
77  buttonFrame->AddFrame(m_openButton, new TGLayoutHints(kLHintsRight, 5, 5, 1, 1));
78  m_openButton->SetEnabled(kFALSE);
79  m_openButton->Connect("Clicked()", "CmsShowSearchFiles", this, "openClicked()");
80 
81  TGTextButton* cancel = new TGTextButton(buttonFrame, "Cancel");
82  buttonFrame->AddFrame(cancel, new TGLayoutHints(kLHintsRight, 5, 5, 1, 1));
83  cancel->Connect("Clicked()", "CmsShowSearchFiles", this, "UnmapWindow()");
84 
85  SetWindowName(windowname);
86 
88  Form("http://cmsshow-rels.web.cern.ch/cmsShow-rels/samples/%d/", fireworks::supportedDataFormatsVersion()[0]);
89 
90  if (!path.empty())
91  fwLog(fwlog::kInfo) << "Search files at " << path << "." << std::endl;
92 
94 
95  MapSubwindows();
96  Layout();
97  m_prefixMenu = nullptr;
98  m_choosePrefix->Connect("Clicked()", "CmsShowSearchFiles", this, "showPrefixes()");
99 }

References fwLog, fwlog::kInfo, m_choosePrefix, m_file, m_openButton, m_prefixMenu, m_webFile, castor_dqm_sourceclient_file_cfg::path, sendToWebBrowser(), AlCaHLTBitMon_QueryRunRegistry::string, and fireworks::supportedDataFormatsVersion().

◆ ~CmsShowSearchFiles()

CmsShowSearchFiles::~CmsShowSearchFiles ( )
override

Definition at line 101 of file CmsShowSearchFiles.cc.

101 { delete m_prefixMenu; }

References m_prefixMenu.

Member Function Documentation

◆ chooseFileFromURL()

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 318 of file CmsShowSearchFiles.cc.

318  {
319  DontCallClose();
320  Connect("CloseWindow()", "CmsShowSearchFiles", this, "UnmapWindow()");
321  m_openCalled = false;
322  MapWindow();
323  gClient->WaitForUnmap(this);
324 
325  if (!m_openCalled) {
326  return std::string();
327  }
328  return m_file->GetText();
329 }

References m_file, m_openCalled, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ClassDefOverride()

CmsShowSearchFiles::ClassDefOverride ( CmsShowSearchFiles  ,
 
)

◆ fileEntryChanged()

void CmsShowSearchFiles::fileEntryChanged ( const char *  iFileName)

Definition at line 124 of file CmsShowSearchFiles.cc.

124  {
125  std::string fileName = iFileName;
126  size_t index = fileName.find_last_of(".");
127  std::string postfix;
128  if (index != std::string::npos) {
129  postfix = fileName.substr(index, std::string::npos);
130  }
131  if (postfix == s_rootPostfix) {
132  m_openButton->SetEnabled(kTRUE);
133  } else {
134  m_openButton->SetEnabled(kFALSE);
135  }
136 }

References MillePedeFileConverter_cfg::fileName, m_openButton, s_rootPostfix(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ hyperlinkClicked()

void CmsShowSearchFiles::hyperlinkClicked ( const char *  iLink)

Definition at line 147 of file CmsShowSearchFiles.cc.

147  {
148  m_file->SetText(iLink, kTRUE);
149 
150  m_webFile->addToVisited(iLink);
151  std::string fileName = iLink;
152  size_t index = fileName.find_last_of(".");
153  std::string postfix = fileName.substr(index, std::string::npos);
154 
155  if (postfix != s_rootPostfix) {
156  updateBrowser();
157  } else {
158  openClicked();
159  }
160 }

References FWHtml::addToVisited(), MillePedeFileConverter_cfg::fileName, m_file, m_webFile, openClicked(), s_rootPostfix(), AlCaHLTBitMon_QueryRunRegistry::string, and updateBrowser().

◆ openClicked()

void CmsShowSearchFiles::openClicked ( )

Definition at line 164 of file CmsShowSearchFiles.cc.

164  {
165  m_openCalled = true;
166  this->UnmapWindow();
167 }

References m_openCalled.

Referenced by hyperlinkClicked().

◆ prefixChoosen()

void CmsShowSearchFiles::prefixChoosen ( Int_t  iIndex)

Definition at line 105 of file CmsShowSearchFiles.cc.

105  {
106  // printf ("pref chosen %d \n", iIndex);
107  m_file->SetText(m_prefixes[iIndex].c_str(), kFALSE);
108  m_openButton->SetEnabled(kFALSE);
109 
110  if (m_prefixComplete[iIndex]) {
111  //gClient->NeedRedraw(this);
112  gClient->NeedRedraw(m_choosePrefix);
113  gClient->NeedRedraw(m_webFile);
114  gClient->ProcessEventsFor(this);
115  updateBrowser();
116  } else {
117  std::string p;
119  }
120 }

References m_choosePrefix, m_file, m_openButton, m_prefixComplete, m_prefixes, m_webFile, AlCaHLTBitMon_ParallelJobs::p, sendToWebBrowser(), AlCaHLTBitMon_QueryRunRegistry::string, and updateBrowser().

◆ readError()

void CmsShowSearchFiles::readError ( )
private

Definition at line 269 of file CmsShowSearchFiles.cc.

269  {
270  const static char* s_readError[] = {
271  "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" "
272  "\"http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd\"> ",
273  "<HTML><HEAD><TITLE>HTTP Read Error</TITLE> ",
274  "<META http-equiv=Content-Type content=\"text/html; charset=UTF-8\"></HEAD> ",
275  "<BODY> ",
276  "<P>Unknown error while trying to get file via http</P>",
277  "</BODY></HTML> ",
278  nullptr};
279 
280  m_webFile->SetBaseUri("");
281  for (int i = 0; s_readError[i]; i++) {
282  m_webFile->ParseText(const_cast<char*>(s_readError[i]));
283  }
284 }

References mps_fire::i, and m_webFile.

Referenced by sendToWebBrowser().

◆ readInfo()

void CmsShowSearchFiles::readInfo ( )
private

Definition at line 286 of file CmsShowSearchFiles.cc.

286  {
287  const static char* s_noBrowserMessage[] = {
288  "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" "
289  "\"http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd\"> ",
290  "<HTML><HEAD><TITLE>No Browser Available</TITLE> ",
291  "<META http-equiv=Content-Type content=\"text/html; charset=UTF-8\"></HEAD> ",
292  "<BODY> ",
293  //"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>",
294  //"Only a prefix beginning in <STRONG>http:</STRONG> which contains a site name (e.g. http://www.site.org) is supported for browsing."
295  "<b>Welcome....</b><BR>",
296  "<BR>",
297  "<b>You may look at examples:</b><BR>",
298  "If you are in Europe, open example data files at CERN : ",
299  " <a href=",
300  Form("http://fireworks.web.cern.ch/fireworks/%d/", fireworks::supportedDataFormatsVersion()[0]),
301  "> http://fireworks.web.cern.ch/fireworks/ </a><BR>",
302  "If you are in US, open example data files at UCSD: ",
303  " <a href=",
304  Form("http://uaf-2.t2.ucsd.edu/fireworks/%d/", fireworks::supportedDataFormatsVersion()[0]),
305  ">http://uaf-2.t2.ucsd.edu/fireworks/ </a><BR>",
306  "<BR>"
307  "<b>You also may load files with Choose Prefix </b><BR>"
308  "</BODY></HTML> ",
309  nullptr};
310 
311  m_webFile->SetBaseUri("");
312  for (int i = 0; s_noBrowserMessage[i]; i++) {
313  m_webFile->ParseText((char*)s_noBrowserMessage[i]);
314  }
315 }

References mps_fire::i, m_webFile, and fireworks::supportedDataFormatsVersion().

Referenced by sendToWebBrowser().

◆ sendToWebBrowser()

void CmsShowSearchFiles::sendToWebBrowser ( std::string &  iWebFile)
private

Definition at line 232 of file CmsShowSearchFiles.cc.

232  {
233  // std::cout << "CmsShowSearchFiles::sendToWebBrowser " << fileName << std::endl ;
234 
235  size_t index = fileName.find_first_of(":");
236  if (index != std::string::npos) {
237  ++index;
238  } else {
239  index = 0;
240  }
241  std::string prefix = fileName.substr(0, index);
242 
243  m_webFile->Clear();
244  if (prefix == s_httpPrefix) {
245  gVirtualX->SetCursor(GetId(), gVirtualX->CreateCursor(kWatch));
246  //If you clicked a hyperlink then the cursor is still a hand but we now
247  // want it to be a watch
248  gVirtualX->SetCursor(m_webFile->GetId(), gVirtualX->CreateCursor(kWatch));
249  //If we don't call ProcessEventsFor then the cursor will not be updated
250  gClient->ProcessEventsFor(this);
251  TUrl url(fileName.c_str());
252  std::string buffer = readRemote(url.GetUrl());
253 
254  if (!buffer.empty()) {
255  m_webFile->SetBaseUri(url.GetUrl());
256  m_webFile->ParseText(const_cast<char*>(buffer.c_str()));
257  } else {
258  readError();
259  }
260  gVirtualX->SetCursor(GetId(), gVirtualX->CreateCursor(kPointer));
261  gVirtualX->SetCursor(m_webFile->GetId(), gVirtualX->CreateCursor(kPointer));
262  } else {
263  readInfo();
264  }
265  m_webFile->Layout();
266 }

References edmScanValgrind::buffer, MillePedeFileConverter_cfg::fileName, m_webFile, ZMuMuAnalysisNtupler_cff::prefix, readError(), readInfo(), readRemote(), s_httpPrefix(), AlCaHLTBitMon_QueryRunRegistry::string, and relmon_authenticated_wget::url.

Referenced by CmsShowSearchFiles(), prefixChoosen(), and updateBrowser().

◆ showPrefixes()

void CmsShowSearchFiles::showPrefixes ( )

Definition at line 171 of file CmsShowSearchFiles.cc.

171  {
172  if (nullptr == m_prefixMenu) {
173  m_prefixMenu = new TGPopupMenu(this);
174  const char* const(*itEnd)[s_columns] = s_prefixes + sizeof(s_prefixes) / sizeof(const char* [3]);
175  int index = 0;
176  for (const char* const(*it)[s_columns] = s_prefixes; it != itEnd; ++it, ++index) {
177  //only add the protocols this version of the code actually can load
178  std::string prefix = std::string((*it)[0]).substr(0, std::string((*it)[0]).find_first_of(":") + 1);
179  if (s_httpPrefix == prefix || s_filePrefix == prefix ||
180  (gPluginMgr->FindHandler("TSystem", prefix.c_str()) &&
181  gPluginMgr->FindHandler("TSystem", prefix.c_str())->CheckPlugin() != -1)) {
182  m_prefixMenu->AddEntry((std::string((*it)[0]) + " (" + ((*it)[1]) + ")").c_str(), index);
183  m_prefixes.push_back((*it)[0]);
184  m_prefixComplete.push_back(nullptr != (*it)[2]);
185  }
186  }
187  m_prefixMenu->Connect("Activated(Int_t)", "CmsShowSearchFiles", this, "prefixChoosen(Int_t)");
188  }
189  m_prefixMenu->PlaceMenu(m_choosePrefix->GetX(), m_choosePrefix->GetY(), true, true);
190 }

References m_choosePrefix, m_prefixComplete, m_prefixes, m_prefixMenu, ZMuMuAnalysisNtupler_cff::prefix, s_columns, s_filePrefix(), s_httpPrefix(), s_prefixes, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ updateBrowser()

void CmsShowSearchFiles::updateBrowser ( )

Definition at line 140 of file CmsShowSearchFiles.cc.

140  {
141  std::string n = m_file->GetText();
143 }

References m_file, dqmiodumpmetadata::n, sendToWebBrowser(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by hyperlinkClicked(), and prefixChoosen().

Member Data Documentation

◆ m_choosePrefix

TGTextButton* CmsShowSearchFiles::m_choosePrefix
private

Definition at line 60 of file CmsShowSearchFiles.h.

Referenced by CmsShowSearchFiles(), prefixChoosen(), and showPrefixes().

◆ m_file

TGTextEntry* CmsShowSearchFiles::m_file
private

◆ m_openButton

TGTextButton* CmsShowSearchFiles::m_openButton
private

Definition at line 66 of file CmsShowSearchFiles.h.

Referenced by CmsShowSearchFiles(), fileEntryChanged(), and prefixChoosen().

◆ m_openCalled

bool CmsShowSearchFiles::m_openCalled
private

Definition at line 67 of file CmsShowSearchFiles.h.

Referenced by chooseFileFromURL(), and openClicked().

◆ m_prefixComplete

std::vector<bool> CmsShowSearchFiles::m_prefixComplete
private

Definition at line 65 of file CmsShowSearchFiles.h.

Referenced by prefixChoosen(), and showPrefixes().

◆ m_prefixes

std::vector<std::string> CmsShowSearchFiles::m_prefixes
private

Definition at line 64 of file CmsShowSearchFiles.h.

Referenced by prefixChoosen(), and showPrefixes().

◆ m_prefixMenu

TGPopupMenu* CmsShowSearchFiles::m_prefixMenu
private

Definition at line 61 of file CmsShowSearchFiles.h.

Referenced by CmsShowSearchFiles(), showPrefixes(), and ~CmsShowSearchFiles().

◆ m_webFile

FWHtml* CmsShowSearchFiles::m_webFile
private
s_rootPostfix
static const std::string s_rootPostfix(".root")
fwLog
#define fwLog(_level_)
Definition: fwLog.h:45
relmon_authenticated_wget.url
url
Definition: relmon_authenticated_wget.py:22
mps_fire.i
i
Definition: mps_fire.py:355
s_prefixes
const static char *const s_prefixes[][s_columns]
Definition: CmsShowSearchFiles.cc:40
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
s_columns
const static unsigned int s_columns
Definition: CmsShowSearchFiles.cc:39
FWHtml
Definition: CmsShowSearchFiles.cc:23
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
CmsShowSearchFiles::sendToWebBrowser
void sendToWebBrowser(std::string &iWebFile)
Definition: CmsShowSearchFiles.cc:232
CmsShowSearchFiles::openClicked
void openClicked()
Definition: CmsShowSearchFiles.cc:164
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
fireworks::supportedDataFormatsVersion
int * supportedDataFormatsVersion()
Definition: fwPaths.cc:35
CmsShowSearchFiles::readInfo
void readInfo()
Definition: CmsShowSearchFiles.cc:286
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
w
const double w
Definition: UKUtility.cc:23
CmsShowSearchFiles::m_prefixes
std::vector< std::string > m_prefixes
Definition: CmsShowSearchFiles.h:64
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
s_filePrefix
static const std::string s_filePrefix("file:")
FWHtml::addToVisited
void addToVisited(const char *iToVisit)
Definition: CmsShowSearchFiles.cc:33
CmsShowSearchFiles::readError
void readError()
Definition: CmsShowSearchFiles.cc:269
CmsShowSearchFiles::m_choosePrefix
TGTextButton * m_choosePrefix
Definition: CmsShowSearchFiles.h:60
CmsShowSearchFiles::m_prefixComplete
std::vector< bool > m_prefixComplete
Definition: CmsShowSearchFiles.h:65
CmsShowSearchFiles::m_prefixMenu
TGPopupMenu * m_prefixMenu
Definition: CmsShowSearchFiles.h:61
CmsShowSearchFiles::m_file
TGTextEntry * m_file
Definition: CmsShowSearchFiles.h:62
s_httpPrefix
static const std::string s_httpPrefix("http:")
fwlog::kInfo
Definition: fwLog.h:35
readRemote
static std::string readRemote(const char *url)
Definition: CmsShowSearchFiles.cc:195
CmsShowSearchFiles::m_openCalled
bool m_openCalled
Definition: CmsShowSearchFiles.h:67
CmsShowSearchFiles::m_webFile
FWHtml * m_webFile
Definition: CmsShowSearchFiles.h:63
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
CmsShowSearchFiles::updateBrowser
void updateBrowser()
Definition: CmsShowSearchFiles.cc:140
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
CmsShowSearchFiles::m_openButton
TGTextButton * m_openButton
Definition: CmsShowSearchFiles.h:66
ZMuMuAnalysisNtupler_cff.prefix
prefix
Definition: ZMuMuAnalysisNtupler_cff.py:14