11 #include "TGTextEntry.h" 12 #include "TPluginManager.h" 16 #include "TVirtualX.h" 18 #include "TVirtualX.h" 25 FWHtml(
const TGWindow*
p,
int w,
int h,
int id = -1) : TGHtml(
p,
w,
h,
id) {}
41 {
"file:",
"Local file [you must type full path name]",
nullptr},
42 {
"dcap://",
"dCache [FNAL]",
nullptr},
43 {
"rfio://",
"Castor [CERN]",
nullptr}
52 const char*
filename,
const char* windowname,
const TGWindow*
p, UInt_t
w, UInt_t
h)
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));
59 TGLabel* urlLabel =
new TGLabel(urlFrame,
"URL");
60 urlFrame->AddFrame(urlLabel,
new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 1, 1, 1, 1));
62 urlFrame->AddFrame(
m_choosePrefix,
new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
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()");
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));
73 TGHorizontalFrame* buttonFrame =
new TGHorizontalFrame(vf);
74 vf->AddFrame(buttonFrame,
new TGLayoutHints(kLHintsExpandX, 1, 10, 1, 10));
77 buttonFrame->AddFrame(
m_openButton,
new TGLayoutHints(kLHintsRight, 5, 5, 1, 1));
79 m_openButton->Connect(
"Clicked()",
"CmsShowSearchFiles",
this,
"openClicked()");
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()");
85 SetWindowName(windowname);
98 m_choosePrefix->Connect(
"Clicked()",
"CmsShowSearchFiles",
this,
"showPrefixes()");
114 gClient->ProcessEventsFor(
this);
128 if (
index != std::string::npos) {
148 m_file->SetText(iLink, kTRUE);
180 (gPluginMgr->FindHandler(
"TSystem",
prefix.c_str()) &&
181 gPluginMgr->FindHandler(
"TSystem",
prefix.c_str())->CheckPlugin() != -1)) {
187 m_prefixMenu->Connect(
"Activated(Int_t)",
"CmsShowSearchFiles",
this,
"prefixChoosen(Int_t)");
201 TString
msg =
"GET ";
202 msg += fUrl.GetProtocol();
204 msg += fUrl.GetHost();
206 msg += fUrl.GetPort();
208 msg += fUrl.GetFile();
212 if (!uri.BeginsWith(
"http://"))
214 TSocket
s(fUrl.GetHost(), fUrl.GetPort());
217 if (
s.SendRaw(
msg.Data(),
msg.Length()) == -1)
219 Int_t
size = 1024 * 1024;
220 buf = (
char*)calloc(
size,
sizeof(
char));
236 if (
index != std::string::npos) {
245 gVirtualX->SetCursor(GetId(), gVirtualX->CreateCursor(kWatch));
248 gVirtualX->SetCursor(
m_webFile->GetId(), gVirtualX->CreateCursor(kWatch));
250 gClient->ProcessEventsFor(
this);
260 gVirtualX->SetCursor(GetId(), gVirtualX->CreateCursor(kPointer));
261 gVirtualX->SetCursor(
m_webFile->GetId(), gVirtualX->CreateCursor(kPointer));
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> ",
276 "<P>Unknown error while trying to get file via http</P>",
281 for (
int i = 0; s_readError[
i];
i++) {
282 m_webFile->ParseText(const_cast<char*>(s_readError[
i]));
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> ",
295 "<b>Welcome....</b><BR>",
297 "<b>You may look at examples:</b><BR>",
298 "If you are in Europe, open example data files at CERN : ",
301 "> http://fireworks.web.cern.ch/fireworks/ </a><BR>",
302 "If you are in US, open example data files at UCSD: ",
305 ">http://uaf-2.t2.ucsd.edu/fireworks/ </a><BR>",
307 "<b>You also may load files with Choose Prefix </b><BR>" 312 for (
int i = 0; s_noBrowserMessage[
i];
i++) {
313 m_webFile->ParseText((
char*)s_noBrowserMessage[
i]);
320 Connect(
"CloseWindow()",
"CmsShowSearchFiles",
this,
"UnmapWindow()");
323 gClient->WaitForUnmap(
this);
void prefixChoosen(Int_t)
void addToVisited(const char *iToVisit)
~CmsShowSearchFiles() override
std::vector< bool > m_prefixComplete
static const char *const s_prefixes[][s_columns]
TGTextButton * m_choosePrefix
static const std::string s_filePrefix("file:")
void fileEntryChanged(const char *)
int * supportedDataFormatsVersion()
FWHtml(const TGWindow *p, int w, int h, int id=-1)
TGPopupMenu * m_prefixMenu
int IsVisited(const char *iCheck) override
TGTextButton * m_openButton
static const std::string s_httpPrefix("http:")
std::vector< std::string > m_prefixes
static const unsigned int s_columns
std::set< std::string > m_visited
CmsShowSearchFiles(const char *filename, const char *windowname, const TGWindow *p=nullptr, UInt_t w=1, UInt_t h=1)
void sendToWebBrowser(std::string &iWebFile)
void hyperlinkClicked(const char *)
static std::string readRemote(const char *url)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
std::string chooseFileFromURL()
This opens the dialog window and returns once the user has choosen, returns an empty string if cancel...
static const std::string s_rootPostfix(".root")