CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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...
 
 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 sendToWebBrowser (const char *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 36 of file CmsShowSearchFiles.h.

Constructor & Destructor Documentation

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

Definition at line 81 of file CmsShowSearchFiles.cc.

References m_choosePrefix, m_file, m_openButton, m_prefixMenu, m_webFile, and sendToWebBrowser().

84  : TGTransientFrame(gClient->GetDefaultRoot(), p, w, h)
85 {
86  TGVerticalFrame* vf = new TGVerticalFrame(this);
87  this->AddFrame(vf,new TGLayoutHints(kLHintsExpandX|kLHintsExpandY,5,5,5,5));
88  TGHorizontalFrame* urlFrame = new TGHorizontalFrame(this);
89  vf->AddFrame(urlFrame,new TGLayoutHints(kLHintsExpandX,5,0,5,5));
90 
91  TGLabel* urlLabel = new TGLabel(urlFrame,"URL");
92  urlFrame->AddFrame(urlLabel, new TGLayoutHints(kLHintsLeft|kLHintsCenterY,1,1,1,1));
93  m_choosePrefix = new TGTextButton(urlFrame,"Choose Prefix");
94  urlFrame->AddFrame(m_choosePrefix, new TGLayoutHints(kLHintsLeft,1,1,1,1));
95 
96  m_file= new TGTextEntry(urlFrame);
97  urlFrame->AddFrame(m_file, new TGLayoutHints(kLHintsExpandX,1,0,1,1));
98  m_file->Connect("TextChanged(const char*)", "CmsShowSearchFiles",this,"fileEntryChanged(const char*)");
99  m_file->Connect("ReturnPressed()", "CmsShowSearchFiles",this,"updateBrowser()");
100 
101  m_webFile = new FWHtml(vf,1,1);
102  m_webFile->Connect("MouseDown(const char*)","CmsShowSearchFiles",this,"hyperlinkClicked(const char*)");
103  vf->AddFrame(m_webFile, new TGLayoutHints(kLHintsExpandX|kLHintsExpandY,1,1,1,1));
104 
105  TGHorizontalFrame* buttonFrame = new TGHorizontalFrame(vf);
106  vf->AddFrame(buttonFrame, new TGLayoutHints(kLHintsExpandX,1,10,1,10));
107 
108  m_openButton = new TGTextButton(buttonFrame,"Open");
109  buttonFrame->AddFrame(m_openButton, new TGLayoutHints(kLHintsRight,5,5,1,1));
110  m_openButton->SetEnabled(kFALSE);
111  m_openButton->Connect("Clicked()","CmsShowSearchFiles",this,"openClicked()");
112 
113  TGTextButton* cancel = new TGTextButton(buttonFrame,"Cancel");
114  buttonFrame->AddFrame(cancel, new TGLayoutHints(kLHintsRight,5,5,1,1));
115  cancel->Connect("Clicked()","CmsShowSearchFiles",this,"UnmapWindow()");
116 
117  SetWindowName(windowname);
118  sendToWebBrowser("");
119  MapSubwindows();
120  Layout();
121  m_prefixMenu=0;
122  m_choosePrefix->Connect("Clicked()","CmsShowSearchFiles",this,"showPrefixes()");
123 }
TGTextButton * m_choosePrefix
TGPopupMenu * m_prefixMenu
TGTextButton * m_openButton
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void sendToWebBrowser(const char *iWebFile)
CmsShowSearchFiles::~CmsShowSearchFiles ( )
virtual

Definition at line 125 of file CmsShowSearchFiles.cc.

References m_prefixMenu.

126 {
127  delete m_prefixMenu;
128 }
TGPopupMenu * m_prefixMenu

Member Function Documentation

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

References m_file, and m_openCalled.

304 {
305  DontCallClose();
306  Connect("CloseWindow()","CmsShowSearchFiles",this,"UnmapWindow()");
307  m_openCalled = false;
308  MapWindow();
309  gClient->WaitForUnmap(this);
310 
311  if(!m_openCalled) {
312  return std::string();
313  }
314  return m_file->GetText();
315 }
CmsShowSearchFiles::ClassDef ( CmsShowSearchFiles  ,
 
)
void CmsShowSearchFiles::fileEntryChanged ( const char *  iFileName)

Definition at line 148 of file CmsShowSearchFiles.cc.

References convertXMLtoSQLite_cfg::fileName, getHLTprescales::index, m_openButton, and s_rootPostfix().

149 {
150  std::string fileName =iFileName;
151  size_t index = fileName.find_last_of(".");
152  std::string postfix;
153  if(index != std::string::npos) {
154  postfix=fileName.substr(index,std::string::npos);
155  }
156  if(postfix ==s_rootPostfix) {
157  m_openButton->SetEnabled(kTRUE);
158  } else {
159  m_openButton->SetEnabled(kFALSE);
160  }
161 }
TGTextButton * m_openButton
static const std::string s_rootPostfix(".root")
void CmsShowSearchFiles::hyperlinkClicked ( const char *  iLink)

Definition at line 171 of file CmsShowSearchFiles.cc.

References FWHtml::addToVisited(), convertXMLtoSQLite_cfg::fileName, getHLTprescales::index, m_file, m_webFile, openClicked(), s_rootPostfix(), and updateBrowser().

172 {
173  m_file->SetText(iLink,kTRUE);
174 
175  m_webFile->addToVisited(iLink);
176  std::string fileName =iLink;
177  size_t index = fileName.find_last_of(".");
178  std::string postfix = fileName.substr(index,std::string::npos);
179 
180  if(postfix !=s_rootPostfix) {
181  updateBrowser();
182  } else {
183  openClicked();
184  }
185 }
void addToVisited(const char *iToVisit)
static const std::string s_rootPostfix(".root")
void CmsShowSearchFiles::openClicked ( )

Definition at line 188 of file CmsShowSearchFiles.cc.

References m_openCalled.

Referenced by hyperlinkClicked().

189 {
190  m_openCalled=true;
191  this->UnmapWindow();
192 }
void CmsShowSearchFiles::prefixChoosen ( Int_t  iIndex)

Definition at line 131 of file CmsShowSearchFiles.cc.

References m_choosePrefix, m_file, m_openButton, m_prefixComplete, m_prefixes, m_webFile, sendToWebBrowser(), and updateBrowser().

132 {
133  m_file->SetText(m_prefixes[iIndex].c_str(),kFALSE);
134  m_openButton->SetEnabled(kFALSE);
135 
136  if(m_prefixComplete[iIndex]) {
137  //gClient->NeedRedraw(this);
138  gClient->NeedRedraw(m_choosePrefix);
139  gClient->NeedRedraw(m_webFile);
140  gClient->ProcessEventsFor(this);
141  updateBrowser();
142  } else {
143  sendToWebBrowser("");
144  }
145 }
std::vector< bool > m_prefixComplete
TGTextButton * m_choosePrefix
TGTextButton * m_openButton
std::vector< std::string > m_prefixes
void sendToWebBrowser(const char *iWebFile)
void CmsShowSearchFiles::sendToWebBrowser ( const char *  iWebFile)
private

Definition at line 260 of file CmsShowSearchFiles.cc.

References convertXMLtoSQLite_cfg::fileName, i, getHLTprescales::index, m_webFile, prof2calltree::prefix, readRemote(), s_httpPrefix(), s_noBrowserMessage, and s_readError.

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

261 {
262  const std::string fileName(iWebFile);
263  size_t index = fileName.find_first_of(":");
264  if(index != std::string::npos) {
265  ++index;
266  } else {
267  index = 0;
268  }
269  std::string prefix = fileName.substr(0,index);
270 
271  m_webFile->Clear();
272  if(prefix == s_httpPrefix) {
273  gVirtualX->SetCursor(GetId(),gVirtualX->CreateCursor(kWatch));
274  //If you clicked a hyperlink then the cursor is still a hand but we now
275  // want it to be a watch
276  gVirtualX->SetCursor(m_webFile->GetId(),gVirtualX->CreateCursor(kWatch));
277  //If we don't call ProcessEventsFor then the cursor will not be updated
278  gClient->ProcessEventsFor(this);
279  TUrl url(iWebFile);
280  std::string buffer = readRemote(url.GetUrl());
281  if (buffer.size()) {
282  m_webFile->SetBaseUri(url.GetUrl());
283  m_webFile->ParseText(const_cast<char*>(buffer.c_str()));
284  }
285  else {
286  m_webFile->SetBaseUri("");
287  for (int i=0; s_readError[i]; i++) {
288  m_webFile->ParseText(const_cast<char *>(s_readError[i]));
289  }
290  }
291  gVirtualX->SetCursor(GetId(),gVirtualX->CreateCursor(kPointer));
292  gVirtualX->SetCursor(m_webFile->GetId(),gVirtualX->CreateCursor(kPointer));
293  } else {
294  m_webFile->SetBaseUri("");
295  for (int i=0; s_noBrowserMessage[i]; i++) {
296  m_webFile->ParseText((char *)s_noBrowserMessage[i]);
297  }
298  }
299  m_webFile->Layout();
300 }
int i
Definition: DBlmapReader.cc:9
static const char * s_readError[]
static const std::string s_httpPrefix("http:")
static const char * s_noBrowserMessage[]
static std::string readRemote(const char *url)
void CmsShowSearchFiles::showPrefixes ( )

Definition at line 196 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.

197 {
198  if(0==m_prefixMenu) {
199  m_prefixMenu = new TGPopupMenu(this);
200  const char* const (*itEnd)[s_columns] = s_prefixes+sizeof(s_prefixes)/sizeof(const char*[3]);
201  int index = 0;
202  for(const char* const (*it)[s_columns] = s_prefixes;
203  it != itEnd;
204  ++it,++index) {
205  //only add the protocols this version of the code actually can load
206  std::string prefix = std::string((*it)[0]).substr(0,std::string((*it)[0]).find_first_of(":")+1);
207  if(s_httpPrefix==prefix ||
208  s_filePrefix==prefix ||
209  (gPluginMgr->FindHandler("TSystem",prefix.c_str()) &&
210  gPluginMgr->FindHandler("TSystem",prefix.c_str())->CheckPlugin() != -1)) {
211  m_prefixMenu->AddEntry((std::string((*it)[0])+" ("+((*it)[1])+")").c_str(),index);
212  m_prefixes.push_back((*it)[0]);
213  m_prefixComplete.push_back(0!=(*it)[2]);
214  }
215  }
216  m_prefixMenu->Connect("Activated(Int_t)","CmsShowSearchFiles",this,"prefixChoosen(Int_t)");
217  }
218  m_prefixMenu->PlaceMenu(m_choosePrefix->GetX(),m_choosePrefix->GetY(),true,true);
219 }
std::vector< bool > m_prefixComplete
static const char *const s_prefixes[][s_columns]
TGTextButton * m_choosePrefix
static const std::string s_filePrefix("file:")
TGPopupMenu * m_prefixMenu
static const std::string s_httpPrefix("http:")
std::vector< std::string > m_prefixes
static const unsigned int s_columns
void CmsShowSearchFiles::updateBrowser ( )

Definition at line 164 of file CmsShowSearchFiles.cc.

References m_file, and sendToWebBrowser().

Referenced by hyperlinkClicked(), and prefixChoosen().

165 {
166  sendToWebBrowser(m_file->GetText());
167 }
void sendToWebBrowser(const char *iWebFile)

Member Data Documentation

TGTextButton* CmsShowSearchFiles::m_choosePrefix
private

Definition at line 61 of file CmsShowSearchFiles.h.

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

TGTextEntry* CmsShowSearchFiles::m_file
private
TGTextButton* CmsShowSearchFiles::m_openButton
private

Definition at line 67 of file CmsShowSearchFiles.h.

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

bool CmsShowSearchFiles::m_openCalled
private

Definition at line 68 of file CmsShowSearchFiles.h.

Referenced by chooseFileFromURL(), and openClicked().

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

Definition at line 66 of file CmsShowSearchFiles.h.

Referenced by prefixChoosen(), and showPrefixes().

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

Definition at line 65 of file CmsShowSearchFiles.h.

Referenced by prefixChoosen(), and showPrefixes().

TGPopupMenu* CmsShowSearchFiles::m_prefixMenu
private

Definition at line 62 of file CmsShowSearchFiles.h.

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

FWHtml* CmsShowSearchFiles::m_webFile
private