Logo ROOT  
Reference Guide
TSessionViewer.cxx
Go to the documentation of this file.
1 // @(#)root/sessionviewer:$Id$
2 // Author: Marek Biskup, Jakub Madejczyk, Bertrand Bellenot 10/08/2005
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 //////////////////////////////////////////////////////////////////////////
13 // //
14 // TSessionViewer //
15 // //
16 // Widget used to manage PROOF or local sessions, PROOF connections, //
17 // queries construction and results handling. //
18 // //
19 //////////////////////////////////////////////////////////////////////////
20 
21 #include "TApplication.h"
22 #include "TROOT.h"
23 #include "THashList.h"
24 #include "TClass.h"
25 #include "TSystem.h"
26 #include "TGFileDialog.h"
27 #include "TBrowser.h"
28 #include "TGButton.h"
29 #include "TGLayout.h"
30 #include "TGListTree.h"
31 #include "TGCanvas.h"
32 #include "TGLabel.h"
33 #include "TGTextEntry.h"
34 #include "TGNumberEntry.h"
35 #include "TGTableLayout.h"
36 #include "TGListBox.h"
37 #include "TGSplitter.h"
38 #include "TGProgressBar.h"
39 #include "TGListView.h"
40 #include "TGMsgBox.h"
41 #include "TGMenu.h"
42 #include "TGStatusBar.h"
43 #include "TGIcon.h"
44 #include "TChain.h"
45 #include "TDSet.h"
46 #include "TFileInfo.h"
47 #include "TObjString.h"
48 #include "TProof.h"
49 #include "TRandom.h"
50 #include "TSessionViewer.h"
51 #include "TSessionLogView.h"
52 #include "TQueryResult.h"
53 #include "TGTextView.h"
54 #include "TGToolBar.h"
55 #include "TGTab.h"
56 #include "TRootEmbeddedCanvas.h"
57 #include "TCanvas.h"
58 #include "TGMimeTypes.h"
59 #include "TInterpreter.h"
60 #include "TContextMenu.h"
61 #include "TG3DLine.h"
62 #include "TSessionDialogs.h"
63 #include "TEnv.h"
64 #include "TH2.h"
65 #include "TVirtualTreePlayer.h"
66 #include "TSelector.h"
67 #include "TFileCollection.h"
68 #include "TVirtualX.h"
69 #include "snprintf.h"
70 #ifdef WIN32
71 #include "TWin32SplashThread.h"
72 #endif
73 
74 #include <cstdlib>
75 
77 
78 const char *kConfigFile = ".proofgui.conf";
79 
88 
89 const char *xpm_names[] = {
90  "monitor01.xpm",
91  "monitor02.xpm",
92  "monitor03.xpm",
93  "monitor04.xpm",
94  0
95 };
96 
97 const char *conftypes[] = {
98  "Config files", "*.conf",
99  "All files", "*.*",
100  0, 0
101 };
102 
103 const char *pkgtypes[] = {
104  "Package files", "*.par",
105  "All files", "*.*",
106  0, 0
107 };
108 
109 const char *macrotypes[] = {
110  "C files", "*.[C|c]*",
111  "All files", "*",
112  0, 0
113 };
114 
115 
116 const char *kFeedbackHistos[] = {
117  "PROOF_PacketsHist",
118  "PROOF_EventsHist",
119  "PROOF_NodeHist",
120  "PROOF_LatencyHist",
121  "PROOF_ProcTimeHist",
122  "PROOF_CpuTimeHist",
123  0
124 };
125 
126 const char* const kSession_RedirectFile = ".templog";
127 const char* const kSession_RedirectCmd = ".tempcmd";
128 
129 // Menu command id's
135 
140 
148 
154 
160 
162 };
163 
164 const char *xpm_toolbar[] = {
165  "fileopen.xpm",
166  "filesaveas.xpm",
167  "",
168  "connect.xpm",
169  "disconnect.xpm",
170  "",
171  "query_new.xpm",
172  "query_submit.xpm",
173  "",
174  "about.xpm",
175  "",
176  "quit.xpm",
177  0
178 };
179 
181  { "", "Open Config File", kFALSE, kFileLoadConfig, 0 },
182  { "", "Save Config File", kFALSE, kFileSaveConfig, 0 },
183  { "", 0, 0, -1, 0 },
184  { "", "Connect", kFALSE, kSessionConnect, 0 },
185  { "", "Disconnect", kFALSE, kSessionDisconnect, 0 },
186  { "", 0, 0, -1, 0 },
187  { "", "New Query", kFALSE, kQueryNew, 0 },
188  { "", "Submit Query", kFALSE, kQuerySubmit, 0 },
189  { "", 0, 0, -1, 0 },
190  { "", "About Root", kFALSE, kHelpAbout, 0 },
191  { "", 0, 0, -1, 0 },
192  { "", "Exit Root", kFALSE, kFileQuit, 0 },
193  { 0, 0, 0, 0, 0 }
194 };
195 
196 
197 ////////////////////////////////////////////////////////////////////////////////
198 // Server Frame
199 
200 ////////////////////////////////////////////////////////////////////////////////
201 /// Constructor.
202 
204  TGCompositeFrame(p, w, h), fFrmNewServer(0), fTxtName(0), fTxtAddress(0),
205  fNumPort(0), fLogLevel(0), fTxtConfig(0), fTxtUsrName(0), fSync(0),
206  fViewer(0), fBtnAdd(0), fBtnConnect(0)
207 {
208 }
209 
210 ////////////////////////////////////////////////////////////////////////////////
211 /// Destructor.
212 
214 {
215  Cleanup();
216 }
217 
218 ////////////////////////////////////////////////////////////////////////////////
219 /// Build server configuration frame.
220 
222 {
224 
226 
227  fViewer = gui;
228  fFrmNewServer = new TGGroupFrame(this, "New Session");
230 
232 
234 
235  fFrmNewServer->AddFrame(new TGLabel(fFrmNewServer, "Session Name:"),
236  new TGLayoutHints(kLHintsLeft, 3, 3, 3, 3));
238  (const char *)0, 1), new TGLayoutHints());
240  fTxtName->Associate(this);
241  fFrmNewServer->AddFrame(new TGLabel(fFrmNewServer, "Server name:"),
242  new TGLayoutHints(kLHintsLeft, 3, 3, 3, 3));
244  (const char *)0, 2), new TGLayoutHints());
246  fTxtAddress->Associate(this);
247  fFrmNewServer->AddFrame(new TGLabel(fFrmNewServer, "Port (default: 1093):"),
248  new TGLayoutHints(kLHintsLeft, 3, 3, 3, 3));
252  fNumPort->Associate(this);
253  fFrmNewServer->AddFrame(new TGLabel(fFrmNewServer, "Configuration File:"),
254  new TGLayoutHints(kLHintsLeft, 3, 3, 3, 3));
256  (const char *)0, 4), new TGLayoutHints());
258  fTxtConfig->Associate(this);
259  fFrmNewServer->AddFrame(new TGLabel(fFrmNewServer, "Log Level:"),
260  new TGLayoutHints(kLHintsLeft, 3, 3, 3, 3));
261 
266  new TGLayoutHints(kLHintsLeft, 3, 3, 3, 3));
267  fLogLevel->Associate(this);
268 
269  fFrmNewServer->AddFrame(new TGLabel(fFrmNewServer, "User Name:"),
270  new TGLayoutHints(kLHintsLeft, 3, 3, 3, 3));
272  (const char *)0, 6), new TGLayoutHints());
274  fTxtUsrName->Associate(this);
275 
276  fFrmNewServer->AddFrame(new TGLabel(fFrmNewServer, "Process mode :"),
278  3, 3, 3, 3));
280  "&Synchronous"), new TGLayoutHints(kLHintsLeft | kLHintsBottom |
281  kLHintsExpandX, 3, 3, 3, 3));
282  fSync->SetToolTipText("Default Process Mode");
284 
285  AddFrame(fBtnAdd = new TGTextButton(this, " Save "),
286  new TGLayoutHints(kLHintsTop | kLHintsCenterX, 5, 5, 15, 5));
287  fBtnAdd->SetToolTipText("Add server to the list");
288  fBtnAdd->Connect("Clicked()", "TSessionServerFrame", this,
289  "OnBtnAddClicked()");
290  AddFrame(fBtnConnect = new TGTextButton(this, " Connect "),
291  new TGLayoutHints(kLHintsTop | kLHintsCenterX, 5, 5, 15, 5));
292  fBtnConnect->Connect("Clicked()", "TSessionServerFrame", this,
293  "OnBtnConnectClicked()");
294  fBtnConnect->SetToolTipText("Connect to the selected server");
295 
296  fTxtConfig->Connect("DoubleClicked()", "TSessionServerFrame", this,
297  "OnConfigFileClicked()");
298 
299  fTxtName->Connect("TextChanged(char*)", "TSessionServerFrame", this,
300  "SettingsChanged()");
301  fTxtAddress->Connect("TextChanged(char*)", "TSessionServerFrame", this,
302  "SettingsChanged()");
303  fTxtConfig->Connect("TextChanged(char*)", "TSessionServerFrame", this,
304  "SettingsChanged()");
305  fTxtUsrName->Connect("TextChanged(char*)", "TSessionServerFrame", this,
306  "SettingsChanged()");
307  fSync->Connect("Clicked()", "TSessionServerFrame", this,
308  "SettingsChanged()");
309  fLogLevel->Connect("ValueChanged(Long_t)", "TSessionServerFrame", this,
310  "SettingsChanged()");
311  fLogLevel->Connect("ValueSet(Long_t)", "TSessionServerFrame", this,
312  "SettingsChanged()");
313  fNumPort->Connect("ValueChanged(Long_t)", "TSessionServerFrame", this,
314  "SettingsChanged()");
315  fNumPort->Connect("ValueSet(Long_t)", "TSessionServerFrame", this,
316  "SettingsChanged()");
317 
318 }
319 
320 ////////////////////////////////////////////////////////////////////////////////
321 /// Settings have changed, update GUI accordingly.
322 
324 {
325  TGTextEntry *sender = dynamic_cast<TGTextEntry*>((TQObject*)gTQSender);
326  Bool_t issync = (fSync->GetState() == kButtonDown);
327  if ((fViewer->GetActDesc()->fLocal) ||
328  (strcmp(fViewer->GetActDesc()->GetName(), fTxtName->GetText())) ||
329  (strcmp(fViewer->GetActDesc()->fAddress.Data(), fTxtAddress->GetText())) ||
330  (strcmp(fViewer->GetActDesc()->fConfigFile.Data(), fTxtConfig->GetText())) ||
331  (strcmp(fViewer->GetActDesc()->fUserName.Data(), fTxtUsrName->GetText())) ||
334  (fViewer->GetActDesc()->fSync != issync)) {
337  }
338  else {
341  }
342  if (sender) {
343  sender->SetFocus();
344  }
345 }
346 
347 
348 ////////////////////////////////////////////////////////////////////////////////
349 /// Handle expose event in server frame.
350 
352 {
353  //fTxtName->SelectAll();
354  //fTxtName->SetFocus();
355  return kTRUE;
356 }
357 
358 ////////////////////////////////////////////////////////////////////////////////
359 /// Browse configuration files.
360 
362 {
363  // do nothing if connection in progress
364  if (fViewer->IsBusy())
365  return;
366  TGFileInfo fi;
367  fi.fFileTypes = conftypes;
368  new TGFileDialog(fClient->GetRoot(), fViewer, kFDOpen, &fi);
369  if (!fi.fFilename) return;
371 }
372 
373 ////////////////////////////////////////////////////////////////////////////////
374 /// Delete selected session configuration (remove it from the list).
375 
377 {
378  // do nothing if connection in progress
379  if (fViewer->IsBusy())
380  return;
382  TIter next(fViewer->GetSessions());
384 
385  if (desc->fLocal) {
386  Int_t retval;
387  new TGMsgBox(fClient->GetRoot(), this, "Error Deleting Session",
388  "Deleting Local Sessions is not allowed !",
389  kMBIconExclamation,kMBOk,&retval);
390  return;
391  }
392  // ask for confirmation
393  TString m;
394  m.Form("Are you sure to delete the server \"%s\"",
395  desc->fName.Data());
396  Int_t result;
397  new TGMsgBox(fClient->GetRoot(), this, "", m.Data(), 0,
398  kMBOk | kMBCancel, &result);
399  // if confirmed, delete it
400  if (result == kMBOk) {
401  // remove the Proof session from gROOT list of Proofs
402  if (desc->fConnected && desc->fAttached && desc->fProof) {
403  desc->fProof->Detach("S");
404  }
405  // remove it from our sessions list
406  fViewer->GetSessions()->Remove((TObject *)desc);
407  // update configuration file
410 
411  TObject *obj = fViewer->GetSessions()->Last();
413  fViewer->GetSessionItem(), (void *)obj);
414  if (item) {
421  fViewer->OnListTreeClicked(item, 1, 0, 0);
422  }
423  }
424  if (fViewer->IsAutoSave())
426 }
427 
428 ////////////////////////////////////////////////////////////////////////////////
429 /// Connect to selected server.
430 
432 {
433  // do nothing if connection in progress
434  if (fViewer->IsBusy())
435  return;
436 
438  OnBtnAddClicked();
439  }
440  else {
443  if (strlen(fTxtConfig->GetText()) > 1)
445  else
446  fViewer->GetActDesc()->fConfigFile = "";
450  if (fViewer->IsAutoSave())
452  }
453  // set flag busy
454  fViewer->SetBusy();
455  // avoid input events in list tree while connecting
460  // set watch cursor to indicate connection in progress
461  gVirtualX->SetCursor(fViewer->GetSessionHierarchy()->GetId(),
462  gVirtualX->CreateCursor(kWatch));
463  gVirtualX->SetCursor(GetId(),gVirtualX->CreateCursor(kWatch));
464  // display connection progress bar in first part of status bar
466  // connect to proof startup message (to update progress bar)
467  TQObject::Connect("TProof", "StartupMessage(char *,Bool_t,Int_t,Int_t)",
468  "TSessionViewer", fViewer, "StartupMessage(char *,Bool_t,Int_t,Int_t)");
469  // collect and set-up configuration
470  TString address = fTxtAddress->GetText();
471  TString url;
472  if (address == "lite://") {
473  url = address;
474  }
475  else {
476  // collect and set-up configuration
477  url = fTxtUsrName->GetText();
478  url += "@"; url += address.Data();
479  if (fNumPort->GetIntNumber() > 0) {
480  url += ":";
481  url += fNumPort->GetIntNumber();
482  }
483  }
484 
485  TProofDesc *desc;
487  if (!fViewer->GetActDesc()->fProofMgr ||
489  // hide connection progress bar from status bar
491  // release busy flag
493  // restore cursors and input
494  gVirtualX->SetCursor(GetId(), 0);
499  gVirtualX->SetCursor(fViewer->GetSessionHierarchy()->GetId(), 0);
500  return;
501  }
503  // check if the session already exist before to recreate it
504  TList *sessions = fViewer->GetActDesc()->fProofMgr->QuerySessions("");
505  if (sessions) {
506  TIter nextp(sessions);
507  // loop over existing Proof sessions
508  while ((desc = (TProofDesc *)nextp())) {
509  if ((desc->GetName() == fViewer->GetActDesc()->fTag) ||
510  (desc->GetTitle() == fViewer->GetActDesc()->fName)) {
513  fViewer->GetActDesc()->fTag = desc->GetName();
517 
519  Int_t i = 0;
520  // browse list of feedback histos and check user's selected ones
521  while (kFeedbackHistos[i]) {
522  if (fViewer->GetCascadeMenu()->IsEntryChecked(41+i)) {
525  }
526  i++;
527  }
528  // connect feedback signal
529  fViewer->GetActDesc()->fProof->Connect("Feedback(TList *objs)",
530  "TSessionQueryFrame", fViewer->GetQueryFrame(),
531  "Feedback(TList *objs)");
532  gROOT->Time();
533  }
534  else {
535  // if feedback option not selected, clear Proof's feedback option
537  }
538 
539  break;
540  }
541  }
542  }
543  if (fViewer->GetActDesc()->fProof == 0) {
544  if (fViewer->GetActDesc()->fProofMgr->IsValid()) {
547  desc = 0;
548  sessions = fViewer->GetActDesc()->fProofMgr->QuerySessions("");
549  if (sessions)
550  desc = (TProofDesc *)sessions->Last();
551  if (desc) {
553  fViewer->GetActDesc()->fTag = desc->GetName();
556  }
557  }
558  }
559  if (fViewer->GetActDesc()->fProof) {
564  if (fViewer->GetActDesc()->fLogLevel < 0)
565  fViewer->GetActDesc()->fLogLevel = 0;
566  if (fViewer->GetActDesc()->fProof->IsLite())
567  fViewer->GetActDesc()->fAddress = "lite://";
568  else
572  }
574 
575  // check if connected and valid
576  if (fViewer->GetActDesc()->fProof &&
577  fViewer->GetActDesc()->fProof->IsValid()) {
578  // set log level
580  // set query type (synch / asynch)
583  // set connected flag
585  // change list tree item picture to connected pixmap
588  if (item) {
590  // update viewer
591  fViewer->OnListTreeClicked(item, 1, 0, 0);
594  }
595  // connect to progress related signals
596  fViewer->GetActDesc()->fProof->Connect("Progress(Long64_t,Long64_t)",
597  "TSessionQueryFrame", fViewer->GetQueryFrame(),
598  "Progress(Long64_t,Long64_t)");
599  fViewer->GetActDesc()->fProof->Connect("Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)",
600  "TSessionQueryFrame", fViewer->GetQueryFrame(),
601  "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)");
602  fViewer->GetActDesc()->fProof->Connect("Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t,Int_t,Int_t,Float_t)",
603  "TSessionQueryFrame", fViewer->GetQueryFrame(),
604  "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t,Int_t,Int_t,Float_t)");
605  fViewer->GetActDesc()->fProof->Connect("StopProcess(Bool_t)",
606  "TSessionQueryFrame", fViewer->GetQueryFrame(),
607  "IndicateStop(Bool_t)");
609  "ResetProgressDialog(const char*,Int_t,Long64_t,Long64_t)",
610  "TSessionQueryFrame", fViewer->GetQueryFrame(),
611  "ResetProgressDialog(const char*,Int_t,Long64_t,Long64_t)");
612  // enable timer used for status bar icon's animation
613  fViewer->EnableTimer();
614  // change status bar right icon to connected pixmap
615  fViewer->ChangeRightLogo("monitor01.xpm");
616  // do not animate yet
618  // connect to signal "query result ready"
619  fViewer->GetActDesc()->fProof->Connect("QueryResultReady(char *)",
620  "TSessionViewer", fViewer, "QueryResultReady(char *)");
621  // display connection information on status bar
622  TString msg;
623  msg.Form("PROOF Cluster %s ready", fViewer->GetActDesc()->fName.Data());
624  fViewer->GetStatusBar()->SetText(msg.Data(), 1);
628  // Enable previously uploaded packages if in auto-enable mode
629  if (fViewer->GetActDesc()->fAutoEnable) {
630  TPackageDescription *package;
631  TIter next(fViewer->GetActDesc()->fPackages);
632  while ((package = (TPackageDescription *)next())) {
633  if (!package->fEnabled) {
634  if (fViewer->GetActDesc()->fProof->EnablePackage(package->fName) != 0)
635  Error("Submit", "Enable package failed");
636  else {
637  package->fEnabled = kTRUE;
639  }
640  }
641  }
642  }
643  }
644  // hide connection progress bar from status bar
646  // release busy flag
648  // restore cursors and input
649  gVirtualX->SetCursor(GetId(), 0);
654  gVirtualX->SetCursor(fViewer->GetSessionHierarchy()->GetId(), 0);
655 }
656 
657 ////////////////////////////////////////////////////////////////////////////////
658 /// Reset server configuration fields.
659 
661 {
662  // do nothing if connection in progress
663  if (fViewer->IsBusy())
664  return;
672  fTxtName->SetText("");
673  fTxtAddress->SetText("");
674  fTxtConfig->SetText("");
675  fNumPort->SetIntNumber(1093);
677  fTxtUsrName->SetText("");
678 }
679 
680 ////////////////////////////////////////////////////////////////////////////////
681 /// Add newly created session configuration in the list of sessions.
682 
684 {
685  Int_t retval;
686  Bool_t newSession = kTRUE;
687  TSessionDescription* desc = 0;
688  // do nothing if connection in progress
689  if (fViewer->IsBusy())
690  return;
691 
692  if ((!fTxtName->GetBuffer()->GetTextLength()) ||
695  new TGMsgBox(fClient->GetRoot(), fViewer, "Error Adding Session",
696  "At least one required field is empty !",
697  kMBIconExclamation, kMBOk, &retval);
698  return;
699  }
701  if (obj)
702  desc = dynamic_cast<TSessionDescription*>(obj);
703  if (desc) {
704  new TGMsgBox(fClient->GetRoot(), fViewer, "Adding Session",
705  TString::Format("The session \"%s\" already exists ! Overwrite ?",
707  kMBCancel, &retval);
708  if (retval != kMBYes)
709  return;
710  newSession = kFALSE;
711  }
712  if (newSession) {
713  desc = new TSessionDescription();
714  desc->fName = fTxtName->GetText();
715  desc->fTag = "";
716  desc->fQueries = new TList();
717  desc->fPackages = new TList();
718  desc->fActQuery = 0;
719  desc->fProof = 0;
720  desc->fProofMgr = 0;
721  desc->fAutoEnable = kFALSE;
722  desc->fAddress = fTxtAddress->GetText();
723  desc->fPort = fNumPort->GetIntNumber();
724  desc->fConnected = kFALSE;
725  desc->fAttached = kFALSE;
726  desc->fLocal = kFALSE;
727  if (strlen(fTxtConfig->GetText()) > 1)
729  else
730  desc->fConfigFile = "";
731  desc->fLogLevel = fLogLevel->GetIntNumber();
732  desc->fUserName = fTxtUsrName->GetText();
733  desc->fSync = (fSync->GetState() == kButtonDown);
734  // add newly created session config to our session list
735  fViewer->GetSessions()->Add((TObject *)desc);
736  // save into configuration file
738  fViewer->GetSessionItem(), desc->fName.Data(),
740  fViewer->GetSessionHierarchy()->SetToolTipItem(item, "Proof Session");
741  item->SetUserData(desc);
749  fViewer->OnListTreeClicked(item, 1, 0, 0);
750  }
751  else {
755  if (strlen(fTxtConfig->GetText()) > 1)
761  item2->SetUserData(fViewer->GetActDesc());
763  1, 0, 0);
764  }
767  if (fViewer->IsAutoSave())
769 }
770 
771 ////////////////////////////////////////////////////////////////////////////////
772 /// Update fields with values from session description desc.
773 
775 {
776  if (desc->fLocal) {
777  fTxtName->SetText("");
778  fTxtAddress->SetText("");
779  fNumPort->SetIntNumber(1093);
780  fTxtConfig->SetText("");
781  fTxtUsrName->SetText("");
783  return;
784  }
785 
786  fTxtName->SetText(desc->fName);
787  fTxtAddress->SetText(desc->fAddress);
788  fNumPort->SetIntNumber(desc->fPort);
790 
791  if (desc->fConfigFile.Length() > 1) {
793  }
794  else {
795  fTxtConfig->SetText("");
796  }
797  fTxtUsrName->SetText(desc->fUserName);
798 }
799 
800 ////////////////////////////////////////////////////////////////////////////////
801 /// Process messages for session server frame.
802 /// Used to navigate between text entry fields.
803 
805 {
806  switch (GET_MSG(msg)) {
807  case kC_TEXTENTRY:
808  switch (GET_SUBMSG(msg)) {
809  case kTE_ENTER:
810  case kTE_TAB:
811  switch (parm1) {
812  case 1: // session name
815  break;
816  case 2: // server address
819  break;
820  case 3: // port number
822  fTxtConfig->SetFocus();
823  break;
824  case 4: // configuration file
827  break;
828  case 5: // log level
831  break;
832  case 6: // user name
833  fTxtName->SelectAll();
834  fTxtName->SetFocus();
835  break;
836  }
837  break;
838 
839  default:
840  break;
841  }
842  break;
843 
844  default:
845  break;
846  }
847  return kTRUE;
848 }
849 
850 ////////////////////////////////////////////////////////////////////////////////
851 // Session Frame
852 
853 ////////////////////////////////////////////////////////////////////////////////
854 /// Constructor.
855 
857  TGCompositeFrame(p, w, h), fTab(0), fFA(0), fFB(0), fFC(0), fFD(0), fFE(0),
858  fCommandTxt(0), fCommandBuf(0), fInfoTextView(0), fClearCheck(0),
859  fBtnShowLog(0), fBtnNewQuery(0), fBtnGetQueries(0), fLBPackages(0),
860  fBtnAdd(0), fBtnRemove(0), fBtnUp(0), fBtnDown(0), fBtnShow(0),
861  fBtnShowEnabled(0), fChkMulti(0), fChkEnable(0), fBtnUpload(0),
862  fBtnEnable(0), fBtnClear(0), fBtnDisable(0), fDSetView(0), fDataSetTree(0),
863  fBtnUploadDSet(0), fBtnRemoveDSet(0), fBtnVerifyDSet(0), fBtnRefresh(0),
864  fTxtParallel(0), fLogLevel(0), fApplyLogLevel(0), fApplyParallel(0),
865  fViewer(0)
866 {
867  for (int i=0;i<19;++i) fInfoLine[i] = 0;
868 }
869 
870 ////////////////////////////////////////////////////////////////////////////////
871 /// Destructor.
872 
874 {
875  Cleanup();
876 }
877 
878 ////////////////////////////////////////////////////////////////////////////////
879 /// Build session frame.
880 
882 {
885  fViewer = gui;
886  Int_t i,j;
887 
888  // main session tab
889  fTab = new TGTab(this, 200, 200);
891  kLHintsExpandY, 2, 2, 2, 2));
892 
893  // add "Status" tab element
894  TGCompositeFrame *tf = fTab->AddTab("Status");
895  fFA = new TGCompositeFrame(tf, 100, 100, kVerticalFrame);
898 
899  // add first session information line
900  fInfoLine[0] = new TGLabel(fFA, " ");
902  kLHintsExpandX, 5, 5, 15, 5));
903 
904  TGCompositeFrame* frmInfos = new TGHorizontalFrame(fFA, 350, 100);
905  frmInfos->SetLayoutManager(new TGTableLayout(frmInfos, 9, 2));
906 
907  // add session information lines
908  j = 0;
909  for (i=0;i<17;i+=2) {
910  fInfoLine[i+1] = new TGLabel(frmInfos, " ");
911  frmInfos->AddFrame(fInfoLine[i+1], new TGTableLayoutHints(0, 1, j, j+1,
912  kLHintsLeft | kLHintsCenterY, 5, 5, 2, 2));
913  fInfoLine[i+2] = new TGLabel(frmInfos, " ");
914  frmInfos->AddFrame(fInfoLine[i+2], new TGTableLayoutHints(1, 2, j, j+1,
915  kLHintsLeft | kLHintsCenterY, 5, 5, 2, 2));
916  j++;
917  }
918  fFA->AddFrame(frmInfos, new TGLayoutHints(kLHintsLeft | kLHintsTop |
919  kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5));
920 
921  // add "new query" and "get queries" buttons
922  TGCompositeFrame* frmBut1 = new TGHorizontalFrame(fFA, 350, 100);
923  frmBut1->SetCleanup(kDeepCleanup);
924  frmBut1->AddFrame(fBtnNewQuery = new TGTextButton(frmBut1, "New Query..."),
925  new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 5, 5, 5, 5));
926  fBtnNewQuery->SetToolTipText("Open New Query Dialog");
927  frmBut1->AddFrame(fBtnGetQueries = new TGTextButton(frmBut1, " Get Queries "),
928  new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 5, 5, 5, 5));
929  fBtnGetQueries->SetToolTipText("Get List of Queries from the server");
930  fBtnShowLog = new TGTextButton(frmBut1, "Show log...");
931  fBtnShowLog->SetToolTipText("Show Session log (opens log window)");
933  kLHintsExpandX, 5, 5, 5, 5));
935  kLHintsExpandX));
936 
937  // add "Commands" tab element
938  tf = fTab->AddTab("Commands");
939  fFC = new TGCompositeFrame(tf, 100, 100, kVerticalFrame);
942 
943  // add command line label and text entry
944  TGCompositeFrame* frmCmd = new TGHorizontalFrame(fFC, 350, 100);
945  frmCmd->SetCleanup(kDeepCleanup);
946  frmCmd->AddFrame(new TGLabel(frmCmd, "Command Line :"),
947  new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5, 5, 15, 5));
948  fCommandBuf = new TGTextBuffer(120);
949  frmCmd->AddFrame(fCommandTxt = new TGTextEntry(frmCmd,
951  kLHintsExpandX, 5, 5, 15, 5));
952  fFC->AddFrame(frmCmd, new TGLayoutHints(kLHintsExpandX, 5, 5, 10, 5));
953  // connect command line text entry to "return pressed" signal
954  fCommandTxt->Connect("ReturnPressed()", "TSessionFrame", this,
955  "OnCommandLine()");
956 
957  // check box for option "clear view"
958  fClearCheck = new TGCheckButton(fFC, "Clear view after each command");
960  10, 5, 5, 5));
962  // add text view for redirected output
963  fFC->AddFrame(new TGLabel(fFC, "Output :"),
964  new TGLayoutHints(kLHintsLeft | kLHintsTop, 10, 5, 5, 5));
965  fInfoTextView = new TGTextView(fFC, 330, 150, "", kSunkenFrame |
966  kDoubleBorder);
968  kLHintsTop | kLHintsExpandX | kLHintsExpandY, 10, 10, 5, 5));
969 
970  // add "Packages" tab element
971  tf = fTab->AddTab("Packages");
972  fFB = new TGCompositeFrame(tf, 100, 100, kVerticalFrame);
975 
976  // new frame containing packages listbox and control buttons
977  TGCompositeFrame* frmcanvas = new TGHorizontalFrame(fFB, 350, 100);
978 
979  // packages listbox
980  fLBPackages = new TGListBox(frmcanvas);
981  fLBPackages->Resize(80,150);
984  kLHintsExpandY, 5, 5, 5, 5));
985  // control buttons frame
986  TGCompositeFrame* frmBut2 = new TGVerticalFrame(frmcanvas, 150, 100);
987 
988  fChkMulti = new TGCheckButton(frmBut2, "Multiple Selection");
989  fChkMulti->SetToolTipText("Enable multiple selection in the package list");
990  frmBut2->AddFrame(fChkMulti, new TGLayoutHints(kLHintsLeft, 5, 5, 5, 5));
991 
992  fBtnAdd = new TGTextButton(frmBut2, " Add... ");
993  fBtnAdd->SetToolTipText("Add a package to the list");
995  kLHintsExpandX, 5, 5, 5, 5));
996  fBtnRemove = new TGTextButton(frmBut2, "Remove");
997  fBtnRemove->SetToolTipText("Remove package from the list");
999  kLHintsExpandX, 5, 5, 5, 5));
1000  fBtnUp = new TGTextButton(frmBut2, "Move Up");
1001  fBtnUp->SetToolTipText("Move package one step upward in the list");
1003  kLHintsExpandX, 5, 5, 5, 5));
1004  fBtnDown = new TGTextButton(frmBut2, "Move Down");
1005  fBtnDown->SetToolTipText("Move package one step downward in the list");
1007  kLHintsExpandX, 5, 5, 5, 5));
1008  frmcanvas->AddFrame(frmBut2, new TGLayoutHints(kLHintsLeft | kLHintsCenterY |
1009  kLHintsExpandY));
1010  fFB->AddFrame(frmcanvas, new TGLayoutHints(kLHintsLeft | kLHintsTop |
1012 
1013  TGCompositeFrame* frmLeg = new TGHorizontalFrame(fFB, 300, 100);
1014  frmLeg->SetCleanup(kDeepCleanup);
1015  TGPicture *pic1 = (TGPicture *)fClient->GetPicture("package.xpm");
1016  TGIcon *icn1 = new TGIcon(frmLeg, pic1, pic1->GetWidth(), pic1->GetHeight());
1017  frmLeg->AddFrame(icn1, new TGLayoutHints(kLHintsLeft | kLHintsTop,
1018  5, 5, 0, 5));
1019  frmLeg->AddFrame(new TGLabel(frmLeg, ": Local"),
1020  new TGLayoutHints(kLHintsLeft | kLHintsTop, 0, 10, 0, 5));
1021 
1022  TGPicture *pic2 = (TGPicture *)fClient->GetPicture("package_delete.xpm");
1023  TGIcon *icn2 = new TGIcon(frmLeg, pic2, pic2->GetWidth(), pic2->GetHeight());
1024  frmLeg->AddFrame(icn2, new TGLayoutHints(kLHintsLeft | kLHintsTop,
1025  5, 5, 0, 5));
1026  frmLeg->AddFrame(new TGLabel(frmLeg, ": Uploaded"),
1027  new TGLayoutHints(kLHintsLeft | kLHintsTop, 0, 10, 0, 5));
1028 
1029  TGPicture *pic3 = (TGPicture *)fClient->GetPicture("package_add.xpm");
1030  TGIcon *icn3 = new TGIcon(frmLeg, pic3, pic3->GetWidth(), pic3->GetHeight());
1031  frmLeg->AddFrame(icn3, new TGLayoutHints(kLHintsLeft | kLHintsTop,
1032  5, 5, 0, 5));
1033  frmLeg->AddFrame(new TGLabel(frmLeg, ": Enabled"),
1034  new TGLayoutHints(kLHintsLeft | kLHintsTop, 0, 10, 0, 5));
1036  kLHintsExpandX, 0, 0, 0, 0));
1037 
1038  TGCompositeFrame* frmBtn = new TGHorizontalFrame(fFB, 300, 100);
1039  frmBtn->SetCleanup(kDeepCleanup);
1040  frmBtn->AddFrame(fBtnUpload = new TGTextButton(frmBtn,
1041  " Upload "), new TGLayoutHints(kLHintsLeft | kLHintsExpandX |
1042  kLHintsCenterY, 5, 5, 5, 5));
1043  fBtnUpload->SetToolTipText("Upload selected package(s) to the server");
1044  frmBtn->AddFrame(fBtnEnable = new TGTextButton(frmBtn,
1045  " Enable "), new TGLayoutHints(kLHintsLeft | kLHintsExpandX |
1046  kLHintsCenterY, 5, 5, 5, 5));
1047  fBtnEnable->SetToolTipText("Enable selected package(s) on the server");
1048  frmBtn->AddFrame(fBtnDisable = new TGTextButton(frmBtn,
1049  " Disable "), new TGLayoutHints(kLHintsLeft | kLHintsExpandX |
1050  kLHintsCenterY, 5, 5, 5, 5));
1051  fBtnDisable->SetToolTipText("Disable selected package(s) on the server");
1052  frmBtn->AddFrame(fBtnClear = new TGTextButton(frmBtn,
1053  " Clear "), new TGLayoutHints(kLHintsLeft | kLHintsExpandX |
1054  kLHintsCenterY, 5, 5, 5, 5));
1055  fBtnClear->SetToolTipText("Clear all packages on the server");
1056  fFB->AddFrame(frmBtn, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
1057 
1059 
1060  TGCompositeFrame* frmBtn3 = new TGHorizontalFrame(fFB, 300, 100);
1061  frmBtn3->SetCleanup(kDeepCleanup);
1062  fBtnShow = new TGTextButton(frmBtn3, "Show packages");
1063  fBtnShow->SetToolTipText("Show (list) available packages on the server");
1065  kLHintsExpandX, 5, 5, 5, 5));
1066  fBtnShowEnabled = new TGTextButton(frmBtn3, "Show Enabled");
1067  fBtnShowEnabled->SetToolTipText("Show (list) enabled packages on the server");
1069  kLHintsExpandX, 5, 5, 5, 5));
1070  fFB->AddFrame(frmBtn3, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
1071 
1072  fChkEnable = new TGCheckButton(fFB, "Enable at session startup");
1073  fChkEnable->SetToolTipText("Enable packages on the server at startup time");
1074  fFB->AddFrame(fChkEnable, new TGLayoutHints(kLHintsLeft, 5, 5, 5, 5));
1075 
1076  // add "DataSets" tab element
1077  tf = fTab->AddTab("DataSets");
1078  fFE = new TGCompositeFrame(tf, 100, 100, kVerticalFrame);
1081 
1082  // new frame containing datasets treeview and control buttons
1083  TGCompositeFrame* frmdataset = new TGHorizontalFrame(fFE, 350, 100);
1084 
1085  // datasets list tree
1086  fDSetView = new TGCanvas(frmdataset, 200, 200, kSunkenFrame | kDoubleBorder);
1088  5, 5, 5, 5));
1090  fDataSetTree->AddItem(0, "DataSets");
1091 
1092  // control buttons frame
1093  TGCompositeFrame* frmBut3 = new TGVerticalFrame(frmdataset, 150, 100);
1094 
1095  fBtnUploadDSet = new TGTextButton(frmBut3, " Upload... ");
1096  fBtnUploadDSet->SetToolTipText("Upload a dataset to the cluster");
1098  kLHintsExpandX, 5, 5, 5, 5));
1099  fBtnRemoveDSet = new TGTextButton(frmBut3, "Remove");
1100  fBtnRemoveDSet->SetToolTipText("Remove dataset from the cluster");
1102  kLHintsExpandX, 5, 5, 5, 5));
1103  fBtnVerifyDSet = new TGTextButton(frmBut3, "Verify");
1104  fBtnVerifyDSet->SetToolTipText("Verify dataset on the cluster");
1106  kLHintsExpandX, 5, 5, 5, 5));
1107  fBtnRefresh = new TGTextButton(frmBut3, "Refresh List");
1108  fBtnRefresh->SetToolTipText("Refresh List of DataSet/Files present on the cluster");
1110  kLHintsExpandX, 5, 5, 15, 5));
1111 
1112  frmdataset->AddFrame(frmBut3, new TGLayoutHints(kLHintsLeft | kLHintsCenterY |
1113  kLHintsExpandY, 5, 5, 5, 0));
1114 
1115  fFE->AddFrame(frmdataset, new TGLayoutHints(kLHintsLeft | kLHintsTop |
1117 
1118  // add "Options" tab element
1119  tf = fTab->AddTab("Options");
1120  fFD = new TGCompositeFrame(tf, 100, 100, kVerticalFrame);
1123 
1124  // add Log Level label and text entry
1125  TGCompositeFrame* frmLog = new TGHorizontalFrame(fFD, 310, 100, kFixedWidth);
1126  frmLog->SetCleanup(kDeepCleanup);
1127  frmLog->AddFrame(fApplyLogLevel = new TGTextButton(frmLog,
1128  " Apply "), new TGLayoutHints(kLHintsRight |
1129  kLHintsCenterY, 10, 5, 5, 5));
1130  fApplyLogLevel->SetToolTipText("Apply currently selected log level");
1131  fLogLevel = new TGNumberEntry(frmLog, 0, 5, 5, TGNumberFormat::kNESInteger,
1134  kLHintsCenterY, 5, 5, 5, 5));
1135  frmLog->AddFrame(new TGLabel(frmLog, "Log Level :"),
1136  new TGLayoutHints(kLHintsRight | kLHintsCenterY, 5, 5, 5, 5));
1137  fFD->AddFrame(frmLog, new TGLayoutHints(kLHintsLeft, 5, 5, 15, 5));
1138 
1139  // add Parallel Nodes label and text entry
1140  TGCompositeFrame* frmPar = new TGHorizontalFrame(fFD, 310, 100, kFixedWidth);
1141  frmPar->SetCleanup(kDeepCleanup);
1142  frmPar->AddFrame(fApplyParallel = new TGTextButton(frmPar,
1143  " Apply "), new TGLayoutHints(kLHintsRight |
1144  kLHintsCenterY, 10, 5, 5, 5));
1145  fApplyParallel->SetToolTipText("Apply currently selected parallel nodes");
1146  fTxtParallel = new TGTextEntry(frmPar);
1148  fTxtParallel->SetText("99999");
1151  kLHintsCenterY, 5, 5, 5, 5));
1152  frmPar->AddFrame(new TGLabel(frmPar, "Set Parallel Nodes :"),
1153  new TGLayoutHints(kLHintsRight | kLHintsCenterY, 5, 5, 5, 5));
1154  fFD->AddFrame(frmPar, new TGLayoutHints(kLHintsLeft, 5, 5, 5, 5));
1155 
1156  // connect button actions to functions
1157  fBtnShowLog->Connect("Clicked()", "TSessionFrame", this,
1158  "OnBtnShowLogClicked()");
1159  fBtnNewQuery->Connect("Clicked()", "TSessionFrame", this,
1160  "OnBtnNewQueryClicked()");
1161  fBtnGetQueries->Connect("Clicked()", "TSessionFrame", this,
1162  "OnBtnGetQueriesClicked()");
1163 
1164  fChkEnable->Connect("Toggled(Bool_t)", "TSessionFrame", this,
1165  "OnStartupEnable(Bool_t)");
1166  fChkMulti->Connect("Toggled(Bool_t)", "TSessionFrame", this,
1167  "OnMultipleSelection(Bool_t)");
1168  fBtnAdd->Connect("Clicked()", "TSessionFrame", this,
1169  "OnBtnAddClicked()");
1170  fBtnRemove->Connect("Clicked()", "TSessionFrame", this,
1171  "OnBtnRemoveClicked()");
1172  fBtnUp->Connect("Clicked()", "TSessionFrame", this,
1173  "OnBtnUpClicked()");
1174  fBtnDown->Connect("Clicked()", "TSessionFrame", this,
1175  "OnBtnDownClicked()");
1176  fApplyLogLevel->Connect("Clicked()", "TSessionFrame", this,
1177  "OnApplyLogLevel()");
1178  fApplyParallel->Connect("Clicked()", "TSessionFrame", this,
1179  "OnApplyParallel()");
1180  fBtnUpload->Connect("Clicked()", "TSessionFrame", this,
1181  "OnUploadPackages()");
1182  fBtnEnable->Connect("Clicked()", "TSessionFrame", this,
1183  "OnEnablePackages()");
1184  fBtnDisable->Connect("Clicked()", "TSessionFrame", this,
1185  "OnDisablePackages()");
1186  fBtnClear->Connect("Clicked()", "TSessionFrame", this,
1187  "OnClearPackages()");
1188  fBtnShowEnabled->Connect("Clicked()", "TSessionViewer", fViewer,
1189  "ShowEnabledPackages()");
1190  fBtnShow->Connect("Clicked()", "TSessionViewer", fViewer,
1191  "ShowPackages()");
1192 
1193  fBtnUploadDSet->Connect("Clicked()", "TSessionFrame", this,
1194  "OnBtnUploadDSet()");
1195  fBtnRemoveDSet->Connect("Clicked()", "TSessionFrame", this,
1196  "OnBtnRemoveDSet()");
1197  fBtnVerifyDSet->Connect("Clicked()", "TSessionFrame", this,
1198  "OnBtnVerifyDSet()");
1199  fBtnRefresh->Connect("Clicked()", "TSessionFrame", this,
1200  "UpdateListOfDataSets()");
1201 }
1202 
1203 ////////////////////////////////////////////////////////////////////////////////
1204 /// Display information on current session.
1205 
1207 {
1208  TString buf;
1209 
1210  // if local session
1211  if (fViewer->GetActDesc()->fLocal) {
1212  buf.Form("*** Local Session on %s ***", gSystem->HostName());
1213  fInfoLine[0]->SetText(buf.Data());
1214  UserGroup_t *userGroup = gSystem->GetUserInfo();
1215  fInfoLine[1]->SetText("User :");
1216  if (userGroup) buf.Form("%s", userGroup->fRealName.Data());
1217  fInfoLine[2]->SetText(buf.Data());
1218  fInfoLine[3]->SetText("Working directory :");
1219  buf.Form("%s", gSystem->WorkingDirectory());
1220  fInfoLine[4]->SetText(buf.Data());
1221  fInfoLine[5]->SetText(" ");
1222  fInfoLine[6]->SetText(" ");
1223  fInfoLine[7]->SetText(" ");
1224  fInfoLine[8]->SetText(" ");
1225  fInfoLine[9]->SetText(" ");
1226  fInfoLine[10]->SetText(" ");
1227  fInfoLine[11]->SetText(" ");
1228  fInfoLine[12]->SetText(" ");
1229  fInfoLine[13]->SetText(" ");
1230  fInfoLine[14]->SetText(" ");
1231  fInfoLine[15]->SetText(" ");
1232  fInfoLine[16]->SetText(" ");
1233  fInfoLine[17]->SetText(" ");
1234  fInfoLine[18]->SetText(" ");
1235  if (userGroup) delete userGroup;
1236  Layout();
1238  return;
1239  }
1240  // return if not a valid Proof session
1241  if (!fViewer->GetActDesc()->fConnected ||
1242  !fViewer->GetActDesc()->fAttached ||
1243  !fViewer->GetActDesc()->fProof ||
1244  !fViewer->GetActDesc()->fProof->IsValid())
1245  return;
1246 
1247  if (!fViewer->GetActDesc()->fProof->IsMaster()) {
1248  if (fViewer->GetActDesc()->fProof->IsParallel())
1249  buf.Form("*** Connected to %s (parallel mode, %d workers) ***",
1252  else
1253  buf.Form("*** Connected to %s (sequential mode) ***",
1255  fInfoLine[0]->SetText(buf.Data());
1256  fInfoLine[1]->SetText("Port number : ");
1257  buf.Form("%d", fViewer->GetActDesc()->fProof->GetPort());
1258  fInfoLine[2]->SetText(buf.Data());
1259  fInfoLine[3]->SetText("User : ");
1260  buf.Form("%s", fViewer->GetActDesc()->fProof->GetUser());
1261  fInfoLine[4]->SetText(buf.Data());
1262  fInfoLine[5]->SetText("Client protocol version : ");
1263  buf.Form("%d", fViewer->GetActDesc()->fProof->GetClientProtocol());
1264  fInfoLine[6]->SetText(buf.Data());
1265  fInfoLine[7]->SetText("Remote protocol version : ");
1266  buf.Form("%d", fViewer->GetActDesc()->fProof->GetRemoteProtocol());
1267  fInfoLine[8]->SetText(buf.Data());
1268  fInfoLine[9]->SetText("Log level : ");
1269  buf.Form("%d", fViewer->GetActDesc()->fProof->GetLogLevel());
1270  fInfoLine[10]->SetText(buf.Data());
1271  fInfoLine[11]->SetText("Session unique tag : ");
1272  buf.Form("%s", fViewer->GetActDesc()->fProof->IsValid() ?
1273  fViewer->GetActDesc()->fProof->GetSessionTag() : " ");
1274  fInfoLine[12]->SetText(buf.Data());
1275  fInfoLine[13]->SetText("Total MB's processed :");
1276  buf.Form("%.2f", float(fViewer->GetActDesc()->fProof->GetBytesRead())/(1024*1024));
1277  fInfoLine[14]->SetText(buf.Data());
1278  fInfoLine[15]->SetText("Total real time used (s) :");
1279  buf.Form("%.3f", fViewer->GetActDesc()->fProof->GetRealTime());
1280  fInfoLine[16]->SetText(buf.Data());
1281  fInfoLine[17]->SetText("Total CPU time used (s) :");
1282  buf.Form("%.3f", fViewer->GetActDesc()->fProof->GetCpuTime());
1283  fInfoLine[18]->SetText(buf.Data());
1284  }
1285  else {
1286  if (fViewer->GetActDesc()->fProof->IsParallel())
1287  buf.Form("*** Master server %s (parallel mode, %d workers) ***",
1290  else
1291  buf.Form("*** Master server %s (sequential mode) ***",
1293  fInfoLine[0]->SetText(buf.Data());
1294  fInfoLine[1]->SetText("Port number : ");
1295  buf.Form("%d", fViewer->GetActDesc()->fProof->GetPort());
1296  fInfoLine[2]->SetText(buf.Data());
1297  fInfoLine[3]->SetText("User : ");
1298  buf.Form("%s", fViewer->GetActDesc()->fProof->GetUser());
1299  fInfoLine[4]->SetText(buf.Data());
1300  fInfoLine[5]->SetText("Protocol version : ");
1301  buf.Form("%d", fViewer->GetActDesc()->fProof->GetClientProtocol());
1302  fInfoLine[6]->SetText(buf.Data());
1303  fInfoLine[7]->SetText("Image name : ");
1304  buf.Form("%s",fViewer->GetActDesc()->fProof->GetImage());
1305  fInfoLine[8]->SetText(buf.Data());
1306  fInfoLine[9]->SetText("Config directory : ");
1307  buf.Form("%s", fViewer->GetActDesc()->fProof->GetConfDir());
1308  fInfoLine[10]->SetText(buf.Data());
1309  fInfoLine[11]->SetText("Config file : ");
1310  buf.Form("%s", fViewer->GetActDesc()->fProof->GetConfFile());
1311  fInfoLine[12]->SetText(buf.Data());
1312  fInfoLine[13]->SetText("Total MB's processed :");
1313  buf.Form("%.2f", float(fViewer->GetActDesc()->fProof->GetBytesRead())/(1024*1024));
1314  fInfoLine[14]->SetText(buf.Data());
1315  fInfoLine[15]->SetText("Total real time used (s) :");
1316  buf.Form("%.3f", fViewer->GetActDesc()->fProof->GetRealTime());
1317  fInfoLine[16]->SetText(buf.Data());
1318  fInfoLine[17]->SetText("Total CPU time used (s) :");
1319  buf.Form("%.3f", fViewer->GetActDesc()->fProof->GetCpuTime());
1320  fInfoLine[18]->SetText(buf.Data());
1321  }
1322  Layout();
1324 }
1325 
1326 ////////////////////////////////////////////////////////////////////////////////
1327 /// Open Upload Dataset dialog.
1328 
1330 {
1331  if (fViewer->IsBusy())
1332  return;
1333  if (fViewer->GetActDesc()->fLocal) return;
1334  new TUploadDataSetDlg(fViewer, 450, 360);
1335 }
1336 
1337 ////////////////////////////////////////////////////////////////////////////////
1338 /// Update list of dataset present on the cluster.
1339 
1341 {
1342  TObjString *dsetname;
1343  TFileInfo *dsetfilename;
1344  // cleanup the list
1349 
1350  const TGPicture *dseticon = fClient->GetPicture("rootdb_t.xpm");
1351  // ask for the list of datasets
1352 
1353  // TODO: is now returning a TMap; viewer has to be adapted
1354  TList *dsetlist = 0; //fViewer->GetActDesc()->fProof->GetDataSets();
1355  // coverity[dead_error_condition]: to be changed for TMap usage
1356  if (dsetlist) {
1357  TGListTreeItem *dsetitem;
1359  TIter nextdset(dsetlist);
1360  while ((dsetname = (TObjString *)nextdset())) {
1361  if (!fDataSetTree->FindItemByObj(fDataSetTree->GetFirstItem(), dsetname)) {
1362  // add the dataset in the tree
1364  dsetname->GetName(), dsetname);
1365  // ask for the list of files in the dataset
1366  TList *dsetfilelist = fViewer->GetActDesc()->fProof->GetDataSet(
1367  dsetname->GetName())->GetList();
1368  if(dsetfilelist) {
1369  TIter nextdsetfile(dsetfilelist);
1370  while ((dsetfilename = (TFileInfo *)nextdsetfile())) {
1371  if (! fDataSetTree->FindItemByObj(dsetitem, dsetfilename)) {
1372  // if not already in, add the file name in the tree
1373  fDataSetTree->AddItem(dsetitem,
1374  dsetfilename->GetFirstUrl()->GetUrl(),
1375  dsetfilename, dseticon, dseticon);
1376  }
1377  }
1378  // open the dataset item in order to show the files
1379  fDataSetTree->OpenItem(dsetitem);
1380  }
1381  }
1382  }
1383  }
1384  }
1385  // refresh list tree
1387 }
1388 
1389 ////////////////////////////////////////////////////////////////////////////////
1390 /// Remove dataset from the list and from the cluster.
1391 
1393 {
1394  TGListTreeItem *item;
1395  TObjString *obj = 0;
1396  if (fViewer->GetActDesc()->fLocal) return;
1397 
1398  item = fDataSetTree->GetSelected();
1399  if (!item) return;
1400  if (item->GetParent() == 0) return;
1401  if (item->GetParent() == fDataSetTree->GetFirstItem()) {
1402  // Dataset itself
1403  obj = (TObjString *)item->GetUserData();
1404  }
1405  else if (item->GetParent()->GetParent() == fDataSetTree->GetFirstItem()) {
1406  // One file of the dataset
1407  obj = (TObjString *)item->GetParent()->GetUserData();
1408  }
1409 
1410  // if valid Proof session, set parallel slaves
1411  if (obj && fViewer->GetActDesc()->fProof &&
1412  fViewer->GetActDesc()->fProof->IsValid()) {
1415  }
1416 }
1417 
1418 ////////////////////////////////////////////////////////////////////////////////
1419 /// Verify that the files in the selected dataset are present on the cluster.
1420 
1422 {
1423  TGListTreeItem *item;
1424  TObjString *obj = 0;
1425  if (fViewer->GetActDesc()->fLocal) return;
1426 
1427  item = fDataSetTree->GetSelected();
1428  if (!item) return;
1429  if (item->GetParent() == 0) return;
1430  if (item->GetParent() == fDataSetTree->GetFirstItem()) {
1431  // Dataset itself
1432  obj = (TObjString *)item->GetUserData();
1433  }
1434  else if (item->GetParent()->GetParent() == fDataSetTree->GetFirstItem()) {
1435  // One file of the dataset
1436  obj = (TObjString *)item->GetParent()->GetUserData();
1437  }
1438 
1439  // if valid Proof session, set parallel slaves
1440  if (obj && fViewer->GetActDesc()->fProof &&
1441  fViewer->GetActDesc()->fProof->IsValid()) {
1443  }
1444 }
1445 
1446 ////////////////////////////////////////////////////////////////////////////////
1447 /// Apply selected log level on current session.
1448 
1450 {
1451  // if local session, do nothing
1452  if (fViewer->GetActDesc()->fLocal) return;
1453  // if valid Proof session, set log level
1454  if (fViewer->GetActDesc()->fProof &&
1455  fViewer->GetActDesc()->fProof->IsValid()) {
1458  }
1460 }
1461 
1462 ////////////////////////////////////////////////////////////////////////////////
1463 /// Apply selected number of workers on current Proof session.
1464 
1466 {
1467  // if local session, do nothing
1468  if (fViewer->GetActDesc()->fLocal) return;
1469  // if valid Proof session, set parallel slaves
1470  if (fViewer->GetActDesc()->fProof &&
1471  fViewer->GetActDesc()->fProof->IsValid()) {
1472  Int_t nodes = atoi(fTxtParallel->GetText());
1473  fViewer->GetActDesc()->fProof->SetParallel(nodes);
1474  }
1476 }
1477 
1478 ////////////////////////////////////////////////////////////////////////////////
1479 /// Handle multiple selection check button.
1480 
1482 {
1484 }
1485 
1486 ////////////////////////////////////////////////////////////////////////////////
1487 /// Handle multiple selection check button.
1488 
1490 {
1491  if (fViewer->GetActDesc())
1492  fViewer->GetActDesc()->fAutoEnable = on;
1493 }
1494 
1495 ////////////////////////////////////////////////////////////////////////////////
1496 /// Update list of packages.
1497 
1499 {
1500  TPackageDescription *package;
1501  const TGPicture *pict;
1503  TIter next(fViewer->GetActDesc()->fPackages);
1504  while ((package = (TPackageDescription *)next())) {
1505  if (package->fEnabled)
1506  pict = fClient->GetPicture("package_add.xpm");
1507  else if (package->fUploaded)
1508  pict = fClient->GetPicture("package_delete.xpm");
1509  else
1510  pict = fClient->GetPicture("package.xpm");
1512  package->fId, package->fPathName, pict);
1514  }
1515  fLBPackages->Layout();
1517 }
1518 
1519 ////////////////////////////////////////////////////////////////////////////////
1520 /// Upload selected package(s) to the current session.
1521 
1523 {
1524  // if local session, do nothing
1525  if (fViewer->GetActDesc()->fLocal) return;
1526  // if valid Proof session, upload packages
1527  if (fViewer->GetActDesc()->fProof &&
1528  fViewer->GetActDesc()->fProof->IsValid()) {
1529  TObject *obj;
1530  TList selected;
1531  fLBPackages->GetSelectedEntries(&selected);
1532  TIter next(&selected);
1533  while ((obj = next())) {
1534  TString name = obj->GetTitle();
1535  if (fViewer->GetActDesc()->fProof->UploadPackage(name.Data()) != 0)
1536  Error("Submit", "Upload package failed");
1537  else {
1539  if (!o) continue;
1540  TPackageDescription *package =
1541  dynamic_cast<TPackageDescription *>(o);
1542  if (package) {
1543  package->fUploaded = kTRUE;
1544  ((TGIconLBEntry *)obj)->SetPicture(
1545  fClient->GetPicture("package_delete.xpm"));
1546  }
1547  }
1548  }
1549  UpdatePackages();
1550  }
1551  fLBPackages->Layout();
1553 }
1554 
1555 ////////////////////////////////////////////////////////////////////////////////
1556 /// Enable selected package(s) in the current session.
1557 
1559 {
1560  // if local session, do nothing
1561  if (fViewer->GetActDesc()->fLocal) return;
1562  // if valid Proof session, enable packages
1563  if (fViewer->GetActDesc()->fProof &&
1564  fViewer->GetActDesc()->fProof->IsValid()) {
1565  TObject *obj;
1566  TList selected;
1568  fLBPackages->GetSelectedEntries(&selected);
1569  TIter next(&selected);
1570  while ((obj = next())) {
1571  TString name = obj->GetTitle();
1573  if (!o) continue;
1574  TPackageDescription *package =
1575  dynamic_cast<TPackageDescription *>(o);
1576  if (package) {
1577  if (!package->fUploaded) {
1578  if (fViewer->GetActDesc()->fProof->UploadPackage(name.Data()) != 0)
1579  Error("Submit", "Upload package failed");
1580  else {
1581  package->fUploaded = kTRUE;
1582  ((TGIconLBEntry *)obj)->SetPicture(
1583  fClient->GetPicture("package_delete.xpm"));
1584  }
1585  }
1586  }
1587  if (fViewer->GetActDesc()->fProof->EnablePackage(name) != 0)
1588  Error("Submit", "Enable package failed");
1589  else {
1590  package->fEnabled = kTRUE;
1591  ((TGIconLBEntry *)obj)->SetPicture(fClient->GetPicture("package_add.xpm"));
1592  }
1593  }
1594  UpdatePackages();
1596  }
1597  fLBPackages->Layout();
1599 }
1600 
1601 ////////////////////////////////////////////////////////////////////////////////
1602 /// Disable selected package(s) in the current session.
1603 
1605 {
1606  // if local session, do nothing
1607  if (fViewer->GetActDesc()->fLocal) return;
1608  // if valid Proof session, disable (clear) packages
1609  if (fViewer->GetActDesc()->fProof &&
1610  fViewer->GetActDesc()->fProof->IsValid()) {
1611  TObject *obj;
1612  TList selected;
1613  fLBPackages->GetSelectedEntries(&selected);
1614  TIter next(&selected);
1615  while ((obj = next())) {
1616  TString name = obj->GetTitle();
1617  if (fViewer->GetActDesc()->fProof->ClearPackage(name) != 0)
1618  Error("Submit", "Clear package failed");
1619  else {
1621  if (!o) continue;
1622  TPackageDescription *package =
1623  dynamic_cast<TPackageDescription *>(o);
1624  if (package) {
1625  package->fEnabled = kFALSE;
1626  package->fUploaded = kFALSE;
1627  ((TGIconLBEntry *)obj)->SetPicture(fClient->GetPicture("package.xpm"));
1628  }
1629  }
1630  }
1631  UpdatePackages();
1632  }
1633  fLBPackages->Layout();
1635 }
1636 
1637 ////////////////////////////////////////////////////////////////////////////////
1638 /// Clear (disable) all packages in the current session.
1639 
1641 {
1642  TPackageDescription *package;
1643  // if local session, do nothing
1644  if (fViewer->GetActDesc()->fLocal) return;
1645  // if valid Proof session, clear packages
1646  if (fViewer->GetActDesc()->fProof &&
1647  fViewer->GetActDesc()->fProof->IsValid()) {
1648  if (fViewer->GetActDesc()->fProof->ClearPackages() != 0)
1649  Error("Submit", "Clear packages failed");
1650  else {
1651  TIter next(fViewer->GetActDesc()->fPackages);
1652  while ((package = (TPackageDescription *)next())) {
1653  package->fEnabled = kFALSE;
1654  }
1655  }
1656  }
1657  fLBPackages->Layout();
1659 }
1660 
1661 ////////////////////////////////////////////////////////////////////////////////
1662 /// Open file dialog and add selected package file to the list.
1663 
1665 {
1666  if (fViewer->IsBusy())
1667  return;
1668  TGFileInfo fi;
1669  TPackageDescription *package;
1670  TGIconLBEntry *entry;
1671  fi.fFileTypes = pkgtypes;
1672  new TGFileDialog(fClient->GetRoot(), fViewer, kFDOpen, &fi);
1673  if (fi.fMultipleSelection && fi.fFileNamesList) {
1674  TObjString *el;
1675  TIter next(fi.fFileNamesList);
1676  while ((el = (TObjString *) next())) {
1677  package = new TPackageDescription;
1678  package->fName = gSystem->BaseName(gSystem->UnixPathName(el->GetString()));
1679  package->fPathName = gSystem->UnixPathName(el->GetString());
1680  package->fId = fViewer->GetActDesc()->fPackages->GetEntries();
1681  package->fUploaded = kFALSE;
1682  package->fEnabled = kFALSE;
1683  fViewer->GetActDesc()->fPackages->Add((TObject *)package);
1684  entry = new TGIconLBEntry(fLBPackages->GetContainer(),
1685  package->fId, package->fPathName,
1686  fClient->GetPicture("package.xpm"));
1688  }
1689  }
1690  else if (fi.fFilename) {
1691  package = new TPackageDescription;
1692  package->fName = gSystem->BaseName(gSystem->UnixPathName(fi.fFilename));
1693  package->fPathName = gSystem->UnixPathName(fi.fFilename);
1694  package->fId = fViewer->GetActDesc()->fPackages->GetEntries();
1695  package->fUploaded = kFALSE;
1696  package->fEnabled = kFALSE;
1697  fViewer->GetActDesc()->fPackages->Add((TObject *)package);
1698  entry = new TGIconLBEntry(fLBPackages->GetContainer(),
1699  package->fId, package->fPathName,
1700  fClient->GetPicture("package.xpm"));
1702  }
1703  fLBPackages->Layout();
1705 }
1706 
1707 ////////////////////////////////////////////////////////////////////////////////
1708 /// Remove selected package from the list.
1709 
1711 {
1712  TPackageDescription *package;
1713  const TGPicture *pict;
1714  Int_t pos = fLBPackages->GetSelected();
1717  fViewer->GetActDesc()->fPackages->At(pos));
1718  Int_t id = 0;
1719  TIter next(fViewer->GetActDesc()->fPackages);
1720  while ((package = (TPackageDescription *)next())) {
1721  package->fId = id;
1722  id++;
1723  if (package->fEnabled)
1724  pict = fClient->GetPicture("package_add.xpm");
1725  else if (package->fUploaded)
1726  pict = fClient->GetPicture("package_delete.xpm");
1727  else
1728  pict = fClient->GetPicture("package.xpm");
1730  package->fId, package->fPathName, pict);
1732  }
1733  fLBPackages->Layout();
1735 }
1736 
1737 ////////////////////////////////////////////////////////////////////////////////
1738 /// Move selected package entry one position up in the list.
1739 
1741 {
1742  TPackageDescription *package;
1743  const TGPicture *pict;
1744  Int_t pos = fLBPackages->GetSelected();
1745  if (pos <= 0) return;
1747  package = (TPackageDescription *)fViewer->GetActDesc()->fPackages->At(pos);
1749  fViewer->GetActDesc()->fPackages->At(pos));
1750  package->fId -= 1;
1751  fViewer->GetActDesc()->fPackages->AddAt(package, package->fId);
1752  Int_t id = 0;
1753  TIter next(fViewer->GetActDesc()->fPackages);
1754  while ((package = (TPackageDescription *)next())) {
1755  package->fId = id;
1756  id++;
1757  if (package->fEnabled)
1758  pict = fClient->GetPicture("package_add.xpm");
1759  else if (package->fUploaded)
1760  pict = fClient->GetPicture("package_delete.xpm");
1761  else
1762  pict = fClient->GetPicture("package.xpm");
1764  package->fId, package->fPathName, pict);
1766  }
1767  fLBPackages->Select(pos-1);
1768  fLBPackages->Layout();
1770 }
1771 
1772 ////////////////////////////////////////////////////////////////////////////////
1773 /// Move selected package entry one position down in the list.
1774 
1776 {
1777  TPackageDescription *package;
1778  const TGPicture *pict;
1779  Int_t pos = fLBPackages->GetSelected();
1780  if (pos == -1 || pos == fViewer->GetActDesc()->fPackages->GetEntries()-1)
1781  return;
1783  package = (TPackageDescription *)fViewer->GetActDesc()->fPackages->At(pos);
1785  fViewer->GetActDesc()->fPackages->At(pos));
1786  package->fId += 1;
1787  fViewer->GetActDesc()->fPackages->AddAt(package, package->fId);
1788  Int_t id = 0;
1789  TIter next(fViewer->GetActDesc()->fPackages);
1790  while ((package = (TPackageDescription *)next())) {
1791  package->fId = id;
1792  id++;
1793  if (package->fEnabled)
1794  pict = fClient->GetPicture("package_add.xpm");
1795  else if (package->fUploaded)
1796  pict = fClient->GetPicture("package_delete.xpm");
1797  else
1798  pict = fClient->GetPicture("package.xpm");
1800  package->fId, package->fPathName, pict);
1802  }
1803  fLBPackages->Select(pos+1);
1804  fLBPackages->Layout();
1806 }
1807 
1808 ////////////////////////////////////////////////////////////////////////////////
1809 /// Disconnect from current Proof session.
1810 
1812 {
1813  // if local session, do nothing
1814  if (fViewer->GetActDesc()->fLocal) return;
1815  // if valid Proof session, disconnect (close)
1816  if (fViewer->GetActDesc()->fAttached &&
1817  fViewer->GetActDesc()->fProof &&
1818  fViewer->GetActDesc()->fProof->IsValid()) {
1820  }
1821  // reset connected flag
1823  fViewer->GetActDesc()->fProof = 0;
1824  // disable animation timer
1825  fViewer->DisableTimer();
1826  // change list tree item picture to disconnected pixmap
1829  if (item) {
1832  }
1833  // update viewer
1835  1, 0, 0);
1838  fViewer->GetStatusBar()->SetText("", 1);
1839 }
1840 
1841 ////////////////////////////////////////////////////////////////////////////////
1842 /// Show session log.
1843 
1845 {
1846  fViewer->ShowLog(0);
1847 }
1848 
1849 ////////////////////////////////////////////////////////////////////////////////
1850 /// Call "New Query" Dialog.
1851 
1853 {
1854  TNewQueryDlg *dlg = new TNewQueryDlg(fViewer, 350, 310);
1855  dlg->Popup();
1856 }
1857 
1858 ////////////////////////////////////////////////////////////////////////////////
1859 /// Get list of queries from current Proof server and populate the list tree.
1860 
1862 {
1863  TList *lqueries = 0;
1864  TQueryResult *query = 0;
1865  TQueryDescription *newquery = 0, *lquery = 0;
1866  if (fViewer->GetActDesc()->fProof &&
1867  fViewer->GetActDesc()->fProof->IsValid()) {
1868  lqueries = fViewer->GetActDesc()->fProof->GetListOfQueries();
1869  }
1870  if (lqueries) {
1871  TIter nextp(lqueries);
1872  // loop over list of queries received from Proof server
1873  while ((query = (TQueryResult *)nextp())) {
1874  // create new query description
1875  newquery = new TQueryDescription();
1876  newquery->fReference = TString::Format("%s:%s", query->GetTitle(),
1877  query->GetName());
1878  // check in our tree if it is already there
1879  TGListTreeItem *item =
1882  // if already there, skip
1884  newquery->fReference.Data()))
1885  continue;
1886  // check also in our query description list
1887  Bool_t found = kFALSE;
1888  TIter nextp2(fViewer->GetActDesc()->fQueries);
1889  while ((lquery = (TQueryDescription *)nextp2())) {
1890  if (lquery->fReference.CompareTo(newquery->fReference) == 0) {
1891  found = kTRUE;
1892  break;
1893  }
1894  }
1895  if (found) continue;
1896  // build new query description with infos from Proof
1897  newquery->fStatus = query->IsFinalized() ?
1900  newquery->fSelectorString = query->GetSelecImp()->GetName();
1901  newquery->fQueryName = TString::Format("%s:%s", query->GetTitle(),
1902  query->GetName());
1903  newquery->fOptions = query->GetOptions();
1904  newquery->fEventList = "";
1905  newquery->fNbFiles = 0;
1906  newquery->fNoEntries = query->GetEntries();
1907  newquery->fFirstEntry = query->GetFirst();
1908  newquery->fResult = query;
1909  newquery->fChain = 0;
1910  fViewer->GetActDesc()->fQueries->Add((TObject *)newquery);
1912  newquery->fQueryName, fViewer->GetQueryConPict(),
1914  item2->SetUserData(newquery);
1915  if (query->GetInputList())
1916  fViewer->GetSessionHierarchy()->AddItem(item2, "InputList");
1917  if (query->GetOutputList())
1918  fViewer->GetSessionHierarchy()->AddItem(item2, "OutputList");
1919  }
1920  }
1921  // at the end, update list tree
1924 }
1925 
1926 ////////////////////////////////////////////////////////////////////////////////
1927 /// Command line handling.
1928 
1930 {
1931  // get command string
1932  const char *cmd = fCommandTxt->GetText();
1933  char opt[2];
1934  // form temporary file path
1935  TString pathtmp = TString::Format("%s/%s", gSystem->TempDirectory(),
1937  // if check box "clear view" is checked, open temp file in write mode
1938  // (overwrite), in append mode otherwise.
1939  if (fClearCheck->IsOn())
1940  snprintf(opt, 2, "w");
1941  else
1942  snprintf(opt, 2, "a");
1943 
1944  // if valid Proof session, pass the command to Proof
1945  if (fViewer->GetActDesc()->fProof &&
1946  fViewer->GetActDesc()->fProof->IsValid()) {
1947  // redirect stdout/stderr to temp file
1948  if (gSystem->RedirectOutput(pathtmp.Data(), opt) != 0) {
1949  Error("ShowStatus", "stdout/stderr redirection failed; skipping");
1950  return;
1951  }
1952  // execute command line
1953  fViewer->GetActDesc()->fProof->Exec(cmd);
1954  // restore back stdout/stderr
1955  if (gSystem->RedirectOutput(0) != 0) {
1956  Error("ShowStatus", "stdout/stderr retore failed; skipping");
1957  return;
1958  }
1959  // if check box "clear view" is checked, clear text view
1960  if (fClearCheck->IsOn())
1961  fInfoTextView->Clear();
1962  // load (display) temp file in text view
1963  fInfoTextView->LoadFile(pathtmp.Data());
1964  // set focus to "command line" text entry
1965  fCommandTxt->SetFocus();
1966  }
1967  else {
1968  // if no Proof session, or Proof session not valid,
1969  // lets execute command line by TApplication
1970 
1971  // redirect stdout/stderr to temp file
1972  if (gSystem->RedirectOutput(pathtmp.Data(), opt) != 0) {
1973  Error("ShowStatus", "stdout/stderr redirection failed; skipping");
1974  }
1975  // execute command line
1976  gApplication->ProcessLine(cmd);
1977  // restore back stdout/stderr
1978  if (gSystem->RedirectOutput(0) != 0) {
1979  Error("ShowStatus", "stdout/stderr retore failed; skipping");
1980  }
1981  // if check box "clear view" is checked, clear text view
1982  if (fClearCheck->IsOn())
1983  fInfoTextView->Clear();
1984  // load (display) temp file in text view
1985  fInfoTextView->LoadFile(pathtmp.Data());
1986  // set focus to "command line" text entry
1987  fCommandTxt->SetFocus();
1988  }
1989  // display bottom of text view
1991 }
1992 
1993 ////////////////////////////////////////////////////////////////////////////////
1994 /// Switch widgets status/visibility for local/remote sessions.
1995 
1997 {
1998  if (local) {
2001  fTab->HideFrame(fTab->GetTabTab("Options"));
2002  fTab->HideFrame(fTab->GetTabTab("Packages"));
2003  fTab->HideFrame(fTab->GetTabTab("DataSets"));
2004  }
2005  else {
2008  fTab->ShowFrame(fTab->GetTabTab("Options"));
2009  fTab->ShowFrame(fTab->GetTabTab("Packages"));
2010  fTab->ShowFrame(fTab->GetTabTab("DataSets"));
2011  }
2012 }
2013 
2014 ////////////////////////////////////////////////////////////////////////////////
2015 /// Shutdown current session.
2016 
2018 {
2019  // do nothing if connection in progress
2020  if (fViewer->IsBusy())
2021  return;
2022 
2023  if (fViewer->GetActDesc()->fLocal) {
2024  Int_t retval;
2025  new TGMsgBox(fClient->GetRoot(), this, "Error Shutting down Session",
2026  "Shutting down Local Sessions is not allowed !",
2027  kMBIconExclamation,kMBOk,&retval);
2028  return;
2029  }
2030  if (!fViewer->GetActDesc()->fAttached ||
2031  !fViewer->GetActDesc()->fProof ||
2032  !fViewer->GetActDesc()->fProof->IsValid())
2033  return;
2034  // ask for confirmation
2035  TString m;
2036  m.Form("Are you sure to shutdown the session \"%s\"",
2037  fViewer->GetActDesc()->fName.Data());
2038  Int_t result;
2039  new TGMsgBox(fClient->GetRoot(), this, "", m.Data(), 0,
2040  kMBOk | kMBCancel, &result);
2041  // if confirmed, delete it
2042  if (result != kMBOk)
2043  return;
2044  // remove the Proof session from gROOT list of Proofs
2045  fViewer->GetActDesc()->fProof->Detach("S");
2046  // reset connected flag
2048  fViewer->GetActDesc()->fProof = 0;
2049  // disable animation timer
2050  fViewer->DisableTimer();
2051  // change list tree item picture to disconnected pixmap
2054  if (item) {
2057  }
2058  // update viewer
2060  1, 0, 0);
2063  fViewer->GetStatusBar()->SetText("", 1);
2064 }
2065 
2066 //////////////////////////////////////////////////////////////////////////
2067 // Edit Query Frame
2068 //////////////////////////////////////////////////////////////////////////
2069 
2070 ////////////////////////////////////////////////////////////////////////////////
2071 /// Create a new Query dialog, used by the Session Viewer, to Edit a Query if
2072 /// the editmode flag is set, or to create a new one if not set.
2073 
2075  TGCompositeFrame(p, w, h, kVerticalFrame), fFrmMore(0), fBtnMore(0),
2076  fTxtQueryName(0), fTxtChain(0), fTxtSelector(0), fTxtOptions(0),
2077  fNumEntries(0), fNumFirstEntry(0), fTxtParFile(0), fTxtEventList(0),
2078  fViewer(0), fQuery(0), fChain(0)
2079 {
2080 }
2081 
2082 ////////////////////////////////////////////////////////////////////////////////
2083 /// Delete query dialog.
2084 
2086 {
2087  Cleanup();
2088 }
2089 
2090 ////////////////////////////////////////////////////////////////////////////////
2091 /// Build the "new query" dialog.
2092 
2094 {
2095  TGButton *btnTmp;
2096  fViewer = gui;
2098  SetLayoutManager(new TGTableLayout(this, 6, 5));
2099 
2100  // add "Query Name" label and text entry
2101  AddFrame(new TGLabel(this, "Query Name :"),
2102  new TGTableLayoutHints(0, 1, 0, 1, kLHintsCenterY, 5, 5, 4, 0));
2103  AddFrame(fTxtQueryName = new TGTextEntry(this,
2104  (const char *)0, 1), new TGTableLayoutHints(1, 2, 0, 1,
2105  kLHintsCenterY, 5, 5, 4, 0));
2106 
2107  // add "TChain" label and text entry
2108  AddFrame(new TGLabel(this, "TChain :"),
2109  new TGTableLayoutHints(0, 1, 1, 2, kLHintsCenterY, 5, 5, 4, 0));
2110  AddFrame(fTxtChain = new TGTextEntry(this,
2111  (const char *)0, 2), new TGTableLayoutHints(1, 2, 1, 2,
2112  kLHintsCenterY, 5, 5, 4, 0));
2113  fTxtChain->SetToolTipText("Specify TChain or TDSet from memory or file");
2115  // add "Browse" button
2116  AddFrame(btnTmp = new TGTextButton(this, "Browse..."),
2117  new TGTableLayoutHints(2, 3, 1, 2, kLHintsCenterY, 5, 0, 4, 8));
2118  btnTmp->Connect("Clicked()", "TEditQueryFrame", this, "OnBrowseChain()");
2119 
2120  // add "Selector" label and text entry
2121  AddFrame(new TGLabel(this, "Selector :"),
2122  new TGTableLayoutHints(0, 1, 2, 3, kLHintsCenterY, 5, 5, 0, 0));
2123  AddFrame(fTxtSelector = new TGTextEntry(this,
2124  (const char *)0, 3), new TGTableLayoutHints(1, 2, 2, 3,
2125  kLHintsCenterY, 5, 5, 0, 0));
2126  // add "Browse" button
2127  AddFrame(btnTmp = new TGTextButton(this, "Browse..."),
2128  new TGTableLayoutHints(2, 3, 2, 3, kLHintsCenterY, 5, 0, 0, 8));
2129  btnTmp->Connect("Clicked()", "TEditQueryFrame", this, "OnBrowseSelector()");
2130 
2131  // add "Less <<" ("More >>") button
2132  AddFrame(fBtnMore = new TGTextButton(this, " Less << "),
2133  new TGTableLayoutHints(2, 3, 4, 5, kLHintsCenterY, 5, 5, 4, 0));
2134  fBtnMore->Connect("Clicked()", "TEditQueryFrame", this, "OnNewQueryMore()");
2135 
2136  // add (initially hidden) options frame
2137  fFrmMore = new TGCompositeFrame(this, 200, 200);
2139 
2140  AddFrame(fFrmMore, new TGTableLayoutHints(0, 3, 5, 6,
2143 
2144  // add "Options" label and text entry
2145  fFrmMore->AddFrame(new TGLabel(fFrmMore, "Options :"),
2146  new TGTableLayoutHints(0, 1, 0, 1, kLHintsCenterY, 5, 5, 0, 0));
2148  (const char *)0, 4), new TGTableLayoutHints(1, 2, 0, 1, 0, 17,
2149  0, 0, 8));
2150  //fTxtOptions->SetText("ASYN");
2151  fTxtOptions->SetText("");
2152 
2153  // add "Nb Entries" label and number entry
2154  fFrmMore->AddFrame(new TGLabel(fFrmMore, "Nb Entries :"),
2155  new TGTableLayoutHints(0, 1, 1, 2, kLHintsCenterY, 5, 5, 0, 0));
2159  0, 17, 0, 0, 8));
2160  // coverity[negative_returns]: no problem with -1, the format is kNESInteger
2162  // add "First Entry" label and number entry
2163  fFrmMore->AddFrame(new TGLabel(fFrmMore, "First entry :"),
2164  new TGTableLayoutHints(0, 1, 2, 3, kLHintsCenterY, 5, 5, 0, 0));
2168  17, 0, 0, 8));
2169 
2170  // add "Event list" label and text entry
2171  fFrmMore->AddFrame(new TGLabel(fFrmMore, "Event list :"),
2172  new TGTableLayoutHints(0, 1, 3, 4, kLHintsCenterY, 5, 5, 0, 0));
2174  (const char *)0, 6), new TGTableLayoutHints(1, 2, 3, 4, 0, 17,
2175  5, 0, 0));
2176  // add "Browse" button
2177  fFrmMore->AddFrame(btnTmp = new TGTextButton(fFrmMore, "Browse..."),
2178  new TGTableLayoutHints(2, 3, 3, 4, 0, 6, 0, 0, 8));
2179  btnTmp->Connect("Clicked()", "TEditQueryFrame", this, "OnBrowseEventList()");
2180 
2181  fTxtQueryName->Associate(this);
2182  fTxtChain->Associate(this);
2183  fTxtSelector->Associate(this);
2184  fTxtOptions->Associate(this);
2185  fNumEntries->Associate(this);
2186  fNumFirstEntry->Associate(this);
2187  fTxtEventList->Associate(this);
2188 
2189  fTxtQueryName->Connect("TextChanged(char*)", "TEditQueryFrame", this,
2190  "SettingsChanged()");
2191  fTxtChain->Connect("TextChanged(char*)", "TEditQueryFrame", this,
2192  "SettingsChanged()");
2193  fTxtSelector->Connect("TextChanged(char*)", "TEditQueryFrame", this,
2194  "SettingsChanged()");
2195  fTxtOptions->Connect("TextChanged(char*)", "TEditQueryFrame", this,
2196  "SettingsChanged()");
2197  fNumEntries->Connect("ValueChanged(Long_t)", "TEditQueryFrame", this,
2198  "SettingsChanged()");
2199  fNumFirstEntry->Connect("ValueChanged(Long_t)", "TEditQueryFrame", this,
2200  "SettingsChanged()");
2201  fTxtEventList->Connect("TextChanged(char*)", "TEditQueryFrame", this,
2202  "SettingsChanged()");
2203 }
2204 
2205 ////////////////////////////////////////////////////////////////////////////////
2206 /// Show/hide options frame and update button text accordingly.
2207 
2209 {
2210  if (IsVisible(fFrmMore)) {
2212  fBtnMore->SetText(" More >> ");
2213  }
2214  else {
2216  fBtnMore->SetText(" Less << ");
2217  }
2218 }
2219 
2220 ////////////////////////////////////////////////////////////////////////////////
2221 /// Call new chain dialog.
2222 
2224 {
2225  TNewChainDlg *dlg = new TNewChainDlg(fClient->GetRoot(), this);
2226  dlg->Connect("OnElementSelected(TObject *)", "TEditQueryFrame",
2227  this, "OnElementSelected(TObject *)");
2228 }
2229 
2230 ////////////////////////////////////////////////////////////////////////////////
2231 /// Handle OnElementSelected signal coming from new chain dialog.
2232 
2234 {
2235  if (obj) {
2236  fChain = obj;
2237  if (obj->IsA() == TChain::Class())
2239  else if (obj->IsA() == TDSet::Class())
2240  fTxtChain->SetText(((TDSet *)fChain)->GetObjName());
2241  }
2242 }
2243 
2244 ////////////////////////////////////////////////////////////////////////////////
2245 /// Open file browser to choose selector macro.
2246 
2248 {
2249  TGFileInfo fi;
2250  fi.fFileTypes = macrotypes;
2251  new TGFileDialog(fClient->GetRoot(), this, kFDOpen, &fi);
2252  if (!fi.fFilename) return;
2254 }
2255 
2256 ////////////////////////////////////////////////////////////////////////////////
2257 ///Browse event list
2258 
2260 {
2261 }
2262 
2263 ////////////////////////////////////////////////////////////////////////////////
2264 /// Save current settings in main session viewer.
2265 
2267 {
2268  // if we are in edition mode and query description is valid,
2269  // use it, otherwise create a new one
2270  TQueryDescription *newquery;
2271  if (fQuery)
2272  newquery = fQuery;
2273  else
2274  newquery = new TQueryDescription();
2275 
2276  // update query description fields
2277  newquery->fSelectorString = fTxtSelector->GetText();
2278  if (fChain) {
2279  newquery->fTDSetString = fChain->GetName();
2280  newquery->fChain = fChain;
2281  }
2282  else {
2283  newquery->fTDSetString = "";
2284  newquery->fChain = 0;
2285  }
2286  newquery->fQueryName = fTxtQueryName->GetText();
2287  newquery->fOptions = fTxtOptions->GetText();
2288  newquery->fNoEntries = fNumEntries->GetIntNumber();
2289  newquery->fFirstEntry = fNumFirstEntry->GetIntNumber();
2290  newquery->fNbFiles = 0;
2291  newquery->fResult = 0;
2292 
2293  if (newquery->fChain) {
2294  if (newquery->fChain->IsA() == TChain::Class())
2295  newquery->fNbFiles = ((TChain *)newquery->fChain)->GetListOfFiles()->GetEntriesFast();
2296  else if (newquery->fChain->IsA() == TDSet::Class())
2297  newquery->fNbFiles = ((TDSet *)newquery->fChain)->GetListOfElements()->GetSize();
2298  }
2299  // update user data with modified query description
2301  fViewer->GetSessionHierarchy()->RenameItem(item, newquery->fQueryName);
2302  item->SetUserData(newquery);
2303  // update list tree
2310  if (fViewer->GetActDesc()->fLocal ||
2311  (fViewer->GetActDesc()->fConnected &&
2313  fViewer->GetActDesc()->fProof &&
2314  fViewer->GetActDesc()->fProof->IsValid())) {
2315  fViewer->GetQueryFrame()->GetTab()->SetTab("Status");
2317  }
2318 }
2319 
2320 ////////////////////////////////////////////////////////////////////////////////
2321 /// Settings have changed, update GUI accordingly.
2322 
2324 {
2325  if (fQuery) {
2326  if ((strcmp(fQuery->fSelectorString.Data(), fTxtSelector->GetText())) ||
2327  (strcmp(fQuery->fQueryName.Data(), fTxtQueryName->GetText())) ||
2328  (strcmp(fQuery->fOptions.Data(), fTxtOptions->GetText())) ||
2331  (fQuery->fChain != fChain)) {
2333  }
2334  else {
2336  }
2337  }
2338  else {
2339  if ((fTxtQueryName->GetText()) &&
2340  ((fTxtQueryName->GetText()) ||
2341  (fTxtChain->GetText())))
2343  else
2345  }
2346 }
2347 
2348 ////////////////////////////////////////////////////////////////////////////////
2349 /// Update entry fields with query description values.
2350 
2352 {
2353  fChain = 0;
2354  fQuery = desc;
2355  fTxtChain->SetText("");
2356  if (desc->fChain) {
2357  fChain = desc->fChain;
2358  fTxtChain->SetText(desc->fTDSetString);
2359  }
2362  fTxtOptions->SetText(desc->fOptions);
2366 }
2367 
2368 ////////////////////////////////////////////////////////////////////////////////
2369 // Query Frame
2370 
2371 ////////////////////////////////////////////////////////////////////////////////
2372 /// Constructor
2373 
2375  TGCompositeFrame(p, w, h), fBtnSubmit(0), fBtnFinalize(0), fBtnStop(0),
2376  fBtnAbort(0), fBtnShowLog(0), fBtnRetrieve(0), fBtnSave(0), fInfoTextView(0),
2377  fModified(0), fFiles(0), fFirst(0), fEntries(0), fPrevTotal(0),
2378  fPrevProcessed(0), fLabInfos(0), fLabStatus(0), fTotal(0), fRate(0),
2379  fStatus(kStopped), fTab(0), fFA(0), fFB(0), fFC(0), fFD(0), frmProg(0),
2380  fECanvas(0), fStatsCanvas(0), fViewer(0), fDesc(0)
2381 {
2382 }
2383 
2384 ////////////////////////////////////////////////////////////////////////////////
2385 /// Destructor.
2386 
2388 {
2389  Cleanup();
2390 }
2391 
2392 ////////////////////////////////////////////////////////////////////////////////
2393 /// Build query information frame.
2394 
2396 {
2399  fFirst = fEntries = fPrevTotal = 0;
2400  fPrevProcessed = 0;
2401  fViewer = gui;
2402  fModified = kFALSE;
2403 
2404  // main query tab
2405  fTab = new TGTab(this, 200, 200);
2407  kLHintsExpandY, 2, 2, 2, 2));
2408 
2409  // add "Status" tab element
2410  TGCompositeFrame *tf = fTab->AddTab("Status");
2411  fFB = new TGCompositeFrame(tf, 100, 100, kVerticalFrame);
2414 
2415  // new frame containing control buttons and feedback histos canvas
2416  TGCompositeFrame* frmcanvas = new TGHorizontalFrame(fFB, 350, 100);
2417  // control buttons frame
2418  TGCompositeFrame* frmBut2 = new TGVerticalFrame(frmcanvas, 150, 100);
2419  fBtnSubmit = new TGTextButton(frmBut2, " Submit ");
2420  fBtnSubmit->SetToolTipText("Submit (process) selected query");
2422  kLHintsExpandX, 5, 5, 5, 5));
2423  fBtnStop = new TGTextButton(frmBut2, "Stop");
2424  fBtnStop->SetToolTipText("Stop processing query");
2426  kLHintsExpandX, 5, 5, 5, 5));
2427  fBtnAbort = new TGTextButton(frmBut2, "Abort");
2428  fBtnAbort->SetToolTipText("Abort processing query");
2430  kLHintsExpandX, 5, 5, 5, 5));
2431  frmcanvas->AddFrame(frmBut2, new TGLayoutHints(kLHintsLeft | kLHintsCenterY |
2432  kLHintsExpandY));
2433  // feedback histos embedded canvas
2434  fECanvas = new TRootEmbeddedCanvas("fECanvas", frmcanvas, 400, 150);
2436  fStatsCanvas->SetFillColor(10);
2439  4, 4, 4, 4));
2440  fFB->AddFrame(frmcanvas, new TGLayoutHints(kLHintsLeft | kLHintsTop |
2442 
2443  // progress infos label
2444  fLabInfos = new TGLabel(fFB, " ");
2445  fFB->AddFrame(fLabInfos, new TGLayoutHints(kLHintsLeft, 5, 5, 5, 5));
2446  // progress status label
2447  fLabStatus = new TGLabel(fFB, " ");
2448  fFB->AddFrame(fLabStatus, new TGLayoutHints(kLHintsLeft, 5, 5, 5, 5));
2449 
2450  //progress bar
2451  frmProg = new TGHProgressBar(fFB, TGProgressBar::kFancy, 350 - 20);
2452  frmProg->ShowPosition();
2453  frmProg->SetBarColor("green");
2454  fFB->AddFrame(frmProg, new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5));
2455  // total progress infos
2456  fFB->AddFrame(fTotal = new TGLabel(fFB,
2457  " Estimated time left : 0 sec (--- events of --- processed) "),
2458  new TGLayoutHints(kLHintsLeft, 5, 5, 5, 5));
2459  // progress rate infos
2460  fFB->AddFrame(fRate = new TGLabel(fFB,
2461  " Processing Rate : -- events/sec "),
2462  new TGLayoutHints(kLHintsLeft, 5, 5, 5, 5));
2463 
2464  // add "Results" tab element
2465  tf = fTab->AddTab("Results");
2466  fFC = new TGCompositeFrame(tf, 100, 100, kVerticalFrame);
2469  // query result (header) information text view
2470  fInfoTextView = new TGTextView(fFC, 330, 185, "", kSunkenFrame |
2471  kDoubleBorder);
2473  kLHintsExpandY | kLHintsExpandX, 5, 5, 10, 10));
2474 
2475  // add "Retrieve", "Finalize" and "Show Log" buttons
2476  TGCompositeFrame* frmBut3 = new TGHorizontalFrame(fFC, 350, 100);
2477  fBtnRetrieve = new TGTextButton(frmBut3, "Retrieve");
2478  fBtnRetrieve->SetToolTipText("Retrieve query results");
2480  kLHintsExpandX, 5, 5, 10, 10));
2481  fBtnFinalize = new TGTextButton(frmBut3, "Finalize");
2482  fBtnFinalize->SetToolTipText("Finalize query");
2484  kLHintsExpandX, 5, 5, 10, 10));
2485  fBtnShowLog = new TGTextButton(frmBut3, "Show Log");
2486  fBtnShowLog->SetToolTipText("Show query log (open log window)");
2488  kLHintsExpandX, 5, 5, 10, 10));
2490 
2491  // add "Results" tab element
2492  tf = fTab->AddTab("Edit Query");
2493  fFD = new TEditQueryFrame(tf, 100, 100);
2494  fFD->Build(fViewer);
2495  tf->AddFrame(fFD, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 10, 0));
2496  TString btntxt;
2497  if (fViewer->GetActDesc()->fLocal ||
2498  (fViewer->GetActDesc()->fProof &&
2499  fViewer->GetActDesc()->fProof->IsValid())) {
2500  btntxt = " Submit ";
2501  }
2502  else {
2503  btntxt = " Apply changes ";
2504  }
2505  tf->AddFrame(fBtnSave = new TGTextButton(tf, btntxt),
2506  new TGLayoutHints(kLHintsTop | kLHintsLeft, 10, 5, 25, 5));
2507 
2508  // connect button actions to functions
2509  fBtnSave->Connect("Clicked()", "TEditQueryFrame", fFD,
2510  "OnBtnSave()");
2511  fBtnSubmit->Connect("Clicked()", "TSessionQueryFrame", this,
2512  "OnBtnSubmit()");
2513  fBtnFinalize->Connect("Clicked()", "TSessionQueryFrame", this,
2514  "OnBtnFinalize()");
2515  fBtnStop->Connect("Clicked()", "TSessionQueryFrame", this,
2516  "OnBtnStop()");
2517  fBtnAbort->Connect("Clicked()", "TSessionQueryFrame", this,
2518  "OnBtnAbort()");
2519  fBtnShowLog->Connect("Clicked()", "TSessionQueryFrame", this,
2520  "OnBtnShowLog()");
2521  fBtnRetrieve->Connect("Clicked()", "TSessionQueryFrame", this,
2522  "OnBtnRetrieve()");
2523 // fBtnSave->SetState(kButtonDisabled);
2524  Resize(350, 310);
2525 }
2526 
2527 ////////////////////////////////////////////////////////////////////////////////
2528 /// Notify changes in query editor settings.
2529 
2531 {
2532  fModified = mod;
2533  if (fModified) {
2535  }
2536  else {
2538  }
2539  if (fViewer->GetActDesc()->fLocal ||
2540  (fViewer->GetActDesc()->fProof &&
2541  fViewer->GetActDesc()->fProof->IsValid()))
2543 }
2544 
2545 ////////////////////////////////////////////////////////////////////////////////
2546 /// Feedback function connected to Feedback signal.
2547 /// Used to update feedback histograms.
2548 
2550 {
2551  // if no actual session, just return
2552  if (!fViewer->GetActDesc()->fAttached)
2553  return;
2554  if (!fViewer->GetActDesc()->fProof)
2555  return;
2556  if ((fViewer->GetActDesc()->fActQuery) &&
2561  return;
2562  TProof *sender = dynamic_cast<TProof*>((TQObject*)gTQSender);
2563  // if Proof sender match actual session one, update feedback histos
2564  if (sender && (sender == fViewer->GetActDesc()->fProof))
2565  UpdateHistos(objs);
2566 }
2567 
2568 ////////////////////////////////////////////////////////////////////////////////
2569 /// Update feedback histograms.
2570 
2572 {
2573  TVirtualPad *save = gPad;
2574  TObject *o;
2575  Int_t pos = 1;
2576  Int_t i = 0;
2577  while (kFeedbackHistos[i]) {
2578  // check if user has selected this histogram in the option menu
2579  if (fViewer->GetCascadeMenu()->IsEntryChecked(41+i)) {
2580  if ( (o = objs->FindObject(kFeedbackHistos[i]))) {
2581  fStatsCanvas->cd(pos);
2582  gPad->SetEditable(kTRUE);
2583  if (TH1 *h = dynamic_cast<TH1*>(o)) {
2584  h->SetStats(0);
2585  h->SetBarWidth(0.75);
2586  h->SetBarOffset(0.125);
2587  h->SetFillColor(9);
2588  h->Draw("bar");
2589  pos++;
2590  }
2591  else if (TH2 *h2 = dynamic_cast<TH2*>(o)) {
2592  h2->Draw();
2593  pos++;
2594  }
2595  gPad->Modified();
2596  }
2597  }
2598  i++;
2599  }
2600  // update canvas
2601  fStatsCanvas->cd();
2603  fStatsCanvas->Update();
2604  if (save != 0) {
2605  save->cd();
2606  } else {
2607  gPad = 0;
2608  }
2609 }
2610 
2611 ////////////////////////////////////////////////////////////////////////////////
2612 /// Update progress bar and status labels.
2613 
2615 {
2616  Long_t tt;
2617  UInt_t hh=0, mm=0, ss=0;
2618  TString stm;
2619  // if no actual session, just return
2620  if (!fViewer->GetActDesc()->fProof)
2621  return;
2622  // if Proof sender does't match actual session one, return
2623  TProof *sender = dynamic_cast<TProof*>((TQObject*)gTQSender);
2624  if (!sender || (sender != fViewer->GetActDesc()->fProof))
2625  return;
2626 
2627  if ((fViewer->GetActDesc()->fActQuery) &&
2632  fTotal->SetText(" Estimated time left : 0 sec (0 events of 0 processed) ");
2633  fRate->SetText(" Processing Rate : 0.0f events/sec ");
2634  frmProg->Reset();
2635  fFB->Layout();
2636  return;
2637  }
2638 
2639  if (total < 0)
2640  total = fPrevTotal;
2641  else
2642  fPrevTotal = total;
2643 
2644  // if no change since last call, just return
2645  if (fPrevProcessed == processed)
2646  return;
2647  TString buf;
2648 
2649  // Update information at first call
2650  if (fEntries != total) {
2651  buf.Form("PROOF cluster : \"%s\" - %d worker nodes",
2654  fLabInfos->SetText(buf);
2655 
2656  fEntries = total;
2657  buf.Form(" %d files, %lld events, starting event %lld",
2658  fFiles, fEntries, fFirst);
2659  fLabStatus->SetText(buf);
2660  }
2661 
2662  // compute progress bar position and update
2663  Float_t pos = (Float_t)((Double_t)(processed * 100)/(Double_t)total);
2664  frmProg->SetPosition(pos);
2665  // if 100%, stop animation and set icon to "connected"
2666  if (pos >= 100.0) {
2668  fViewer->ChangeRightLogo("monitor01.xpm");
2669  }
2670 
2671  // get current time
2672  if ((fViewer->GetActDesc()->fActQuery->fStatus ==
2677  TTime tdiff = fViewer->GetActDesc()->fActQuery->fEndTime -
2679  Float_t eta = 0;
2680  if (processed)
2681  eta = ((Float_t)((Long64_t)tdiff)*total/Float_t(processed) -
2682  Long64_t(tdiff))/1000.;
2683 
2684  tt = (Long_t)eta;
2685  if (tt > 0) {
2686  hh = (UInt_t)(tt / 3600);
2687  mm = (UInt_t)((tt % 3600) / 60);
2688  ss = (UInt_t)((tt % 3600) % 60);
2689  }
2690  if (hh)
2691  stm.Form("%d h %d min %d sec", hh, mm, ss);
2692  else if (mm)
2693  stm.Form("%d min %d sec", mm, ss);
2694  else
2695  stm.Form("%d sec", ss);
2696  if (processed == total) {
2697  // finished
2698  tt = (Long_t) Long64_t(tdiff)/1000;
2699  if (tt > 0) {
2700  hh = (UInt_t)(tt / 3600);
2701  mm = (UInt_t)((tt % 3600) / 60);
2702  ss = (UInt_t)((tt % 3600) % 60);
2703  }
2704  if (hh)
2705  stm.Form("%d h %d min %d sec", hh, mm, ss);
2706  else if (mm)
2707  stm.Form("%d min %d sec", mm, ss);
2708  else
2709  stm.Form("%d sec", ss);
2710  buf.Form(" Processed : %lld events in %s", total, stm.Data());
2711  fTotal->SetText(buf.Data());
2712  } else {
2713  // update status infos
2714  buf.Form(" Estimated time left : %s (%lld events of %lld processed) ",
2715  stm.Data(), processed, total);
2716  fTotal->SetText(buf.Data());
2717  }
2718  if (processed > 0 && (Long64_t)tdiff > 0) {
2719  buf.Form(" Processing Rate : %.1f events/sec ",
2720  (Float_t)processed/(Long64_t)tdiff*1000.);
2721  fRate->SetText(buf);
2722  }
2723  fPrevProcessed = processed;
2724 
2725  fFB->Layout();
2726 }
2727 
2728 ////////////////////////////////////////////////////////////////////////////////
2729 /// New version of Progress (just forward to the old version
2730 /// for the time being).
2731 
2733  Long64_t /*bytesread*/, Float_t /*initTime*/,
2734  Float_t /*procTime*/, Float_t /*evtrti*/,
2735  Float_t /*mbrti*/, Int_t /*actw*/,
2736  Int_t /*tses*/, Float_t /*eses*/)
2737 {
2738  Progress(total, processed);
2739 }
2740 
2741 ////////////////////////////////////////////////////////////////////////////////
2742 /// Update progress bar and status labels.
2743 
2745 {
2746  Long_t tt;
2747  UInt_t hh=0, mm=0, ss=0;
2748  TString stm;
2749  TString cproc;
2750  Int_t status;
2751 
2752  switch (fViewer->GetActDesc()->fActQuery->fStatus) {
2753 
2755  cproc = " - ABORTED";
2756  status = kAborted;
2757  break;
2759  cproc = " - STOPPED";
2760  status = kStopped;
2761  break;
2763  cproc = " ";
2764  status = kRunning;
2765  break;
2768  cproc = " ";
2769  status = kDone;
2770  break;
2771  default:
2772  status = -1;
2773  break;
2774  }
2775  if (processed < 0) processed = 0;
2776 
2777  frmProg->SetBarColor("green");
2778  if (status == kAborted)
2779  frmProg->SetBarColor("red");
2780  else if (status == kStopped)
2781  frmProg->SetBarColor("yellow");
2782  else if (status == -1 ) {
2783  fTotal->SetText(" Estimated time left : 0 sec (0 events of 0 processed) ");
2784  fRate->SetText(" Processing Rate : 0.0f events/sec ");
2785  frmProg->Reset();
2786  fFB->Layout();
2787  return;
2788  }
2789 
2790  if (total < 0)
2791  total = fPrevTotal;
2792  else
2793  fPrevTotal = total;
2794 
2795  // if no change since last call, just return
2796  TString buf;
2797 
2798  // Update information at first call
2799  if (fEntries != total) {
2800  fLabInfos->SetText("Local Session");
2801 
2802  fEntries = total;
2803  buf.Form(" %d files, %lld events, starting event %lld",
2804  fFiles, fEntries, fFirst);
2805  fLabStatus->SetText(buf.Data());
2806  }
2807 
2808  // compute progress bar position and update
2809  Float_t pos = 0.0;
2810  if (processed > 0 && total > 0)
2811  pos = (Float_t)((Double_t)(processed * 100)/(Double_t)total);
2812  frmProg->SetPosition(pos);
2813  // if 100%, stop animation and set icon to "connected"
2814  if (pos >= 100.0) {
2816  fViewer->ChangeRightLogo("monitor01.xpm");
2817  }
2818 
2819  // get current time
2820  if (status == kRunning)
2822  TTime tdiff = fViewer->GetActDesc()->fActQuery->fEndTime -
2824  Float_t eta = 0;
2825  if (processed)
2826  eta = ((Float_t)((Long64_t)tdiff)*total/(Float_t)(processed) -
2827  (Long64_t)(tdiff))/1000.;
2828 
2829  tt = (Long_t)eta;
2830  if (tt > 0) {
2831  hh = (UInt_t)(tt / 3600);
2832  mm = (UInt_t)((tt % 3600) / 60);
2833  ss = (UInt_t)((tt % 3600) % 60);
2834  }
2835  if (hh)
2836  stm = TString::Format("%d h %d min %d sec", hh, mm, ss);
2837  else if (mm)
2838  stm = TString::Format("%d min %d sec", mm, ss);
2839  else
2840  stm = TString::Format("%d sec", ss);
2841  if ((processed != total) && (status == kRunning)) {
2842  // update status infos
2843  buf.Form(" Estimated time left : %s (%lld events of %lld processed) ",
2844  stm.Data(), processed, total);
2845  fTotal->SetText(buf);
2846  } else {
2847  tt = (Long_t) Long64_t(tdiff)/1000;
2848  if (tt > 0) {
2849  hh = (UInt_t)(tt / 3600);
2850  mm = (UInt_t)((tt % 3600) / 60);
2851  ss = (UInt_t)((tt % 3600) % 60);
2852  }
2853  if (hh)
2854  stm = TString::Format("%d h %d min %d sec", hh, mm, ss);
2855  else if (mm)
2856  stm = TString::Format("%d min %d sec", mm, ss);
2857  else
2858  stm = TString::Format("%d sec", ss);
2859  buf.Form(" Processed : %ld events in %s",
2860  (Long_t)processed, stm.Data());
2861  buf += cproc;
2862  fTotal->SetText(buf.Data());
2863  }
2864  if (processed > 0 && (Long64_t)tdiff > 0) {
2865  buf.Form(" Processing Rate : %.1f events/sec ",
2866  (Float_t)processed/(Long64_t)tdiff*1000.);
2867  fRate->SetText(buf.Data());
2868  }
2869  fPrevProcessed = processed;
2870 
2871  fFB->Layout();
2872 }
2873 
2874 ////////////////////////////////////////////////////////////////////////////////
2875 /// Indicate that Cancel or Stop was clicked.
2876 
2878 {
2879  if (aborted == kTRUE) {
2880  // Aborted
2881  frmProg->SetBarColor("red");
2882  }
2883  else {
2884  // Stopped
2885  frmProg->SetBarColor("yellow");
2886  }
2887  // disconnect progress related signals
2888  if (fViewer->GetActDesc()->fProof &&
2889  fViewer->GetActDesc()->fProof->IsValid()) {
2890  fViewer->GetActDesc()->fProof->Disconnect("Progress(Long64_t,Long64_t)",
2891  this, "Progress(Long64_t,Long64_t)");
2892  fViewer->GetActDesc()->fProof->Disconnect("Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)",
2893  this, "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)");
2894  fViewer->GetActDesc()->fProof->Disconnect("Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t,Int_t,Int_t,Float_t)",
2895  this, "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t,Int_t,Int_t,Float_t)");
2896  fViewer->GetActDesc()->fProof->Disconnect("StopProcess(Bool_t)", this,
2897  "IndicateStop(Bool_t)");
2898  }
2899 }
2900 
2901 ////////////////////////////////////////////////////////////////////////////////
2902 /// Reset progress frame information fields.
2903 
2904 void TSessionQueryFrame::ResetProgressDialog(const char * /*selector*/, Int_t files,
2905  Long64_t first, Long64_t entries)
2906 {
2907  TString buf;
2908  fFiles = files > 0 ? files : 0;
2909  fFirst = first;
2910  fEntries = entries;
2911  fPrevProcessed = 0;
2912  fPrevTotal = 0;
2913 
2914  if (!fViewer->GetActDesc()->fLocal) {
2915  frmProg->SetBarColor("green");
2916  frmProg->Reset();
2917  }
2918 
2919  buf.Form("%0d files, %0lld events, starting event %0lld",
2920  fFiles > 0 ? fFiles : 0, fEntries > 0 ? fEntries : 0,
2921  fFirst >= 0 ? fFirst : 0);
2922  fLabStatus->SetText(buf.Data());
2923  // Reconnect the slots
2924  if (fViewer->GetActDesc()->fProof &&
2925  fViewer->GetActDesc()->fProof->IsValid()) {
2926  fViewer->GetActDesc()->fProof->Connect("Progress(Long64_t,Long64_t)",
2927  "TSessionQueryFrame", this, "Progress(Long64_t,Long64_t)");
2928  fViewer->GetActDesc()->fProof->Connect("Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)",
2929  "TSessionQueryFrame", this,
2930  "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)");
2931  fViewer->GetActDesc()->fProof->Connect("StopProcess(Bool_t)",
2932  "TSessionQueryFrame", this, "IndicateStop(Bool_t)");
2933  buf.Form("PROOF cluster : \"%s\" - %d worker nodes",
2936  fLabInfos->SetText(buf.Data());
2937  }
2938  else if (fViewer->GetActDesc()->fLocal) {
2939  fStatsCanvas->Clear();
2940  fLabInfos->SetText("Local Session");
2941  fLabStatus->SetText(" ");
2942  }
2943  else {
2944  fLabInfos->SetText(" ");
2945  fLabStatus->SetText(" ");
2946  }
2947  fFB->Layout();
2948 }
2949 
2950 ////////////////////////////////////////////////////////////////////////////////
2951 /// Finalize query.
2952 
2954 {
2955  // check if Proof is valid
2956  if (fViewer->GetActDesc()->fProof &&
2957  fViewer->GetActDesc()->fProof->IsValid()) {
2958  gPad->SetEditable(kFALSE);
2960  if (!item) return;
2961  TObject *obj = (TObject *)item->GetUserData();
2962  if ((obj) && (obj->IsA() == TQueryDescription::Class())) {
2963  // as it can take time, set watch cursor
2964  gVirtualX->SetCursor(GetId(),gVirtualX->CreateCursor(kWatch));
2965  TQueryDescription *query = (TQueryDescription *)obj;
2967  UpdateButtons(query);
2968  // restore cursor
2969  gVirtualX->SetCursor(GetId(), 0);
2970  }
2971  }
2972  if (fViewer->GetActDesc()->fLocal) {
2973  gPad->SetEditable(kFALSE);
2974  TChain *chain = (TChain *)fViewer->GetActDesc()->fActQuery->fChain;
2975  if (chain && chain->GetPlayer())
2976  chain->GetPlayer()->GetSelectorFromFile()->Terminate();
2977  }
2978 }
2979 
2980 ////////////////////////////////////////////////////////////////////////////////
2981 /// Stop processing query.
2982 
2984 {
2985  // check for proof validity
2986  if (fViewer->GetActDesc()->fProof &&
2987  fViewer->GetActDesc()->fProof->IsValid()) {
2989  }
2990  if (fViewer->GetActDesc()->fLocal) {
2991  gROOT->SetInterrupt();
2994  }
2995  // stop icon animation and set connected icon
2996  fViewer->ChangeRightLogo("monitor01.xpm");
2998 }
2999 
3000 ////////////////////////////////////////////////////////////////////////////////
3001 /// Show query log.
3002 
3004 {
3006  if (!item) return;
3007  TObject *obj = (TObject *)item->GetUserData();
3008  if ((!obj) || (obj->IsA() != TQueryDescription::Class()))
3009  return;
3010  TQueryDescription *query = (TQueryDescription *)obj;
3011  fViewer->ShowLog(query->fReference.Data());
3012 }
3013 
3014 ////////////////////////////////////////////////////////////////////////////////
3015 /// Retrieve query.
3016 
3018 {
3019  // check for proof validity
3020  if (fViewer->GetActDesc()->fAttached &&
3021  fViewer->GetActDesc()->fProof &&
3022  fViewer->GetActDesc()->fProof->IsValid()) {
3024  if (!item) return;
3025  TObject *obj = (TObject *)item->GetUserData();
3026  if (obj && obj->IsA() == TQueryDescription::Class()) {
3027  // as it can take time, set watch cursor
3028  gVirtualX->SetCursor(GetId(), gVirtualX->CreateCursor(kWatch));
3029  TQueryDescription *query = (TQueryDescription *)obj;
3030  Int_t rc = fViewer->GetActDesc()->fProof->Retrieve(query->fReference);
3031  if (rc == 0)
3033  // restore cursor
3034  gVirtualX->SetCursor(GetId(), 0);
3035  }
3036  }
3037  if (fViewer->GetActDesc()->fLocal) {
3038  TGListTreeItem *item=0, *item2=0;
3040  fViewer->GetActDesc());
3041  if (item) {
3042  item2 = fViewer->GetSessionHierarchy()->FindItemByObj(item,
3044  }
3045  if (item2) {
3046  // add input and output list entries
3047  TChain *chain = (TChain *)fViewer->GetActDesc()->fActQuery->fChain;
3048  if (chain && chain->GetPlayer()) {
3049  TSelector *selector = chain->GetPlayer()->GetSelectorFromFile();
3050  if (selector) {
3051  TList *objlist = selector->GetOutputList();
3052  if (objlist)
3053  if (!fViewer->GetSessionHierarchy()->FindChildByName(item2, "OutputList"))
3054  fViewer->GetSessionHierarchy()->AddItem(item2, "OutputList");
3055  }
3056  }
3057  }
3058  // update list tree, query frame information, and buttons state
3061  UpdateInfos();
3063  }
3064 }
3065 
3066 ////////////////////////////////////////////////////////////////////////////////
3067 /// Abort processing query.
3068 
3070 {
3071  // check for proof validity
3072  if (fViewer->GetActDesc()->fProof &&
3073  fViewer->GetActDesc()->fProof->IsValid()) {
3075  }
3076  if (fViewer->GetActDesc()->fLocal) {
3077  gROOT->SetInterrupt();
3080  }
3081  // stop icon animation and set connected icon
3082  fViewer->ChangeRightLogo("monitor01.xpm");
3084 }
3085 
3086 ////////////////////////////////////////////////////////////////////////////////
3087 /// Submit query.
3088 
3090 {
3091  Int_t retval;
3092  Long64_t id = 0;
3094  if (!item) return;
3095  // retrieve query description attached to list tree item
3096  TObject *obj = (TObject *)item->GetUserData();
3097  if (!obj || obj->IsA() != TQueryDescription::Class())
3098  return;
3099  TQueryDescription *newquery = (TQueryDescription *)obj;
3100  // reset progress information
3102  newquery->fNbFiles, newquery->fFirstEntry, newquery->fNoEntries);
3103  // set query start time
3104  newquery->fStartTime = gSystem->Now();
3105  fViewer->GetActDesc()->fNbHistos = 0;
3106  // check for proof validity
3107  if (fViewer->GetActDesc()->fProof &&
3108  fViewer->GetActDesc()->fProof->IsValid()) {
3110  // set query description status to submitted
3112  // if feedback option selected
3114  Int_t i = 0;
3115  // browse list of feedback histos and check user's selected ones
3116  while (kFeedbackHistos[i]) {
3117  if (fViewer->GetCascadeMenu()->IsEntryChecked(41+i)) {
3120  }
3121  i++;
3122  }
3123  // connect feedback signal
3124  fViewer->GetActDesc()->fProof->Connect("Feedback(TList *objs)",
3125  "TSessionQueryFrame", fViewer->GetQueryFrame(),
3126  "Feedback(TList *objs)");
3127  gROOT->Time();
3128  }
3129  else {
3130  // if feedback option not selected, clear Proof's feedback option
3132  }
3133  // set current proof session
3134  fViewer->GetActDesc()->fProof->cd();
3135  // check if parameter file has been specified
3136  if (newquery->fChain) {
3137  if (fViewer->GetActDesc()->fProof->IsLite()) {
3138  newquery->fOptions = "";
3139  }
3140  // set query reference id
3141  newquery->fReference= TString::Format("session-%s:q%d",
3143  fViewer->GetActDesc()->fProof->GetSeqNum()+1);
3144  if (newquery->fChain->IsA() == TChain::Class()) {
3145  // TChain case
3147  ((TChain *)newquery->fChain)->SetProof(fViewer->GetActDesc()->fProof);
3148  id = ((TChain *)newquery->fChain)->Process(newquery->fSelectorString,
3149  newquery->fOptions,
3150  newquery->fNoEntries > 0 ? newquery->fNoEntries : 1234567890,
3151  newquery->fFirstEntry);
3152  }
3153  else if (newquery->fChain->IsA() == TDSet::Class()) {
3154  // TDSet case
3156  id = ((TDSet *)newquery->fChain)->Process(newquery->fSelectorString,
3157  newquery->fOptions,
3158  newquery->fNoEntries,
3159  newquery->fFirstEntry);
3160  }
3161  }
3162  else {
3163  Error("Submit", "No TChain defined; skipping");
3165  return;
3166  }
3167  // set query reference id to unique identifier
3168  newquery->fReference= TString::Format("session-%s:q%lld",
3169  fViewer->GetActDesc()->fProof->GetSessionTag(), id);
3170  // start icon animation
3172  }
3173  else if (fViewer->GetActDesc()->fLocal) { // local session case
3174  // if feedback option selected
3176  Int_t i = 0;
3177  // browse list of feedback histos and check user's selected ones
3178  while (kFeedbackHistos[i]) {
3179  if (fViewer->GetCascadeMenu()->IsEntryChecked(41+i)) {
3181  }
3182  i++;
3183  }
3184  }
3185  if (newquery->fChain) {
3186  if (newquery->fChain->IsA() == TChain::Class()) {
3187  // TChain case
3189  fViewer->EnableTimer();
3190  UpdateButtons(newquery);
3191  gPad->SetEditable(kFALSE);
3192  ((TChain *)newquery->fChain)->SetTimerInterval(100);
3193  id = ((TChain *)newquery->fChain)->Process(newquery->fSelectorString,
3194  newquery->fOptions,
3195  newquery->fNoEntries > 0 ? newquery->fNoEntries : 1234567890,
3196  newquery->fFirstEntry);
3197  ((TChain *)newquery->fChain)->SetTimerInterval(0);
3198  OnBtnRetrieve();
3199  TChain *chain = (TChain *)newquery->fChain;
3200  ProgressLocal(chain->GetEntries(),
3201  chain->GetReadEntry()+1);
3202  if ((newquery->fStatus != TQueryDescription::kSessionQueryAborted) &&
3205  UpdateButtons(newquery);
3206  }
3207  else {
3208  new TGMsgBox(fClient->GetRoot(), this, "Error Submitting Query",
3209  "Only TChains are allowed in Local Session (no TDSet) !",
3210  kMBIconExclamation,kMBOk,&retval);
3211  }
3212  }
3213  else {
3214  Error("Submit", "No TChain defined; skipping");
3216  return;
3217  }
3218  // set query reference id to unique identifier
3219  newquery->fReference = TString::Format("local-session-%s:q%lld", newquery->fQueryName.Data(), id);
3220  }
3221  // update buttons state
3222  UpdateButtons(newquery);
3223 }
3224 
3225 ////////////////////////////////////////////////////////////////////////////////
3226 /// Update buttons state for the current query status.
3227 
3229 {
3231  if (!item) return;
3232  // retrieve query description attached to list tree item
3233  TObject *obj = (TObject *)item->GetUserData();
3234  if (!obj || obj->IsA() != TQueryDescription::Class())
3235  return;
3236  TQueryDescription *query = (TQueryDescription *)obj;
3237  if (desc != query) return;
3238 
3239  Bool_t submit_en = kFALSE;
3240  if ((fViewer->GetActDesc()->fProof &&
3241  fViewer->GetActDesc()->fProof->IsValid()) ||
3243  submit_en = kTRUE;
3244 
3245  switch (desc->fStatus) {
3247  fBtnSubmit->SetEnabled(submit_en);
3253  break;
3254 
3256  fBtnSubmit->SetEnabled(submit_en);
3258  if (((desc->fResult == 0) || (desc->fResult &&
3259  (desc->fResult->IsFinalized() ||
3260  (desc->fResult->GetInputObject("TDSet") == 0)))) &&
3261  !(fViewer->GetActDesc()->fLocal))
3267  break;
3268 
3270  fBtnSubmit->SetEnabled(submit_en);
3276  break;
3277 
3285  break;
3286 
3294  break;
3295 
3297  fBtnSubmit->SetEnabled(submit_en);
3303  break;
3304 
3306  fBtnSubmit->SetEnabled(submit_en);
3312  break;
3313 
3315  fBtnSubmit->SetEnabled(submit_en);
3321  break;
3322 
3323  default:
3324  break;
3325  }
3326  if (fViewer->GetActDesc()->fLocal &&
3327  !(fViewer->GetActDesc()->fActQuery->fChain)) {
3330  }
3331 }
3332 
3333 ////////////////////////////////////////////////////////////////////////////////
3334 /// Update query information (header) text view.
3335 
3337 {
3338  TString buffer;
3339  const char *qst[] = {"aborted ", "submitted", "running ",
3340  "stopped ", "completed"};
3341 
3342  if (fViewer->GetActDesc()->fActQuery)
3344 
3345  if (fViewer->GetActDesc()->fLocal ||
3346  (fViewer->GetActDesc()->fConnected &&
3348  fViewer->GetActDesc()->fProof &&
3349  fViewer->GetActDesc()->fProof->IsValid())) {
3350  fBtnSave->SetText(" Submit ");
3351  }
3352  else {
3353  fBtnSave->SetText(" Apply changes ");
3354  }
3356  fInfoTextView->Clear();
3357  if (!fViewer->GetActDesc()->fActQuery ||
3359  ResetProgressDialog("", 0, 0, 0);
3360  if (fViewer->GetActDesc()->fLocal) {
3361  if (fViewer->GetActDesc()->fActQuery) {
3362  TChain *chain = (TChain *)fViewer->GetActDesc()->fActQuery->fChain;
3363  if (chain) {
3364  ProgressLocal(chain->GetEntries(),
3365  chain->GetReadEntry()+1);
3366  }
3367  else {
3368  ProgressLocal(0, 0);
3369  }
3371  }
3372  }
3373  else {
3374  fTotal->SetText(" Estimated time left : 0 sec (0 events of 0 processed) ");
3375  fRate->SetText(" Processing Rate : 0.0f events/sec ");
3376  frmProg->Reset();
3377  fFB->Layout();
3378  }
3379  return;
3380  }
3382 
3383  // Status label
3384  Int_t st = (result->GetStatus() > 0 && result->GetStatus() <=
3385  TQueryResult::kCompleted) ? result->GetStatus() : 0;
3386 
3387  Int_t qry = result->GetSeqNum();
3388 
3389  buffer = TString::Format("------------------------------------------------------\n");
3390  // Print header
3391  if (!result->IsDraw()) {
3392  const char *fin = result->IsFinalized() ? "finalized" : qst[st];
3393  const char *arc = result->IsArchived() ? "(A)" : "";
3394  buffer = TString::Format(" Query No : %d\n", qry);
3395  buffer += TString::Format(" Ref : \"%s:%s\"\n", result->GetTitle(),
3396  result->GetName());
3397  buffer += TString::Format(" Selector : %s\n",
3398  result->GetSelecImp()->GetTitle());
3399  buffer += TString::Format("Status : %9s%s\n", fin, arc);
3400  buffer += TString::Format("------------------------------------------------------\n");
3401  } else {
3402  buffer += TString::Format(" Query No : %d\n", qry);
3403  buffer += TString::Format(" Ref : \"%s:%s\"\n", result->GetTitle(),
3404  result->GetName());
3405  buffer += TString::Format(" Selector : %s\n",
3406  result->GetSelecImp()->GetTitle());
3407  buffer += TString::Format("------------------------------------------------------\n");
3408  }
3409 
3410  // Time information
3411  Int_t elapsed = (Int_t)(result->GetEndTime().Convert() -
3412  result->GetStartTime().Convert());
3413  buffer += TString::Format(" Started : %s\n",
3414  result->GetStartTime().AsString());
3415  buffer += TString::Format(" Real time : %d sec (CPU time: %.1f sec)\n",
3416  elapsed, result->GetUsedCPU());
3417 
3418  // Number of events processed, rate, size
3419  Double_t rate = 0.0;
3420  if (result->GetEntries() > -1 && elapsed > 0)
3421  rate = result->GetEntries() / (Double_t)elapsed ;
3422  Float_t size = ((Float_t)result->GetBytes())/(1024*1024);
3423  buffer += TString::Format(" Processed : %lld events (size: %.3f MBs)\n",
3424  result->GetEntries(), size);
3425  buffer += TString::Format(" Rate : %.1f evts/sec\n", rate);
3426 
3427  // Package information
3428  if (strlen(result->GetParList()) > 1) {
3429  buffer += TString::Format(" Packages : %s\n", result->GetParList());
3430  }
3431 
3432  // Result information
3433  TString res = result->GetResultFile();
3434  if (!result->IsArchived()) {
3435  Int_t dq = res.Index("queries");
3436  if (dq > -1) {
3437  res.Remove(0,res.Index("queries"));
3438  res.Insert(0,"<PROOF_SandBox>/");
3439  }
3440  if (res.BeginsWith("-")) {
3441  res = (result->GetStatus() == TQueryResult::kAborted) ?
3442  "not available" : "sent to client";
3443  }
3444  }
3445  if (res.Length() > 1) {
3446  buffer += TString::Format("------------------------------------------------------\n");
3447  buffer += TString::Format(" Results : %s\n", res.Data());
3448  }
3449 
3450  if (result->GetOutputList() && result->GetOutputList()->GetSize() > 0) {
3451  buffer += TString::Format(" Outlist : %d objects\n",
3452  result->GetOutputList()->GetSize());
3453  buffer += TString::Format("------------------------------------------------------\n");
3454  }
3455  fInfoTextView->LoadBuffer(buffer.Data());
3456 
3457  //Float_t pos = Float_t((Double_t)(result->GetEntries() * 100)/(Double_t)total);
3458  if (result->GetStatus() == TQueryResult::kAborted)
3459  frmProg->SetBarColor("red");
3460  else if (result->GetStatus() == TQueryResult::kStopped)
3461  frmProg->SetBarColor("yellow");
3462  else
3463  frmProg->SetBarColor("green");
3464 
3465  frmProg->SetPosition(100.0);
3466 
3467  buffer = TString::Format(" Processed : %lld events in %.1f sec", result->GetEntries(),
3468  (Float_t)elapsed);
3469  fTotal->SetText(buffer.Data());
3470  buffer = TString::Format(" Processing Rate : %.1f events/sec ", rate);
3471  fRate->SetText(buffer.Data());
3472  fFB->Layout();
3473 }
3474 
3475 //////////////////////////////////////////////////////////////////////////////////////////
3476 // Output frame
3477 
3478 ////////////////////////////////////////////////////////////////////////////////
3479 /// Constructor.
3480 
3482  TGCompositeFrame(p, w, h), fEntryTmp(0), fLVContainer(0), fViewer(0)
3483 {
3484 }
3485 
3486 ////////////////////////////////////////////////////////////////////////////////
3487 /// Destructor.
3488 
3490 {
3491  delete fLVContainer; // this container is inside the TGListView and is not
3492  // deleted automatically
3493  Cleanup();
3494 }
3495 
3496 ////////////////////////////////////////////////////////////////////////////////
3497 /// Build query output information frame.
3498 
3500 {
3501  fViewer = gui;
3504 
3505  // Container of object TGListView
3506  TGListView *frmListView = new TGListView(this, 340, 190);
3507  fLVContainer = new TGLVContainer(frmListView, kSunkenFrame, GetWhitePixel());
3508  fLVContainer->Associate(frmListView);
3511  4, 4, 4, 4));
3512 
3513  frmListView->Connect("Clicked(TGLVEntry*, Int_t, Int_t, Int_t)",
3514  "TSessionOutputFrame", this,
3515  "OnElementClicked(TGLVEntry* ,Int_t, Int_t, Int_t)");
3516  frmListView->Connect("DoubleClicked(TGLVEntry*, Int_t, Int_t, Int_t)",
3517  "TSessionOutputFrame", this,
3518  "OnElementDblClicked(TGLVEntry* ,Int_t, Int_t, Int_t)");
3519 }
3520 
3521 ////////////////////////////////////////////////////////////////////////////////
3522 /// Handle mouse clicks on list view items.
3523 
3525  Int_t y)
3526 {
3527  TObject *obj = (TObject *)entry->GetUserData();
3528  if ((obj) && (btn ==3)) {
3529  // if right button, popup context menu
3530  fViewer->GetContextMenu()->Popup(x, y, obj, (TBrowser *)0);
3531  }
3532 }
3533 
3534 ////////////////////////////////////////////////////////////////////////////////
3535 /// Handle double-clicks on list view items.
3536 
3538 {
3539  char action[512];
3540  TString act;
3541  TObject *obj = (TObject *)entry->GetUserData();
3542  if (!obj) return;
3543  TString ext = obj->GetName();
3544  gPad->SetEditable(kFALSE);
3545  // check default action from root.mimes
3546  if (fClient->GetMimeTypeList()->GetAction(obj->IsA()->GetName(), action)) {
3547  act = TString::Format("((%s*)0x%lx)%s", obj->IsA()->GetName(), (Long_t)obj, action);
3548  if (act[0] == '!') {
3549  act.Remove(0, 1);
3550  gSystem->Exec(act.Data());
3551  } else {
3552  // do not allow browse
3553  if (!act.Contains("Browse"))
3554  gROOT->ProcessLine(act.Data());
3555  }
3556  }
3557 }
3558 
3559 ////////////////////////////////////////////////////////////////////////////////
3560 /// Add object to output list view.
3561 
3563 {
3564  TGLVEntry *item;
3565  if (obj) {
3566  item = new TGLVEntry(fLVContainer, obj->GetName(), obj->IsA()->GetName());
3567  item->SetUserData(obj);
3568  fLVContainer->AddItem(item);
3569  }
3570 }
3571 
3572 //////////////////////////////////////////////////////////////////////////////////////////
3573 // Input Frame
3574 
3575 ////////////////////////////////////////////////////////////////////////////////
3576 /// Constructor.
3577 
3579  TGCompositeFrame(p, w, h), fViewer(0), fLVContainer(0)
3580 {
3581 }
3582 
3583 ////////////////////////////////////////////////////////////////////////////////
3584 /// Destructor.
3585 
3587 {
3588  delete fLVContainer; // this container is inside the TGListView and is not
3589  // deleted automatically
3590  Cleanup();
3591 }
3592 
3593 ////////////////////////////////////////////////////////////////////////////////
3594 /// Build query input information frame.
3595 
3597 {
3598  fViewer = gui;
3601 
3602  // Container of object TGListView
3603  TGListView *frmListView = new TGListView(this, 340, 190);
3604  fLVContainer = new TGLVContainer(frmListView, kSunkenFrame, GetWhitePixel());
3605  fLVContainer->Associate(frmListView);
3608  4, 4, 4, 4));
3609 }
3610 
3611 ////////////////////////////////////////////////////////////////////////////////
3612 /// Add object to input list view.
3613 
3615 {
3616  TGLVEntry *item;
3617  if (obj) {
3618  item = new TGLVEntry(fLVContainer, obj->GetName(), obj->IsA()->GetName());
3619  item->SetUserData(obj);
3620  fLVContainer->AddItem(item);
3621  }
3622 }
3623 
3624 //////////////////////////////////////////////////////////////////////////////////////////
3625 // Session Viewer Main Frame
3626 
3627 ////////////////////////////////////////////////////////////////////////////////
3628 /// Main Session viewer constructor.
3629 
3631  TGMainFrame(gClient->GetRoot(), w, h), fSessionHierarchy(0), fSessionItem(0)
3632 {
3633  // only one session viewer allowed
3634  if (gSessionViewer)
3635  // coverity[uninit_member]: already done
3636  return;
3637  Build();
3639  Resize(w, h);
3640  gSessionViewer = this;
3641 }
3642 
3643 ////////////////////////////////////////////////////////////////////////////////
3644 /// Main Session viewer constructor.
3645 
3647  UInt_t h) : TGMainFrame(gClient->GetRoot(), w, h),
3648  fSessionHierarchy(0), fSessionItem(0)
3649 {
3650  // only one session viewer allowed
3651  if (gSessionViewer)
3652  // coverity[uninit_member]: already done
3653  return;
3654  Build();
3656  Move(x, y);
3657  Resize(w, h);
3658  gSessionViewer = this;
3659 }
3660 
3661 ////////////////////////////////////////////////////////////////////////////////
3662 /// Read configuration file and populate list of sessions
3663 /// list of queries and list of packages.
3664 /// Read and set also global options as feedback histos.
3665 
3666 void TSessionViewer::ReadConfiguration(const char *filename)
3667 {
3668  if (fViewerEnv)
3669  delete fViewerEnv;
3670  fViewerEnv = new TEnv();
3671 
3672  const char *fn = (filename && strlen(filename)) ? filename : fConfigFile.Data();
3673 
3675 
3676  Bool_t bval = (Bool_t)fViewerEnv->GetValue("Option.Feedback", 1);
3677  if (bval)
3679  else
3681 
3682  bval = (Bool_t)fViewerEnv->GetValue("Option.MasterHistos", 1);
3683  if (bval) {
3685  gEnv->SetValue("Proof.StatsHist", 1);
3686  }
3687  else {
3689  gEnv->SetValue("Proof.StatsHist", 0);
3690  }
3691  bval = (Bool_t)fViewerEnv->GetValue("Option.MasterEvents", 0);
3692  if (bval)
3694  else
3696  bval = (Bool_t)fViewerEnv->GetValue("Option.WorkerEvents", 0);
3697  if (bval)
3699  else
3701 
3702  Int_t i = 0;
3703  while (kFeedbackHistos[i]) {
3704  bval = (Bool_t)fViewerEnv->GetValue(Form("Option.%s",kFeedbackHistos[i]),
3705  i == 1 ? 1 : 0);
3706  if (bval)
3707  fCascadeMenu->CheckEntry(41+i);
3708  else
3709  fCascadeMenu->UnCheckEntry(41+i);
3710  i++;
3711  }
3712  TSessionDescription *proofDesc;
3713  fSessions->Delete();
3714  if (fSessionItem)
3716  else
3717  fSessionItem = fSessionHierarchy->AddItem(0, "Sessions", fBaseIcon,
3718  fBaseIcon);
3719  // add local session description
3721  fLocal, fLocal);
3722  fSessionHierarchy->SetToolTipItem(item, "Local Session");
3723  TSessionDescription *localdesc = new TSessionDescription();
3724  localdesc->fTag = "";
3725  localdesc->fName = "Local";
3726  localdesc->fAddress = "Local";
3727  localdesc->fPort = 0;
3728  localdesc->fConfigFile = "";
3729  localdesc->fLogLevel = 0;
3730  localdesc->fUserName = "";
3731  localdesc->fQueries = new TList();
3732  localdesc->fPackages = new TList();
3733  localdesc->fActQuery = 0;
3734  localdesc->fProof = 0;
3735  localdesc->fProofMgr = 0;
3736  localdesc->fAttached = kFALSE;
3737  localdesc->fConnected = kFALSE;
3738  localdesc->fLocal = kTRUE;
3739  localdesc->fSync = kTRUE;
3740  localdesc->fAutoEnable = kFALSE;
3741  localdesc->fNbHistos = 0;
3742  item->SetUserData(localdesc);
3743  fSessions->Add((TObject *)localdesc);
3744  fActDesc = localdesc;
3745 
3746  SysInfo_t info;
3747  gSystem->GetSysInfo(&info);
3748  // if the machine has more than one CPU, add one PROOF lite session
3749  // (not supported on Windows yet)
3750  if (!info.fOS.Contains("Microsoft") && info.fCpus > 1) {
3751  // add proof lite session description
3752  item = fSessionHierarchy->AddItem(fSessionItem, "Lite",
3754  fSessionHierarchy->SetToolTipItem(item, "PROOF Lite");
3755  TSessionDescription *litedesc = new TSessionDescription();
3756  litedesc->fTag = "";
3757  litedesc->fName = "PROOF Lite";
3758  litedesc->fAddress = "lite://";
3759  litedesc->fPort = 0;
3760  litedesc->fConfigFile = "";
3761  litedesc->fLogLevel = 0;
3762  litedesc->fUserName = "";
3763  litedesc->fQueries = new TList();
3764  litedesc->fPackages = new TList();
3765  litedesc->fActQuery = 0;
3766  litedesc->fProof = 0;
3767  litedesc->fProofMgr = 0;
3768  litedesc->fAttached = kFALSE;
3769  litedesc->fConnected = kFALSE;
3770  litedesc->fLocal = kFALSE;
3771  litedesc->fSync = kTRUE;
3772  litedesc->fAutoEnable = kFALSE;
3773  litedesc->fNbHistos = 0;
3774  item->SetUserData(litedesc);
3775  fSessions->Add((TObject *)litedesc);
3776  fActDesc = litedesc;
3777  }
3778  TIter next(fViewerEnv->GetTable());
3779  TEnvRec *er;
3780  while ((er = (TEnvRec*) next())) {
3781  const char *s;
3782  if ((s = strstr(er->GetName(), "SessionDescription."))) {
3783  const char *val = fViewerEnv->GetValue(s, (const char*)0);
3784  if (val) {
3785  Int_t cnt = 0;
3786  char *v = StrDup(val);
3787  s += 7;
3788  while (1) {
3789  TString name = strtok(!cnt ? v : 0, ";");
3790  if (name.IsNull()) break;
3791  TString sessiontag = strtok(0, ";");
3792  TString address = strtok(0, ";");
3793  if (address.IsNull()) break;
3794  TString port = strtok(0, ";");
3795  if (port.IsNull()) break;
3796  TString loglevel = strtok(0, ";");
3797  if (loglevel.IsNull()) break;
3798  TString configfile = strtok(0, ";");
3799  TString user = strtok(0, ";");
3800  if (user.IsNull()) break;
3801  TString sync = strtok(0, ";");
3802  TString autoen = strtok(0, ";");
3803 
3804  // build session description
3805  proofDesc = new TSessionDescription();
3806  proofDesc->fTag = sessiontag.Length() > 2 ? sessiontag.Data() : "";
3807  proofDesc->fName = name;
3808  proofDesc->fAddress = address;
3809  proofDesc->fPort = atoi(port);
3810  proofDesc->fConfigFile = configfile.Length() > 2 ? configfile.Data() : "";
3811  proofDesc->fLogLevel = atoi(loglevel);
3812  proofDesc->fConnected = kFALSE;
3813  proofDesc->fAttached = kFALSE;
3814  proofDesc->fLocal = kFALSE;
3815  proofDesc->fQueries = new TList();
3816  proofDesc->fPackages = new TList();
3817  proofDesc->fActQuery = 0;
3818  proofDesc->fProof = 0;
3819  proofDesc->fProofMgr = 0;
3820  proofDesc->fSync = (Bool_t)(atoi(sync));
3821  proofDesc->fAutoEnable = (Bool_t)(atoi(autoen));
3822  proofDesc->fUserName = user;
3823  fSessions->Add((TObject *)proofDesc);
3824  item = fSessionHierarchy->AddItem(
3825  fSessionItem, proofDesc->fName.Data(),
3827  fSessionHierarchy->SetToolTipItem(item, "Proof Session");
3828  item->SetUserData(proofDesc);
3829  fActDesc = proofDesc;
3830  cnt++;
3831  }
3832  delete [] v;
3833  }
3834  }
3835  if ((s = strstr(er->GetName(), "QueryDescription."))) {
3836  const char *val = fViewerEnv->GetValue(s, (const char*)0);
3837  if (val) {
3838  Int_t cnt = 0;
3839  char *v = StrDup(val);
3840  s += 7;
3841  while (1) {
3842 
3843  TString status = strtok(!cnt ? v : 0, ";");
3844  if (status.IsNull()) break;
3845 
3846  TString reference = strtok(0, ";");
3847  if (reference.IsNull()) break;
3848  TString queryname = strtok(0, ";");
3849  if (queryname.IsNull()) break;
3850  TString selector = strtok(0, ";");
3851  if (selector.IsNull()) break;
3852  TString dset = strtok(0, ";");
3853  TString options = strtok(0, ";");
3854  TString eventlist = strtok(0, ";");