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