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