Logo ROOT  
Reference Guide
TSessionViewer.cxx
Go to the documentation of this file.
1// @(#)root/sessionviewer:$Id$
2// Author: Marek Biskup, Jakub Madejczyk, Bertrand Bellenot 10/08/2005
3
4/*************************************************************************
5 * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12//////////////////////////////////////////////////////////////////////////
13// //
14// TSessionViewer //
15// //
16// Widget used to manage PROOF or local sessions, PROOF connections, //
17// queries construction and results handling. //
18// //
19//////////////////////////////////////////////////////////////////////////
20
21#include "TApplication.h"
22#include "TROOT.h"
23#include "THashList.h"
24#include "TClass.h"
25#include "TSystem.h"
26#include "TGFileDialog.h"
27#include "TBrowser.h"
28#include "TGButton.h"
29#include "TGLayout.h"
30#include "TGListTree.h"
31#include "TGCanvas.h"
32#include "TGLabel.h"
33#include "TGTextEntry.h"
34#include "TGNumberEntry.h"
35#include "TGTableLayout.h"
36#include "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 "TObjString.h"
48#include "TProof.h"
49#include "TRandom.h"
50#include "TSessionViewer.h"
51#include "TSessionLogView.h"
52#include "TQueryResult.h"
53#include "TGTextView.h"
54#include "TGToolBar.h"
55#include "TGTab.h"
56#include "TRootEmbeddedCanvas.h"
57#include "TCanvas.h"
58#include "TGMimeTypes.h"
59#include "TInterpreter.h"
60#include "TContextMenu.h"
61#include "TG3DLine.h"
62#include "TSessionDialogs.h"
63#include "TEnv.h"
64#include "TH2.h"
65#include "TVirtualTreePlayer.h"
66#include "TSelector.h"
67#include "TFileCollection.h"
68#include "TVirtualX.h"
69#ifdef WIN32
70#include "TWin32SplashThread.h"
71#endif
72#include <stdlib.h>
73
75
76const char *kConfigFile = ".proofgui.conf";
77
86
87const char *xpm_names[] = {
88 "monitor01.xpm",
89 "monitor02.xpm",
90 "monitor03.xpm",
91 "monitor04.xpm",
92 0
93};
94
95const char *conftypes[] = {
96 "Config files", "*.conf",
97 "All files", "*.*",
98 0, 0
99};
100
101const char *pkgtypes[] = {
102 "Package files", "*.par",
103 "All files", "*.*",
104 0, 0
105};
106
107const char *macrotypes[] = {
108 "C files", "*.[C|c]*",
109 "All files", "*",
110 0, 0
111};
112
113
114const char *kFeedbackHistos[] = {
115 "PROOF_PacketsHist",
116 "PROOF_EventsHist",
117 "PROOF_NodeHist",
118 "PROOF_LatencyHist",
119 "PROOF_ProcTimeHist",
120 "PROOF_CpuTimeHist",
121 0
122};
123
124const char* const kSession_RedirectFile = ".templog";
125const char* const kSession_RedirectCmd = ".tempcmd";
126
127// Menu command id's
133
138
146
152
158
161
162const char *xpm_toolbar[] = {
163 "fileopen.xpm",
164 "filesaveas.xpm",
165 "",
166 "connect.xpm",
167 "disconnect.xpm",
168 "",
169 "query_new.xpm",
170 "query_submit.xpm",
171 "",
172 "about.xpm",
173 "",
174 "quit.xpm",
175 0
176};
177
179 { "", "Open Config File", kFALSE, kFileLoadConfig, 0 },
180 { "", "Save Config File", kFALSE, kFileSaveConfig, 0 },
181 { "", 0, 0, -1, 0 },
182 { "", "Connect", kFALSE, kSessionConnect, 0 },
183 { "", "Disconnect", kFALSE, kSessionDisconnect, 0 },
184 { "", 0, 0, -1, 0 },
185 { "", "New Query", kFALSE, kQueryNew, 0 },
186 { "", "Submit Query", kFALSE, kQuerySubmit, 0 },
187 { "", 0, 0, -1, 0 },
188 { "", "About Root", kFALSE, kHelpAbout, 0 },
189 { "", 0, 0, -1, 0 },
190 { "", "Exit Root", kFALSE, kFileQuit, 0 },
191 { 0, 0, 0, 0, 0 }
192};
193
194
195////////////////////////////////////////////////////////////////////////////////
196// Server Frame
197
198////////////////////////////////////////////////////////////////////////////////
199/// Constructor.
200
202 TGCompositeFrame(p, w, h), fFrmNewServer(0), fTxtName(0), fTxtAddress(0),
203 fNumPort(0), fLogLevel(0), fTxtConfig(0), fTxtUsrName(0), fSync(0),
204 fViewer(0), fBtnAdd(0), fBtnConnect(0)
205{
206}
207
208////////////////////////////////////////////////////////////////////////////////
209/// Destructor.
210
212{
213 Cleanup();
214}
215
216////////////////////////////////////////////////////////////////////////////////
217/// Build server configuration frame.
218
220{
222
224
225 fViewer = gui;
226 fFrmNewServer = new TGGroupFrame(this, "New Session");
228
230
232
233 fFrmNewServer->AddFrame(new TGLabel(fFrmNewServer, "Session Name:"),
234 new TGLayoutHints(kLHintsLeft, 3, 3, 3, 3));
236 (const char *)0, 1), new TGLayoutHints());
238 fTxtName->Associate(this);
239 fFrmNewServer->AddFrame(new TGLabel(fFrmNewServer, "Server name:"),
240 new TGLayoutHints(kLHintsLeft, 3, 3, 3, 3));
242 (const char *)0, 2), new TGLayoutHints());
244 fTxtAddress->Associate(this);
245 fFrmNewServer->AddFrame(new TGLabel(fFrmNewServer, "Port (default: 1093):"),
246 new TGLayoutHints(kLHintsLeft, 3, 3, 3, 3));
250 fNumPort->Associate(this);
251 fFrmNewServer->AddFrame(new TGLabel(fFrmNewServer, "Configuration File:"),
252 new TGLayoutHints(kLHintsLeft, 3, 3, 3, 3));
254 (const char *)0, 4), new TGLayoutHints());
256 fTxtConfig->Associate(this);
257 fFrmNewServer->AddFrame(new TGLabel(fFrmNewServer, "Log Level:"),
258 new TGLayoutHints(kLHintsLeft, 3, 3, 3, 3));
259
264 new TGLayoutHints(kLHintsLeft, 3, 3, 3, 3));
265 fLogLevel->Associate(this);
266
267 fFrmNewServer->AddFrame(new TGLabel(fFrmNewServer, "User Name:"),
268 new TGLayoutHints(kLHintsLeft, 3, 3, 3, 3));
270 (const char *)0, 6), new TGLayoutHints());
272 fTxtUsrName->Associate(this);
273
274 fFrmNewServer->AddFrame(new TGLabel(fFrmNewServer, "Process mode :"),
276 3, 3, 3, 3));
278 "&Synchronous"), new TGLayoutHints(kLHintsLeft | kLHintsBottom |
279 kLHintsExpandX, 3, 3, 3, 3));
280 fSync->SetToolTipText("Default Process Mode");
282
283 AddFrame(fBtnAdd = new TGTextButton(this, " Save "),
284 new TGLayoutHints(kLHintsTop | kLHintsCenterX, 5, 5, 15, 5));
285 fBtnAdd->SetToolTipText("Add server to the list");
286 fBtnAdd->Connect("Clicked()", "TSessionServerFrame", this,
287 "OnBtnAddClicked()");
288 AddFrame(fBtnConnect = new TGTextButton(this, " Connect "),
289 new TGLayoutHints(kLHintsTop | kLHintsCenterX, 5, 5, 15, 5));
290 fBtnConnect->Connect("Clicked()", "TSessionServerFrame", this,
291 "OnBtnConnectClicked()");
292 fBtnConnect->SetToolTipText("Connect to the selected server");
293
294 fTxtConfig->Connect("DoubleClicked()", "TSessionServerFrame", this,
295 "OnConfigFileClicked()");
296
297 fTxtName->Connect("TextChanged(char*)", "TSessionServerFrame", this,
298 "SettingsChanged()");
299 fTxtAddress->Connect("TextChanged(char*)", "TSessionServerFrame", this,
300 "SettingsChanged()");
301 fTxtConfig->Connect("TextChanged(char*)", "TSessionServerFrame", this,
302 "SettingsChanged()");
303 fTxtUsrName->Connect("TextChanged(char*)", "TSessionServerFrame", this,
304 "SettingsChanged()");
305 fSync->Connect("Clicked()", "TSessionServerFrame", this,
306 "SettingsChanged()");
307 fLogLevel->Connect("ValueChanged(Long_t)", "TSessionServerFrame", this,
308 "SettingsChanged()");
309 fLogLevel->Connect("ValueSet(Long_t)", "TSessionServerFrame", this,
310 "SettingsChanged()");
311 fNumPort->Connect("ValueChanged(Long_t)", "TSessionServerFrame", this,
312 "SettingsChanged()");
313 fNumPort->Connect("ValueSet(Long_t)", "TSessionServerFrame", this,
314 "SettingsChanged()");
315
316}
317
318////////////////////////////////////////////////////////////////////////////////
319/// Settings have changed, update GUI accordingly.
320
322{
323 TGTextEntry *sender = dynamic_cast<TGTextEntry*>((TQObject*)gTQSender);
324 Bool_t issync = (fSync->GetState() == kButtonDown);
325 if ((fViewer->GetActDesc()->fLocal) ||
326 (strcmp(fViewer->GetActDesc()->GetName(), fTxtName->GetText())) ||
327 (strcmp(fViewer->GetActDesc()->fAddress.Data(), fTxtAddress->GetText())) ||
328 (strcmp(fViewer->GetActDesc()->fConfigFile.Data(), fTxtConfig->GetText())) ||
329 (strcmp(fViewer->GetActDesc()->fUserName.Data(), fTxtUsrName->GetText())) ||
332 (fViewer->GetActDesc()->fSync != issync)) {
335 }
336 else {
339 }
340 if (sender) {
341 sender->SetFocus();
342 }
343}
344
345
346////////////////////////////////////////////////////////////////////////////////
347/// Handle expose event in server frame.
348
350{
351 //fTxtName->SelectAll();
352 //fTxtName->SetFocus();
353 return kTRUE;
354}
355
356////////////////////////////////////////////////////////////////////////////////
357/// Browse configuration files.
358
360{
361 // do nothing if connection in progress
362 if (fViewer->IsBusy())
363 return;
364 TGFileInfo fi;
367 if (!fi.fFilename) return;
369}
370
371////////////////////////////////////////////////////////////////////////////////
372/// Delete selected session configuration (remove it from the list).
373
375{
376 // do nothing if connection in progress
377 if (fViewer->IsBusy())
378 return;
380 TIter next(fViewer->GetSessions());
382
383 if (desc->fLocal) {
384 Int_t retval;
385 new TGMsgBox(fClient->GetRoot(), this, "Error Deleting Session",
386 "Deleting Local Sessions is not allowed !",
387 kMBIconExclamation,kMBOk,&retval);
388 return;
389 }
390 // ask for confirmation
391 TString m;
392 m.Form("Are you sure to delete the server \"%s\"",
393 desc->fName.Data());
394 Int_t result;
395 new TGMsgBox(fClient->GetRoot(), this, "", m.Data(), 0,
396 kMBOk | kMBCancel, &result);
397 // if confirmed, delete it
398 if (result == kMBOk) {
399 // remove the Proof session from gROOT list of Proofs
400 if (desc->fConnected && desc->fAttached && desc->fProof) {
401 desc->fProof->Detach("S");
402 }
403 // remove it from our sessions list
404 fViewer->GetSessions()->Remove((TObject *)desc);
405 // update configuration file
408
409 TObject *obj = fViewer->GetSessions()->Last();
411 fViewer->GetSessionItem(), (void *)obj);
412 if (item) {
419 fViewer->OnListTreeClicked(item, 1, 0, 0);
420 }
421 }
422 if (fViewer->IsAutoSave())
424}
425
426////////////////////////////////////////////////////////////////////////////////
427/// Connect to selected server.
428
430{
431 // do nothing if connection in progress
432 if (fViewer->IsBusy())
433 return;
434
437 }
438 else {
441 if (strlen(fTxtConfig->GetText()) > 1)
443 else
448 if (fViewer->IsAutoSave())
450 }
451 // set flag busy
452 fViewer->SetBusy();
453 // avoid input events in list tree while connecting
458 // set watch cursor to indicate connection in progress
460 gVirtualX->CreateCursor(kWatch));
461 gVirtualX->SetCursor(GetId(),gVirtualX->CreateCursor(kWatch));
462 // display connection progress bar in first part of status bar
464 // connect to proof startup message (to update progress bar)
465 TQObject::Connect("TProof", "StartupMessage(char *,Bool_t,Int_t,Int_t)",
466 "TSessionViewer", fViewer, "StartupMessage(char *,Bool_t,Int_t,Int_t)");
467 // collect and set-up configuration
468 TString address = fTxtAddress->GetText();
469 TString url;
470 if (address == "lite://") {
471 url = address;
472 }
473 else {
474 // collect and set-up configuration
475 url = fTxtUsrName->GetText();
476 url += "@"; url += address.Data();
477 if (fNumPort->GetIntNumber() > 0) {
478 url += ":";
479 url += fNumPort->GetIntNumber();
480 }
481 }
482
483 TProofDesc *desc;
485 if (!fViewer->GetActDesc()->fProofMgr ||
487 // hide connection progress bar from status bar
489 // release busy flag
491 // restore cursors and input
492 gVirtualX->SetCursor(GetId(), 0);
497 gVirtualX->SetCursor(fViewer->GetSessionHierarchy()->GetId(), 0);
498 return;
499 }
501 // check if the session already exist before to recreate it
502 TList *sessions = fViewer->GetActDesc()->fProofMgr->QuerySessions("");
503 if (sessions) {
504 TIter nextp(sessions);
505 // loop over existing Proof sessions
506 while ((desc = (TProofDesc *)nextp())) {
507 if ((desc->GetName() == fViewer->GetActDesc()->fTag) ||
508 (desc->GetTitle() == fViewer->GetActDesc()->fName)) {
511 fViewer->GetActDesc()->fTag = desc->GetName();
515
517 Int_t i = 0;
518 // browse list of feedback histos and check user's selected ones
519 while (kFeedbackHistos[i]) {
520 if (fViewer->GetCascadeMenu()->IsEntryChecked(41+i)) {
523 }
524 i++;
525 }
526 // connect feedback signal
527 fViewer->GetActDesc()->fProof->Connect("Feedback(TList *objs)",
528 "TSessionQueryFrame", fViewer->GetQueryFrame(),
529 "Feedback(TList *objs)");
530 gROOT->Time();
531 }
532 else {
533 // if feedback option not selected, clear Proof's feedback option
535 }
536
537 break;
538 }
539 }
540 }
541 if (fViewer->GetActDesc()->fProof == 0) {
542 if (fViewer->GetActDesc()->fProofMgr->IsValid()) {
545 desc = 0;
546 sessions = fViewer->GetActDesc()->fProofMgr->QuerySessions("");
547 if (sessions)
548 desc = (TProofDesc *)sessions->Last();
549 if (desc) {
551 fViewer->GetActDesc()->fTag = desc->GetName();
554 }
555 }
556 }
557 if (fViewer->GetActDesc()->fProof) {
562 if (fViewer->GetActDesc()->fLogLevel < 0)
564 if (fViewer->GetActDesc()->fProof->IsLite())
565 fViewer->GetActDesc()->fAddress = "lite://";
566 else
570 }
572
573 // check if connected and valid
574 if (fViewer->GetActDesc()->fProof &&
576 // set log level
578 // set query type (synch / asynch)
581 // set connected flag
583 // change list tree item picture to connected pixmap
586 if (item) {
588 // update viewer
589 fViewer->OnListTreeClicked(item, 1, 0, 0);
592 }
593 // connect to progress related signals
594 fViewer->GetActDesc()->fProof->Connect("Progress(Long64_t,Long64_t)",
595 "TSessionQueryFrame", fViewer->GetQueryFrame(),
596 "Progress(Long64_t,Long64_t)");
597 fViewer->GetActDesc()->fProof->Connect("Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)",
598 "TSessionQueryFrame", fViewer->GetQueryFrame(),
599 "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)");
600 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)",
601 "TSessionQueryFrame", fViewer->GetQueryFrame(),
602 "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t,Int_t,Int_t,Float_t)");
603 fViewer->GetActDesc()->fProof->Connect("StopProcess(Bool_t)",
604 "TSessionQueryFrame", fViewer->GetQueryFrame(),
605 "IndicateStop(Bool_t)");
607 "ResetProgressDialog(const char*,Int_t,Long64_t,Long64_t)",
608 "TSessionQueryFrame", fViewer->GetQueryFrame(),
609 "ResetProgressDialog(const char*,Int_t,Long64_t,Long64_t)");
610 // enable timer used for status bar icon's animation
612 // change status bar right icon to connected pixmap
613 fViewer->ChangeRightLogo("monitor01.xpm");
614 // do not animate yet
616 // connect to signal "query result ready"
617 fViewer->GetActDesc()->fProof->Connect("QueryResultReady(char *)",
618 "TSessionViewer", fViewer, "QueryResultReady(char *)");
619 // display connection information on status bar
620 TString msg;
621 msg.Form("PROOF Cluster %s ready", fViewer->GetActDesc()->fName.Data());
622 fViewer->GetStatusBar()->SetText(msg.Data(), 1);
626 // Enable previously uploaded packages if in auto-enable mode
628 TPackageDescription *package;
630 while ((package = (TPackageDescription *)next())) {
631 if (!package->fEnabled) {
632 if (fViewer->GetActDesc()->fProof->EnablePackage(package->fName) != 0)
633 Error("Submit", "Enable package failed");
634 else {
635 package->fEnabled = kTRUE;
637 }
638 }
639 }
640 }
641 }
642 // hide connection progress bar from status bar
644 // release busy flag
646 // restore cursors and input
647 gVirtualX->SetCursor(GetId(), 0);
652 gVirtualX->SetCursor(fViewer->GetSessionHierarchy()->GetId(), 0);
653}
654
655////////////////////////////////////////////////////////////////////////////////
656/// Reset server configuration fields.
657
659{
660 // do nothing if connection in progress
661 if (fViewer->IsBusy())
662 return;
670 fTxtName->SetText("");
671 fTxtAddress->SetText("");
672 fTxtConfig->SetText("");
673 fNumPort->SetIntNumber(1093);
675 fTxtUsrName->SetText("");
676}
677
678////////////////////////////////////////////////////////////////////////////////
679/// Add newly created session configuration in the list of sessions.
680
682{
683 Int_t retval;
684 Bool_t newSession = kTRUE;
685 TSessionDescription* desc = 0;
686 // do nothing if connection in progress
687 if (fViewer->IsBusy())
688 return;
689
690 if ((!fTxtName->GetBuffer()->GetTextLength()) ||
693 new TGMsgBox(fClient->GetRoot(), fViewer, "Error Adding Session",
694 "At least one required field is empty !",
695 kMBIconExclamation, kMBOk, &retval);
696 return;
697 }
699 if (obj)
700 desc = dynamic_cast<TSessionDescription*>(obj);
701 if (desc) {
702 new TGMsgBox(fClient->GetRoot(), fViewer, "Adding Session",
703 TString::Format("The session \"%s\" already exists ! Overwrite ?",
705 kMBCancel, &retval);
706 if (retval != kMBYes)
707 return;
708 newSession = kFALSE;
709 }
710 if (newSession) {
711 desc = new TSessionDescription();
712 desc->fName = fTxtName->GetText();
713 desc->fTag = "";
714 desc->fQueries = new TList();
715 desc->fPackages = new TList();
716 desc->fActQuery = 0;
717 desc->fProof = 0;
718 desc->fProofMgr = 0;
719 desc->fAutoEnable = kFALSE;
720 desc->fAddress = fTxtAddress->GetText();
721 desc->fPort = fNumPort->GetIntNumber();
722 desc->fConnected = kFALSE;
723 desc->fAttached = kFALSE;
724 desc->fLocal = kFALSE;
725 if (strlen(fTxtConfig->GetText()) > 1)
727 else
728 desc->fConfigFile = "";
730 desc->fUserName = fTxtUsrName->GetText();
731 desc->fSync = (fSync->GetState() == kButtonDown);
732 // add newly created session config to our session list
733 fViewer->GetSessions()->Add((TObject *)desc);
734 // save into configuration file
736 fViewer->GetSessionItem(), desc->fName.Data(),
738 fViewer->GetSessionHierarchy()->SetToolTipItem(item, "Proof Session");
739 item->SetUserData(desc);
747 fViewer->OnListTreeClicked(item, 1, 0, 0);
748 }
749 else {
753 if (strlen(fTxtConfig->GetText()) > 1)
759 item2->SetUserData(fViewer->GetActDesc());
761 1, 0, 0);
762 }
765 if (fViewer->IsAutoSave())
767}
768
769////////////////////////////////////////////////////////////////////////////////
770/// Update fields with values from session description desc.
771
773{
774 if (desc->fLocal) {
775 fTxtName->SetText("");
776 fTxtAddress->SetText("");
777 fNumPort->SetIntNumber(1093);
778 fTxtConfig->SetText("");
779 fTxtUsrName->SetText("");
781 return;
782 }
783
784 fTxtName->SetText(desc->fName);
788
789 if (desc->fConfigFile.Length() > 1) {
791 }
792 else {
793 fTxtConfig->SetText("");
794 }
796}
797
798////////////////////////////////////////////////////////////////////////////////
799/// Process messages for session server frame.
800/// Used to navigate between text entry fields.
801
803{
804 switch (GET_MSG(msg)) {
805 case kC_TEXTENTRY:
806 switch (GET_SUBMSG(msg)) {
807 case kTE_ENTER:
808 case kTE_TAB:
809 switch (parm1) {
810 case 1: // session name
813 break;
814 case 2: // server address
817 break;
818 case 3: // port number
821 break;
822 case 4: // configuration file
825 break;
826 case 5: // log level
829 break;
830 case 6: // user name
833 break;
834 }
835 break;
836
837 default:
838 break;
839 }
840 break;
841
842 default:
843 break;
844 }
845 return kTRUE;
846}
847
848////////////////////////////////////////////////////////////////////////////////
849// Session Frame
850
851////////////////////////////////////////////////////////////////////////////////
852/// Constructor.
853
855 TGCompositeFrame(p, w, h), fTab(0), fFA(0), fFB(0), fFC(0), fFD(0), fFE(0),
856 fCommandTxt(0), fCommandBuf(0), fInfoTextView(0), fClearCheck(0),
857 fBtnShowLog(0), fBtnNewQuery(0), fBtnGetQueries(0), fLBPackages(0),
858 fBtnAdd(0), fBtnRemove(0), fBtnUp(0), fBtnDown(0), fBtnShow(0),
859 fBtnShowEnabled(0), fChkMulti(0), fChkEnable(0), fBtnUpload(0),
860 fBtnEnable(0), fBtnClear(0), fBtnDisable(0), fDSetView(0), fDataSetTree(0),
861 fBtnUploadDSet(0), fBtnRemoveDSet(0), fBtnVerifyDSet(0), fBtnRefresh(0),
862 fTxtParallel(0), fLogLevel(0), fApplyLogLevel(0), fApplyParallel(0),
863 fViewer(0)
864{
865 for (int i=0;i<19;++i) fInfoLine[i] = 0;
866}
867
868////////////////////////////////////////////////////////////////////////////////
869/// Destructor.
870
872{
873 Cleanup();
874}
875
876////////////////////////////////////////////////////////////////////////////////
877/// Build session frame.
878
880{
883 fViewer = gui;
884 Int_t i,j;
885
886 // main session tab
887 fTab = new TGTab(this, 200, 200);
889 kLHintsExpandY, 2, 2, 2, 2));
890
891 // add "Status" tab element
892 TGCompositeFrame *tf = fTab->AddTab("Status");
893 fFA = new TGCompositeFrame(tf, 100, 100, kVerticalFrame);
896
897 // add first session information line
898 fInfoLine[0] = new TGLabel(fFA, " ");
900 kLHintsExpandX, 5, 5, 15, 5));
901
902 TGCompositeFrame* frmInfos = new TGHorizontalFrame(fFA, 350, 100);
903 frmInfos->SetLayoutManager(new TGTableLayout(frmInfos, 9, 2));
904
905 // add session information lines
906 j = 0;
907 for (i=0;i<17;i+=2) {
908 fInfoLine[i+1] = new TGLabel(frmInfos, " ");
909 frmInfos->AddFrame(fInfoLine[i+1], new TGTableLayoutHints(0, 1, j, j+1,
910 kLHintsLeft | kLHintsCenterY, 5, 5, 2, 2));
911 fInfoLine[i+2] = new TGLabel(frmInfos, " ");
912 frmInfos->AddFrame(fInfoLine[i+2], new TGTableLayoutHints(1, 2, j, j+1,
913 kLHintsLeft | kLHintsCenterY, 5, 5, 2, 2));
914 j++;
915 }
917 kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5));
918
919 // add "new query" and "get queries" buttons
920 TGCompositeFrame* frmBut1 = new TGHorizontalFrame(fFA, 350, 100);
921 frmBut1->SetCleanup(kDeepCleanup);
922 frmBut1->AddFrame(fBtnNewQuery = new TGTextButton(frmBut1, "New Query..."),
923 new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 5, 5, 5, 5));
924 fBtnNewQuery->SetToolTipText("Open New Query Dialog");
925 frmBut1->AddFrame(fBtnGetQueries = new TGTextButton(frmBut1, " Get Queries "),
926 new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 5, 5, 5, 5));
927 fBtnGetQueries->SetToolTipText("Get List of Queries from the server");
928 fBtnShowLog = new TGTextButton(frmBut1, "Show log...");
929 fBtnShowLog->SetToolTipText("Show Session log (opens log window)");
931 kLHintsExpandX, 5, 5, 5, 5));
934
935 // add "Commands" tab element
936 tf = fTab->AddTab("Commands");
937 fFC = new TGCompositeFrame(tf, 100, 100, kVerticalFrame);
940
941 // add command line label and text entry
942 TGCompositeFrame* frmCmd = new TGHorizontalFrame(fFC, 350, 100);
943 frmCmd->SetCleanup(kDeepCleanup);
944 frmCmd->AddFrame(new TGLabel(frmCmd, "Command Line :"),
945 new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5, 5, 15, 5));
946 fCommandBuf = new TGTextBuffer(120);
947 frmCmd->AddFrame(fCommandTxt = new TGTextEntry(frmCmd,
949 kLHintsExpandX, 5, 5, 15, 5));
950 fFC->AddFrame(frmCmd, new TGLayoutHints(kLHintsExpandX, 5, 5, 10, 5));
951 // connect command line text entry to "return pressed" signal
952 fCommandTxt->Connect("ReturnPressed()", "TSessionFrame", this,
953 "OnCommandLine()");
954
955 // check box for option "clear view"
956 fClearCheck = new TGCheckButton(fFC, "Clear view after each command");
958 10, 5, 5, 5));
960 // add text view for redirected output
961 fFC->AddFrame(new TGLabel(fFC, "Output :"),
962 new TGLayoutHints(kLHintsLeft | kLHintsTop, 10, 5, 5, 5));
963 fInfoTextView = new TGTextView(fFC, 330, 150, "", kSunkenFrame |
966 kLHintsTop | kLHintsExpandX | kLHintsExpandY, 10, 10, 5, 5));
967
968 // add "Packages" tab element
969 tf = fTab->AddTab("Packages");
970 fFB = new TGCompositeFrame(tf, 100, 100, kVerticalFrame);
973
974 // new frame containing packages listbox and control buttons
975 TGCompositeFrame* frmcanvas = new TGHorizontalFrame(fFB, 350, 100);
976
977 // packages listbox
978 fLBPackages = new TGListBox(frmcanvas);
979 fLBPackages->Resize(80,150);
982 kLHintsExpandY, 5, 5, 5, 5));
983 // control buttons frame
984 TGCompositeFrame* frmBut2 = new TGVerticalFrame(frmcanvas, 150, 100);
985
986 fChkMulti = new TGCheckButton(frmBut2, "Multiple Selection");
987 fChkMulti->SetToolTipText("Enable multiple selection in the package list");
988 frmBut2->AddFrame(fChkMulti, new TGLayoutHints(kLHintsLeft, 5, 5, 5, 5));
989
990 fBtnAdd = new TGTextButton(frmBut2, " Add... ");
991 fBtnAdd->SetToolTipText("Add a package to the list");
993 kLHintsExpandX, 5, 5, 5, 5));
994 fBtnRemove = new TGTextButton(frmBut2, "Remove");
995 fBtnRemove->SetToolTipText("Remove package from the list");
997 kLHintsExpandX, 5, 5, 5, 5));
998 fBtnUp = new TGTextButton(frmBut2, "Move Up");
999 fBtnUp->SetToolTipText("Move package one step upward in the list");
1001 kLHintsExpandX, 5, 5, 5, 5));
1002 fBtnDown = new TGTextButton(frmBut2, "Move Down");
1003 fBtnDown->SetToolTipText("Move package one step downward in the list");
1005 kLHintsExpandX, 5, 5, 5, 5));
1006 frmcanvas->AddFrame(frmBut2, new TGLayoutHints(kLHintsLeft | kLHintsCenterY |
1008 fFB->AddFrame(frmcanvas, new TGLayoutHints(kLHintsLeft | kLHintsTop |
1010
1011 TGCompositeFrame* frmLeg = new TGHorizontalFrame(fFB, 300, 100);
1012 frmLeg->SetCleanup(kDeepCleanup);
1013 TGPicture *pic1 = (TGPicture *)fClient->GetPicture("package.xpm");
1014 TGIcon *icn1 = new TGIcon(frmLeg, pic1, pic1->GetWidth(), pic1->GetHeight());
1015 frmLeg->AddFrame(icn1, new TGLayoutHints(kLHintsLeft | kLHintsTop,
1016 5, 5, 0, 5));
1017 frmLeg->AddFrame(new TGLabel(frmLeg, ": Local"),
1018 new TGLayoutHints(kLHintsLeft | kLHintsTop, 0, 10, 0, 5));
1019
1020 TGPicture *pic2 = (TGPicture *)fClient->GetPicture("package_delete.xpm");
1021 TGIcon *icn2 = new TGIcon(frmLeg, pic2, pic2->GetWidth(), pic2->GetHeight());
1022 frmLeg->AddFrame(icn2, new TGLayoutHints(kLHintsLeft | kLHintsTop,
1023 5, 5, 0, 5));
1024 frmLeg->AddFrame(new TGLabel(frmLeg, ": Uploaded"),
1025 new TGLayoutHints(kLHintsLeft | kLHintsTop, 0, 10, 0, 5));
1026
1027 TGPicture *pic3 = (TGPicture *)fClient->GetPicture("package_add.xpm");
1028 TGIcon *icn3 = new TGIcon(frmLeg, pic3, pic3->GetWidth(), pic3->GetHeight());
1029 frmLeg->AddFrame(icn3, new TGLayoutHints(kLHintsLeft | kLHintsTop,
1030 5, 5, 0, 5));
1031 frmLeg->AddFrame(new TGLabel(frmLeg, ": Enabled"),
1032 new TGLayoutHints(kLHintsLeft | kLHintsTop, 0, 10, 0, 5));
1034 kLHintsExpandX, 0, 0, 0, 0));
1035
1036 TGCompositeFrame* frmBtn = new TGHorizontalFrame(fFB, 300, 100);
1037 frmBtn->SetCleanup(kDeepCleanup);
1038 frmBtn->AddFrame(fBtnUpload = new TGTextButton(frmBtn,
1039 " Upload "), new TGLayoutHints(kLHintsLeft | kLHintsExpandX |
1040 kLHintsCenterY, 5, 5, 5, 5));
1041 fBtnUpload->SetToolTipText("Upload selected package(s) to the server");
1042 frmBtn->AddFrame(fBtnEnable = new TGTextButton(frmBtn,
1043 " Enable "), new TGLayoutHints(kLHintsLeft | kLHintsExpandX |
1044 kLHintsCenterY, 5, 5, 5, 5));
1045 fBtnEnable->SetToolTipText("Enable selected package(s) on the server");
1046 frmBtn->AddFrame(fBtnDisable = new TGTextButton(frmBtn,
1047 " Disable "), new TGLayoutHints(kLHintsLeft | kLHintsExpandX |
1048 kLHintsCenterY, 5, 5, 5, 5));
1049 fBtnDisable->SetToolTipText("Disable selected package(s) on the server");
1050 frmBtn->AddFrame(fBtnClear = new TGTextButton(frmBtn,
1051 " Clear "), new TGLayoutHints(kLHintsLeft | kLHintsExpandX |
1052 kLHintsCenterY, 5, 5, 5, 5));
1053 fBtnClear->SetToolTipText("Clear all packages on the server");
1054 fFB->AddFrame(frmBtn, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
1055
1057
1058 TGCompositeFrame* frmBtn3 = new TGHorizontalFrame(fFB, 300, 100);
1059 frmBtn3->SetCleanup(kDeepCleanup);
1060 fBtnShow = new TGTextButton(frmBtn3, "Show packages");
1061 fBtnShow->SetToolTipText("Show (list) available packages on the server");
1063 kLHintsExpandX, 5, 5, 5, 5));
1064 fBtnShowEnabled = new TGTextButton(frmBtn3, "Show Enabled");
1065 fBtnShowEnabled->SetToolTipText("Show (list) enabled packages on the server");
1067 kLHintsExpandX, 5, 5, 5, 5));
1068 fFB->AddFrame(frmBtn3, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
1069
1070 fChkEnable = new TGCheckButton(fFB, "Enable at session startup");
1071 fChkEnable->SetToolTipText("Enable packages on the server at startup time");
1072 fFB->AddFrame(fChkEnable, new TGLayoutHints(kLHintsLeft, 5, 5, 5, 5));
1073
1074 // add "DataSets" tab element
1075 tf = fTab->AddTab("DataSets");
1076 fFE = new TGCompositeFrame(tf, 100, 100, kVerticalFrame);
1079
1080 // new frame containing datasets treeview and control buttons
1081 TGCompositeFrame* frmdataset = new TGHorizontalFrame(fFE, 350, 100);
1082
1083 // datasets list tree
1084 fDSetView = new TGCanvas(frmdataset, 200, 200, kSunkenFrame | kDoubleBorder);
1086 5, 5, 5, 5));
1088 fDataSetTree->AddItem(0, "DataSets");
1089
1090 // control buttons frame
1091 TGCompositeFrame* frmBut3 = new TGVerticalFrame(frmdataset, 150, 100);
1092
1093 fBtnUploadDSet = new TGTextButton(frmBut3, " Upload... ");
1094 fBtnUploadDSet->SetToolTipText("Upload a dataset to the cluster");
1096 kLHintsExpandX, 5, 5, 5, 5));
1097 fBtnRemoveDSet = new TGTextButton(frmBut3, "Remove");
1098 fBtnRemoveDSet->SetToolTipText("Remove dataset from the cluster");
1100 kLHintsExpandX, 5, 5, 5, 5));
1101 fBtnVerifyDSet = new TGTextButton(frmBut3, "Verify");
1102 fBtnVerifyDSet->SetToolTipText("Verify dataset on the cluster");
1104 kLHintsExpandX, 5, 5, 5, 5));
1105 fBtnRefresh = new TGTextButton(frmBut3, "Refresh List");
1106 fBtnRefresh->SetToolTipText("Refresh List of DataSet/Files present on the cluster");
1108 kLHintsExpandX, 5, 5, 15, 5));
1109
1110 frmdataset->AddFrame(frmBut3, new TGLayoutHints(kLHintsLeft | kLHintsCenterY |
1111 kLHintsExpandY, 5, 5, 5, 0));
1112
1113 fFE->AddFrame(frmdataset, new TGLayoutHints(kLHintsLeft | kLHintsTop |
1115
1116 // add "Options" tab element
1117 tf = fTab->AddTab("Options");
1118 fFD = new TGCompositeFrame(tf, 100, 100, kVerticalFrame);
1121
1122 // add Log Level label and text entry
1123 TGCompositeFrame* frmLog = new TGHorizontalFrame(fFD, 310, 100, kFixedWidth);
1124 frmLog->SetCleanup(kDeepCleanup);
1125 frmLog->AddFrame(fApplyLogLevel = new TGTextButton(frmLog,
1126 " Apply "), new TGLayoutHints(kLHintsRight |
1127 kLHintsCenterY, 10, 5, 5, 5));
1128 fApplyLogLevel->SetToolTipText("Apply currently selected log level");
1132 kLHintsCenterY, 5, 5, 5, 5));
1133 frmLog->AddFrame(new TGLabel(frmLog, "Log Level :"),
1134 new TGLayoutHints(kLHintsRight | kLHintsCenterY, 5, 5, 5, 5));
1135 fFD->AddFrame(frmLog, new TGLayoutHints(kLHintsLeft, 5, 5, 15, 5));
1136
1137 // add Parallel Nodes label and text entry
1138 TGCompositeFrame* frmPar = new TGHorizontalFrame(fFD, 310, 100, kFixedWidth);
1139 frmPar->SetCleanup(kDeepCleanup);
1140 frmPar->AddFrame(fApplyParallel = new TGTextButton(frmPar,
1141 " Apply "), new TGLayoutHints(kLHintsRight |
1142 kLHintsCenterY, 10, 5, 5, 5));
1143 fApplyParallel->SetToolTipText("Apply currently selected parallel nodes");
1144 fTxtParallel = new TGTextEntry(frmPar);
1146 fTxtParallel->SetText("99999");
1149 kLHintsCenterY, 5, 5, 5, 5));
1150 frmPar->AddFrame(new TGLabel(frmPar, "Set Parallel Nodes :"),
1151 new TGLayoutHints(kLHintsRight | kLHintsCenterY, 5, 5, 5, 5));
1152 fFD->AddFrame(frmPar, new TGLayoutHints(kLHintsLeft, 5, 5, 5, 5));
1153
1154 // connect button actions to functions
1155 fBtnShowLog->Connect("Clicked()", "TSessionFrame", this,
1156 "OnBtnShowLogClicked()");
1157 fBtnNewQuery->Connect("Clicked()", "TSessionFrame", this,
1158 "OnBtnNewQueryClicked()");
1159 fBtnGetQueries->Connect("Clicked()", "TSessionFrame", this,
1160 "OnBtnGetQueriesClicked()");
1161
1162 fChkEnable->Connect("Toggled(Bool_t)", "TSessionFrame", this,
1163 "OnStartupEnable(Bool_t)");
1164 fChkMulti->Connect("Toggled(Bool_t)", "TSessionFrame", this,
1165 "OnMultipleSelection(Bool_t)");
1166 fBtnAdd->Connect("Clicked()", "TSessionFrame", this,
1167 "OnBtnAddClicked()");
1168 fBtnRemove->Connect("Clicked()", "TSessionFrame", this,
1169 "OnBtnRemoveClicked()");
1170 fBtnUp->Connect("Clicked()", "TSessionFrame", this,
1171 "OnBtnUpClicked()");
1172 fBtnDown->Connect("Clicked()", "TSessionFrame", this,
1173 "OnBtnDownClicked()");
1174 fApplyLogLevel->Connect("Clicked()", "TSessionFrame", this,
1175 "OnApplyLogLevel()");
1176 fApplyParallel->Connect("Clicked()", "TSessionFrame", this,
1177 "OnApplyParallel()");
1178 fBtnUpload->Connect("Clicked()", "TSessionFrame", this,
1179 "OnUploadPackages()");
1180 fBtnEnable->Connect("Clicked()", "TSessionFrame", this,
1181 "OnEnablePackages()");
1182 fBtnDisable->Connect("Clicked()", "TSessionFrame", this,
1183 "OnDisablePackages()");
1184 fBtnClear->Connect("Clicked()", "TSessionFrame", this,
1185 "OnClearPackages()");
1186 fBtnShowEnabled->Connect("Clicked()", "TSessionViewer", fViewer,
1187 "ShowEnabledPackages()");
1188 fBtnShow->Connect("Clicked()", "TSessionViewer", fViewer,
1189 "ShowPackages()");
1190
1191 fBtnUploadDSet->Connect("Clicked()", "TSessionFrame", this,
1192 "OnBtnUploadDSet()");
1193 fBtnRemoveDSet->Connect("Clicked()", "TSessionFrame", this,
1194 "OnBtnRemoveDSet()");
1195 fBtnVerifyDSet->Connect("Clicked()", "TSessionFrame", this,
1196 "OnBtnVerifyDSet()");
1197 fBtnRefresh->Connect("Clicked()", "TSessionFrame", this,
1198 "UpdateListOfDataSets()");
1199}
1200
1201////////////////////////////////////////////////////////////////////////////////
1202/// Display information on current session.
1203
1205{
1206 TString buf;
1207
1208 // if local session
1209 if (fViewer->GetActDesc()->fLocal) {
1210 buf.Form("*** Local Session on %s ***", gSystem->HostName());
1211 fInfoLine[0]->SetText(buf.Data());
1212 UserGroup_t *userGroup = gSystem->GetUserInfo();
1213 fInfoLine[1]->SetText("User :");
1214 if (userGroup) buf.Form("%s", userGroup->fRealName.Data());
1215 fInfoLine[2]->SetText(buf.Data());
1216 fInfoLine[3]->SetText("Working directory :");
1217 buf.Form("%s", gSystem->WorkingDirectory());
1218 fInfoLine[4]->SetText(buf.Data());
1219 fInfoLine[5]->SetText(" ");
1220 fInfoLine[6]->SetText(" ");
1221 fInfoLine[7]->SetText(" ");
1222 fInfoLine[8]->SetText(" ");
1223 fInfoLine[9]->SetText(" ");
1224 fInfoLine[10]->SetText(" ");
1225 fInfoLine[11]->SetText(" ");
1226 fInfoLine[12]->SetText(" ");
1227 fInfoLine[13]->SetText(" ");
1228 fInfoLine[14]->SetText(" ");
1229 fInfoLine[15]->SetText(" ");
1230 fInfoLine[16]->SetText(" ");
1231 fInfoLine[17]->SetText(" ");
1232 fInfoLine[18]->SetText(" ");
1233 if (userGroup) delete userGroup;
1234 Layout();
1236 return;
1237 }
1238 // return if not a valid Proof session
1239 if (!fViewer->GetActDesc()->fConnected ||
1241 !fViewer->GetActDesc()->fProof ||
1243 return;
1244
1245 if (!fViewer->GetActDesc()->fProof->IsMaster()) {
1247 buf.Form("*** Connected to %s (parallel mode, %d workers) ***",
1250 else
1251 buf.Form("*** Connected to %s (sequential mode) ***",
1253 fInfoLine[0]->SetText(buf.Data());
1254 fInfoLine[1]->SetText("Port number : ");
1255 buf.Form("%d", fViewer->GetActDesc()->fProof->GetPort());
1256 fInfoLine[2]->SetText(buf.Data());
1257 fInfoLine[3]->SetText("User : ");
1258 buf.Form("%s", fViewer->GetActDesc()->fProof->GetUser());
1259 fInfoLine[4]->SetText(buf.Data());
1260 fInfoLine[5]->SetText("Client protocol version : ");
1262 fInfoLine[6]->SetText(buf.Data());
1263 fInfoLine[7]->SetText("Remote protocol version : ");
1265 fInfoLine[8]->SetText(buf.Data());
1266 fInfoLine[9]->SetText("Log level : ");
1267 buf.Form("%d", fViewer->GetActDesc()->fProof->GetLogLevel());
1268 fInfoLine[10]->SetText(buf.Data());
1269 fInfoLine[11]->SetText("Session unique tag : ");
1270 buf.Form("%s", fViewer->GetActDesc()->fProof->IsValid() ?
1271 fViewer->GetActDesc()->fProof->GetSessionTag() : " ");
1272 fInfoLine[12]->SetText(buf.Data());
1273 fInfoLine[13]->SetText("Total MB's processed :");
1274 buf.Form("%.2f", float(fViewer->GetActDesc()->fProof->GetBytesRead())/(1024*1024));
1275 fInfoLine[14]->SetText(buf.Data());
1276 fInfoLine[15]->SetText("Total real time used (s) :");
1277 buf.Form("%.3f", fViewer->GetActDesc()->fProof->GetRealTime());
1278 fInfoLine[16]->SetText(buf.Data());
1279 fInfoLine[17]->SetText("Total CPU time used (s) :");
1280 buf.Form("%.3f", fViewer->GetActDesc()->fProof->GetCpuTime());
1281 fInfoLine[18]->SetText(buf.Data());
1282 }
1283 else {
1285 buf.Form("*** Master server %s (parallel mode, %d workers) ***",
1288 else
1289 buf.Form("*** Master server %s (sequential mode) ***",
1291 fInfoLine[0]->SetText(buf.Data());
1292 fInfoLine[1]->SetText("Port number : ");
1293 buf.Form("%d", fViewer->GetActDesc()->fProof->GetPort());
1294 fInfoLine[2]->SetText(buf.Data());
1295 fInfoLine[3]->SetText("User : ");
1296 buf.Form("%s", fViewer->GetActDesc()->fProof->GetUser());
1297 fInfoLine[4]->SetText(buf.Data());
1298 fInfoLine[5]->SetText("Protocol version : ");
1300 fInfoLine[6]->SetText(buf.Data());
1301 fInfoLine[7]->SetText("Image name : ");
1302 buf.Form("%s",fViewer->GetActDesc()->fProof->GetImage());
1303 fInfoLine[8]->SetText(buf.Data());
1304 fInfoLine[9]->SetText("Config directory : ");
1305 buf.Form("%s", fViewer->GetActDesc()->fProof->GetConfDir());
1306 fInfoLine[10]->SetText(buf.Data());
1307 fInfoLine[11]->SetText("Config file : ");
1308 buf.Form("%s", fViewer->GetActDesc()->fProof->GetConfFile());
1309 fInfoLine[12]->SetText(buf.Data());
1310 fInfoLine[13]->SetText("Total MB's processed :");
1311 buf.Form("%.2f", float(fViewer->GetActDesc()->fProof->GetBytesRead())/(1024*1024));
1312 fInfoLine[14]->SetText(buf.Data());
1313 fInfoLine[15]->SetText("Total real time used (s) :");
1314 buf.Form("%.3f", fViewer->GetActDesc()->fProof->GetRealTime());
1315 fInfoLine[16]->SetText(buf.Data());
1316 fInfoLine[17]->SetText("Total CPU time used (s) :");
1317 buf.Form("%.3f", fViewer->GetActDesc()->fProof->GetCpuTime());
1318 fInfoLine[18]->SetText(buf.Data());
1319 }
1320 Layout();
1322}
1323
1324////////////////////////////////////////////////////////////////////////////////
1325/// Open Upload Dataset dialog.
1326
1328{
1329 if (fViewer->IsBusy())
1330 return;
1331 if (fViewer->GetActDesc()->fLocal) return;
1332 new TUploadDataSetDlg(fViewer, 450, 360);
1333}
1334
1335////////////////////////////////////////////////////////////////////////////////
1336/// Update list of dataset present on the cluster.
1337
1339{
1340 TObjString *dsetname;
1341 TFileInfo *dsetfilename;
1342 // cleanup the list
1347
1348 const TGPicture *dseticon = fClient->GetPicture("rootdb_t.xpm");
1349 // ask for the list of datasets
1350
1351 // TODO: is now returning a TMap; viewer has to be adapted
1352 TList *dsetlist = 0; //fViewer->GetActDesc()->fProof->GetDataSets();
1353 // coverity[dead_error_condition]: to be changed for TMap usage
1354 if (dsetlist) {
1355 TGListTreeItem *dsetitem;
1357 TIter nextdset(dsetlist);
1358 while ((dsetname = (TObjString *)nextdset())) {
1360 // add the dataset in the tree
1362 dsetname->GetName(), dsetname);
1363 // ask for the list of files in the dataset
1364 TList *dsetfilelist = fViewer->GetActDesc()->fProof->GetDataSet(
1365 dsetname->GetName())->GetList();
1366 if(dsetfilelist) {
1367 TIter nextdsetfile(dsetfilelist);
1368 while ((dsetfilename = (TFileInfo *)nextdsetfile())) {
1369 if (! fDataSetTree->FindItemByObj(dsetitem, dsetfilename)) {
1370 // if not already in, add the file name in the tree
1371 fDataSetTree->AddItem(dsetitem,
1372 dsetfilename->GetFirstUrl()->GetUrl(),
1373 dsetfilename, dseticon, dseticon);
1374 }
1375 }
1376 // open the dataset item in order to show the files
1377 fDataSetTree->OpenItem(dsetitem);
1378 }
1379 }
1380 }
1381 }
1382 }
1383 // refresh list tree
1385}
1386
1387////////////////////////////////////////////////////////////////////////////////
1388/// Remove dataset from the list and from the cluster.
1389
1391{
1392 TGListTreeItem *item;
1393 TObjString *obj = 0;
1394 if (fViewer->GetActDesc()->fLocal) return;
1395
1396 item = fDataSetTree->GetSelected();
1397 if (!item) return;
1398 if (item->GetParent() == 0) return;
1399 if (item->GetParent() == fDataSetTree->GetFirstItem()) {
1400 // Dataset itself
1401 obj = (TObjString *)item->GetUserData();
1402 }
1403 else if (item->GetParent()->GetParent() == fDataSetTree->GetFirstItem()) {
1404 // One file of the dataset
1405 obj = (TObjString *)item->GetParent()->GetUserData();
1406 }
1407
1408 // if valid Proof session, set parallel slaves
1409 if (obj && fViewer->GetActDesc()->fProof &&
1413 }
1414}
1415
1416////////////////////////////////////////////////////////////////////////////////
1417/// Verify that the files in the selected dataset are present on the cluster.
1418
1420{
1421 TGListTreeItem *item;
1422 TObjString *obj = 0;
1423 if (fViewer->GetActDesc()->fLocal) return;
1424
1425 item = fDataSetTree->GetSelected();
1426 if (!item) return;
1427 if (item->GetParent() == 0) return;
1428 if (item->GetParent() == fDataSetTree->GetFirstItem()) {
1429 // Dataset itself
1430 obj = (TObjString *)item->GetUserData();
1431 }
1432 else if (item->GetParent()->GetParent() == fDataSetTree->GetFirstItem()) {
1433 // One file of the dataset
1434 obj = (TObjString *)item->GetParent()->GetUserData();
1435 }
1436
1437 // if valid Proof session, set parallel slaves
1438 if (obj && fViewer->GetActDesc()->fProof &&
1441 }
1442}
1443
1444////////////////////////////////////////////////////////////////////////////////
1445/// Apply selected log level on current session.
1446
1448{
1449 // if local session, do nothing
1450 if (fViewer->GetActDesc()->fLocal) return;
1451 // if valid Proof session, set log level
1452 if (fViewer->GetActDesc()->fProof &&
1456 }
1458}
1459
1460////////////////////////////////////////////////////////////////////////////////
1461/// Apply selected number of workers on current Proof session.
1462
1464{
1465 // if local session, do nothing
1466 if (fViewer->GetActDesc()->fLocal) return;
1467 // if valid Proof session, set parallel slaves
1468 if (fViewer->GetActDesc()->fProof &&
1470 Int_t nodes = atoi(fTxtParallel->GetText());
1472 }
1474}
1475
1476////////////////////////////////////////////////////////////////////////////////
1477/// Handle multiple selection check button.
1478
1480{
1482}
1483
1484////////////////////////////////////////////////////////////////////////////////
1485/// Handle multiple selection check button.
1486
1488{
1489 if (fViewer->GetActDesc())
1491}
1492
1493////////////////////////////////////////////////////////////////////////////////
1494/// Update list of packages.
1495
1497{
1498 TPackageDescription *package;
1499 const TGPicture *pict;
1502 while ((package = (TPackageDescription *)next())) {
1503 if (package->fEnabled)
1504 pict = fClient->GetPicture("package_add.xpm");
1505 else if (package->fUploaded)
1506 pict = fClient->GetPicture("package_delete.xpm");
1507 else
1508 pict = fClient->GetPicture("package.xpm");
1510 package->fId, package->fPathName, pict);
1512 }
1515}
1516
1517////////////////////////////////////////////////////////////////////////////////
1518/// Upload selected package(s) to the current session.
1519
1521{
1522 // if local session, do nothing
1523 if (fViewer->GetActDesc()->fLocal) return;
1524 // if valid Proof session, upload packages
1525 if (fViewer->GetActDesc()->fProof &&
1527 TObject *obj;
1528 TList selected;
1529 fLBPackages->GetSelectedEntries(&selected);
1530 TIter next(&selected);
1531 while ((obj = next())) {
1532 TString name = obj->GetTitle();
1533 if (fViewer->GetActDesc()->fProof->UploadPackage(name.Data()) != 0)
1534 Error("Submit", "Upload package failed");
1535 else {
1537 if (!o) continue;
1538 TPackageDescription *package =
1539 dynamic_cast<TPackageDescription *>(o);
1540 if (package) {
1541 package->fUploaded = kTRUE;
1542 ((TGIconLBEntry *)obj)->SetPicture(
1543 fClient->GetPicture("package_delete.xpm"));
1544 }
1545 }
1546 }
1548 }
1551}
1552
1553////////////////////////////////////////////////////////////////////////////////
1554/// Enable selected package(s) in the current session.
1555
1557{
1558 // if local session, do nothing
1559 if (fViewer->GetActDesc()->fLocal) return;
1560 // if valid Proof session, enable packages
1561 if (fViewer->GetActDesc()->fProof &&
1563 TObject *obj;
1564 TList selected;
1566 fLBPackages->GetSelectedEntries(&selected);
1567 TIter next(&selected);
1568 while ((obj = next())) {
1569 TString name = obj->GetTitle();
1571 if (!o) continue;
1572 TPackageDescription *package =
1573 dynamic_cast<TPackageDescription *>(o);
1574 if (package) {
1575 if (!package->fUploaded) {
1576 if (fViewer->GetActDesc()->fProof->UploadPackage(name.Data()) != 0)
1577 Error("Submit", "Upload package failed");
1578 else {
1579 package->fUploaded = kTRUE;
1580 ((TGIconLBEntry *)obj)->SetPicture(
1581 fClient->GetPicture("package_delete.xpm"));
1582 }
1583 }
1584 }
1586 Error("Submit", "Enable package failed");
1587 else {
1588 package->fEnabled = kTRUE;
1589 ((TGIconLBEntry *)obj)->SetPicture(fClient->GetPicture("package_add.xpm"));
1590 }
1591 }
1594 }
1597}
1598
1599////////////////////////////////////////////////////////////////////////////////
1600/// Disable selected package(s) in the current session.
1601
1603{
1604 // if local session, do nothing
1605 if (fViewer->GetActDesc()->fLocal) return;
1606 // if valid Proof session, disable (clear) packages
1607 if (fViewer->GetActDesc()->fProof &&
1609 TObject *obj;
1610 TList selected;
1611 fLBPackages->GetSelectedEntries(&selected);
1612 TIter next(&selected);
1613 while ((obj = next())) {
1614 TString name = obj->GetTitle();
1615 if (fViewer->GetActDesc()->fProof->ClearPackage(name) != 0)
1616 Error("Submit", "Clear package failed");
1617 else {
1619 if (!o) continue;
1620 TPackageDescription *package =
1621 dynamic_cast<TPackageDescription *>(o);
1622 if (package) {
1623 package->fEnabled = kFALSE;
1624 package->fUploaded = kFALSE;
1625 ((TGIconLBEntry *)obj)->SetPicture(fClient->GetPicture("package.xpm"));
1626 }
1627 }
1628 }
1630 }
1633}
1634
1635////////////////////////////////////////////////////////////////////////////////
1636/// Clear (disable) all packages in the current session.
1637
1639{
1640 TPackageDescription *package;
1641 // if local session, do nothing
1642 if (fViewer->GetActDesc()->fLocal) return;
1643 // if valid Proof session, clear packages
1644 if (fViewer->GetActDesc()->fProof &&
1646 if (fViewer->GetActDesc()->fProof->ClearPackages() != 0)
1647 Error("Submit", "Clear packages failed");
1648 else {
1650 while ((package = (TPackageDescription *)next())) {
1651 package->fEnabled = kFALSE;
1652 }
1653 }
1654 }
1657}
1658
1659////////////////////////////////////////////////////////////////////////////////
1660/// Open file dialog and add selected package file to the list.
1661
1663{
1664 if (fViewer->IsBusy())
1665 return;
1666 TGFileInfo fi;
1667 TPackageDescription *package;
1668 TGIconLBEntry *entry;
1669 fi.fFileTypes = pkgtypes;
1671 if (fi.fMultipleSelection && fi.fFileNamesList) {
1672 TObjString *el;
1673 TIter next(fi.fFileNamesList);
1674 while ((el = (TObjString *) next())) {
1675 package = new TPackageDescription;
1676 package->fName = gSystem->BaseName(gSystem->UnixPathName(el->GetString()));
1677 package->fPathName = gSystem->UnixPathName(el->GetString());
1678 package->fId = fViewer->GetActDesc()->fPackages->GetEntries();
1679 package->fUploaded = kFALSE;
1680 package->fEnabled = kFALSE;
1681 fViewer->GetActDesc()->fPackages->Add((TObject *)package);
1682 entry = new TGIconLBEntry(fLBPackages->GetContainer(),
1683 package->fId, package->fPathName,
1684 fClient->GetPicture("package.xpm"));
1686 }
1687 }
1688 else if (fi.fFilename) {
1689 package = new TPackageDescription;
1691 package->fPathName = gSystem->UnixPathName(fi.fFilename);
1692 package->fId = fViewer->GetActDesc()->fPackages->GetEntries();
1693 package->fUploaded = kFALSE;
1694 package->fEnabled = kFALSE;
1695 fViewer->GetActDesc()->fPackages->Add((TObject *)package);
1696 entry = new TGIconLBEntry(fLBPackages->GetContainer(),
1697 package->fId, package->fPathName,
1698 fClient->GetPicture("package.xpm"));
1700 }
1703}
1704
1705////////////////////////////////////////////////////////////////////////////////
1706/// Remove selected package from the list.
1707
1709{
1710 TPackageDescription *package;
1711 const TGPicture *pict;
1712 Int_t pos = fLBPackages->GetSelected();
1715 fViewer->GetActDesc()->fPackages->At(pos));
1716 Int_t id = 0;
1718 while ((package = (TPackageDescription *)next())) {
1719 package->fId = id;
1720 id++;
1721 if (package->fEnabled)
1722 pict = fClient->GetPicture("package_add.xpm");
1723 else if (package->fUploaded)
1724 pict = fClient->GetPicture("package_delete.xpm");
1725 else
1726 pict = fClient->GetPicture("package.xpm");
1728 package->fId, package->fPathName, pict);
1730 }
1733}
1734
1735////////////////////////////////////////////////////////////////////////////////
1736/// Move selected package entry one position up in the list.
1737
1739{
1740 TPackageDescription *package;
1741 const TGPicture *pict;
1742 Int_t pos = fLBPackages->GetSelected();
1743 if (pos <= 0) return;
1745 package = (TPackageDescription *)fViewer->GetActDesc()->fPackages->At(pos);
1747 fViewer->GetActDesc()->fPackages->At(pos));
1748 package->fId -= 1;
1749 fViewer->GetActDesc()->fPackages->AddAt(package, package->fId);
1750 Int_t id = 0;
1752 while ((package = (TPackageDescription *)next())) {
1753 package->fId = id;
1754 id++;
1755 if (package->fEnabled)
1756 pict = fClient->GetPicture("package_add.xpm");
1757 else if (package->fUploaded)
1758 pict = fClient->GetPicture("package_delete.xpm");
1759 else
1760 pict = fClient->GetPicture("package.xpm");
1762 package->fId, package->fPathName, pict);
1764 }
1765 fLBPackages->Select(pos-1);
1768}
1769
1770////////////////////////////////////////////////////////////////////////////////
1771/// Move selected package entry one position down in the list.
1772
1774{
1775 TPackageDescription *package;
1776 const TGPicture *pict;
1777 Int_t pos = fLBPackages->GetSelected();
1778 if (pos == -1 || pos == fViewer->GetActDesc()->fPackages->GetEntries()-1)
1779 return;
1781 package = (TPackageDescription *)fViewer->GetActDesc()->fPackages->At(pos);
1783 fViewer->GetActDesc()->fPackages->At(pos));
1784 package->fId += 1;
1785 fViewer->GetActDesc()->fPackages->AddAt(package, package->fId);
1786 Int_t id = 0;
1788 while ((package = (TPackageDescription *)next())) {
1789 package->fId = id;
1790 id++;
1791 if (package->fEnabled)
1792 pict = fClient->GetPicture("package_add.xpm");
1793 else if (package->fUploaded)
1794 pict = fClient->GetPicture("package_delete.xpm");
1795 else
1796 pict = fClient->GetPicture("package.xpm");
1798 package->fId, package->fPathName, pict);
1800 }
1801 fLBPackages->Select(pos+1);
1804}
1805
1806////////////////////////////////////////////////////////////////////////////////
1807/// Disconnect from current Proof session.
1808
1810{
1811 // if local session, do nothing
1812 if (fViewer->GetActDesc()->fLocal) return;
1813 // if valid Proof session, disconnect (close)
1814 if (fViewer->GetActDesc()->fAttached &&
1818 }
1819 // reset connected flag
1821 fViewer->GetActDesc()->fProof = 0;
1822 // disable animation timer
1824 // change list tree item picture to disconnected pixmap
1827 if (item) {
1830 }
1831 // update viewer
1833 1, 0, 0);
1836 fViewer->GetStatusBar()->SetText("", 1);
1837}
1838
1839////////////////////////////////////////////////////////////////////////////////
1840/// Show session log.
1841
1843{
1844 fViewer->ShowLog(0);
1845}
1846
1847////////////////////////////////////////////////////////////////////////////////
1848/// Call "New Query" Dialog.
1849
1851{
1852 TNewQueryDlg *dlg = new TNewQueryDlg(fViewer, 350, 310);
1853 dlg->Popup();
1854}
1855
1856////////////////////////////////////////////////////////////////////////////////
1857/// Get list of queries from current Proof server and populate the list tree.
1858
1860{
1861 TList *lqueries = 0;
1862 TQueryResult *query = 0;
1863 TQueryDescription *newquery = 0, *lquery = 0;
1864 if (fViewer->GetActDesc()->fProof &&
1866 lqueries = fViewer->GetActDesc()->fProof->GetListOfQueries();
1867 }
1868 if (lqueries) {
1869 TIter nextp(lqueries);
1870 // loop over list of queries received from Proof server
1871 while ((query = (TQueryResult *)nextp())) {
1872 // create new query description
1873 newquery = new TQueryDescription();
1874 newquery->fReference = TString::Format("%s:%s", query->GetTitle(),
1875 query->GetName());
1876 // check in our tree if it is already there
1877 TGListTreeItem *item =
1880 // if already there, skip
1882 newquery->fReference.Data()))
1883 continue;
1884 // check also in our query description list
1885 Bool_t found = kFALSE;
1886 TIter nextp2(fViewer->GetActDesc()->fQueries);
1887 while ((lquery = (TQueryDescription *)nextp2())) {
1888 if (lquery->fReference.CompareTo(newquery->fReference) == 0) {
1889 found = kTRUE;
1890 break;
1891 }
1892 }
1893 if (found) continue;
1894 // build new query description with infos from Proof
1895 newquery->fStatus = query->IsFinalized() ?
1898 newquery->fSelectorString = query->GetSelecImp()->GetName();
1899 newquery->fQueryName = TString::Format("%s:%s", query->GetTitle(),
1900 query->GetName());
1901 newquery->fOptions = query->GetOptions();
1902 newquery->fEventList = "";
1903 newquery->fNbFiles = 0;
1904 newquery->fNoEntries = query->GetEntries();
1905 newquery->fFirstEntry = query->GetFirst();
1906 newquery->fResult = query;
1907 newquery->fChain = 0;
1908 fViewer->GetActDesc()->fQueries->Add((TObject *)newquery);
1910 newquery->fQueryName, fViewer->GetQueryConPict(),
1912 item2->SetUserData(newquery);
1913 if (query->GetInputList())
1914 fViewer->GetSessionHierarchy()->AddItem(item2, "InputList");
1915 if (query->GetOutputList())
1916 fViewer->GetSessionHierarchy()->AddItem(item2, "OutputList");
1917 }
1918 }
1919 // at the end, update list tree
1922}
1923
1924////////////////////////////////////////////////////////////////////////////////
1925/// Command line handling.
1926
1928{
1929 // get command string
1930 const char *cmd = fCommandTxt->GetText();
1931 char opt[2];
1932 // form temporary file path
1933 TString pathtmp = TString::Format("%s/%s", gSystem->TempDirectory(),
1935 // if check box "clear view" is checked, open temp file in write mode
1936 // (overwrite), in append mode otherwise.
1937 if (fClearCheck->IsOn())
1938 snprintf(opt, 2, "w");
1939 else
1940 snprintf(opt, 2, "a");
1941
1942 // if valid Proof session, pass the command to Proof
1943 if (fViewer->GetActDesc()->fProof &&
1945 // redirect stdout/stderr to temp file
1946 if (gSystem->RedirectOutput(pathtmp.Data(), opt) != 0) {
1947 Error("ShowStatus", "stdout/stderr redirection failed; skipping");
1948 return;
1949 }
1950 // execute command line
1951 fViewer->GetActDesc()->fProof->Exec(cmd);
1952 // restore back stdout/stderr
1953 if (gSystem->RedirectOutput(0) != 0) {
1954 Error("ShowStatus", "stdout/stderr retore failed; skipping");
1955 return;
1956 }
1957 // if check box "clear view" is checked, clear text view
1958 if (fClearCheck->IsOn())
1960 // load (display) temp file in text view
1961 fInfoTextView->LoadFile(pathtmp.Data());
1962 // set focus to "command line" text entry
1964 }
1965 else {
1966 // if no Proof session, or Proof session not valid,
1967 // lets execute command line by TApplication
1968
1969 // redirect stdout/stderr to temp file
1970 if (gSystem->RedirectOutput(pathtmp.Data(), opt) != 0) {
1971 Error("ShowStatus", "stdout/stderr redirection failed; skipping");
1972 }
1973 // execute command line
1975 // restore back stdout/stderr
1976 if (gSystem->RedirectOutput(0) != 0) {
1977 Error("ShowStatus", "stdout/stderr retore failed; skipping");
1978 }
1979 // if check box "clear view" is checked, clear text view
1980 if (fClearCheck->IsOn())
1982 // load (display) temp file in text view
1983 fInfoTextView->LoadFile(pathtmp.Data());
1984 // set focus to "command line" text entry
1986 }
1987 // display bottom of text view
1989}
1990
1991////////////////////////////////////////////////////////////////////////////////
1992/// Switch widgets status/visibility for local/remote sessions.
1993
1995{
1996 if (local) {
1999 fTab->HideFrame(fTab->GetTabTab("Options"));
2000 fTab->HideFrame(fTab->GetTabTab("Packages"));
2001 fTab->HideFrame(fTab->GetTabTab("DataSets"));
2002 }
2003 else {
2006 fTab->ShowFrame(fTab->GetTabTab("Options"));
2007 fTab->ShowFrame(fTab->GetTabTab("Packages"));
2008 fTab->ShowFrame(fTab->GetTabTab("DataSets"));
2009 }
2010}
2011
2012////////////////////////////////////////////////////////////////////////////////
2013/// Shutdown current session.
2014
2016{
2017 // do nothing if connection in progress
2018 if (fViewer->IsBusy())
2019 return;
2020
2021 if (fViewer->GetActDesc()->fLocal) {
2022 Int_t retval;
2023 new TGMsgBox(fClient->GetRoot(), this, "Error Shutting down Session",
2024 "Shutting down Local Sessions is not allowed !",
2025 kMBIconExclamation,kMBOk,&retval);
2026 return;
2027 }
2028 if (!fViewer->GetActDesc()->fAttached ||
2029 !fViewer->GetActDesc()->fProof ||
2031 return;
2032 // ask for confirmation
2033 TString m;
2034 m.Form("Are you sure to shutdown the session \"%s\"",
2036 Int_t result;
2037 new TGMsgBox(fClient->GetRoot(), this, "", m.Data(), 0,
2038 kMBOk | kMBCancel, &result);
2039 // if confirmed, delete it
2040 if (result != kMBOk)
2041 return;
2042 // remove the Proof session from gROOT list of Proofs
2043 fViewer->GetActDesc()->fProof->Detach("S");
2044 // reset connected flag
2046 fViewer->GetActDesc()->fProof = 0;
2047 // disable animation timer
2049 // change list tree item picture to disconnected pixmap
2052 if (item) {
2055 }
2056 // update viewer
2058 1, 0, 0);
2061 fViewer->GetStatusBar()->SetText("", 1);
2062}
2063
2064//////////////////////////////////////////////////////////////////////////
2065// Edit Query Frame
2066//////////////////////////////////////////////////////////////////////////
2067
2068////////////////////////////////////////////////////////////////////////////////
2069/// Create a new Query dialog, used by the Session Viewer, to Edit a Query if
2070/// the editmode flag is set, or to create a new one if not set.
2071
2073 TGCompositeFrame(p, w, h, kVerticalFrame), fFrmMore(0), fBtnMore(0),
2074 fTxtQueryName(0), fTxtChain(0), fTxtSelector(0), fTxtOptions(0),
2075 fNumEntries(0), fNumFirstEntry(0), fTxtParFile(0), fTxtEventList(0),
2076 fViewer(0), fQuery(0), fChain(0)
2077{
2078}
2079
2080////////////////////////////////////////////////////////////////////////////////
2081/// Delete query dialog.
2082
2084{
2085 Cleanup();
2086}
2087
2088////////////////////////////////////////////////////////////////////////////////
2089/// Build the "new query" dialog.
2090
2092{
2093 TGButton *btnTmp;
2094 fViewer = gui;
2096 SetLayoutManager(new TGTableLayout(this, 6, 5));
2097
2098 // add "Query Name" label and text entry
2099 AddFrame(new TGLabel(this, "Query Name :"),
2100 new TGTableLayoutHints(0, 1, 0, 1, kLHintsCenterY, 5, 5, 4, 0));
2102 (const char *)0, 1), new TGTableLayoutHints(1, 2, 0, 1,
2103 kLHintsCenterY, 5, 5, 4, 0));
2104
2105 // add "TChain" label and text entry
2106 AddFrame(new TGLabel(this, "TChain :"),
2107 new TGTableLayoutHints(0, 1, 1, 2, kLHintsCenterY, 5, 5, 4, 0));
2108 AddFrame(fTxtChain = new TGTextEntry(this,
2109 (const char *)0, 2), new TGTableLayoutHints(1, 2, 1, 2,
2110 kLHintsCenterY, 5, 5, 4, 0));
2111 fTxtChain->SetToolTipText("Specify TChain or TDSet from memory or file");
2113 // add "Browse" button
2114 AddFrame(btnTmp = new TGTextButton(this, "Browse..."),
2115 new TGTableLayoutHints(2, 3, 1, 2, kLHintsCenterY, 5, 0, 4, 8));
2116 btnTmp->Connect("Clicked()", "TEditQueryFrame", this, "OnBrowseChain()");
2117
2118 // add "Selector" label and text entry
2119 AddFrame(new TGLabel(this, "Selector :"),
2120 new TGTableLayoutHints(0, 1, 2, 3, kLHintsCenterY, 5, 5, 0, 0));
2122 (const char *)0, 3), new TGTableLayoutHints(1, 2, 2, 3,
2123 kLHintsCenterY, 5, 5, 0, 0));
2124 // add "Browse" button
2125 AddFrame(btnTmp = new TGTextButton(this, "Browse..."),
2126 new TGTableLayoutHints(2, 3, 2, 3, kLHintsCenterY, 5, 0, 0, 8));
2127 btnTmp->Connect("Clicked()", "TEditQueryFrame", this, "OnBrowseSelector()");
2128
2129 // add "Less <<" ("More >>") button
2130 AddFrame(fBtnMore = new TGTextButton(this, " Less << "),
2131 new TGTableLayoutHints(2, 3, 4, 5, kLHintsCenterY, 5, 5, 4, 0));
2132 fBtnMore->Connect("Clicked()", "TEditQueryFrame", this, "OnNewQueryMore()");
2133
2134 // add (initially hidden) options frame
2135 fFrmMore = new TGCompositeFrame(this, 200, 200);
2137
2138 AddFrame(fFrmMore, new TGTableLayoutHints(0, 3, 5, 6,
2141
2142 // add "Options" label and text entry
2143 fFrmMore->AddFrame(new TGLabel(fFrmMore, "Options :"),
2144 new TGTableLayoutHints(0, 1, 0, 1, kLHintsCenterY, 5, 5, 0, 0));
2146 (const char *)0, 4), new TGTableLayoutHints(1, 2, 0, 1, 0, 17,
2147 0, 0, 8));
2148 //fTxtOptions->SetText("ASYN");
2149 fTxtOptions->SetText("");
2150
2151 // add "Nb Entries" label and number entry
2152 fFrmMore->AddFrame(new TGLabel(fFrmMore, "Nb Entries :"),
2153 new TGTableLayoutHints(0, 1, 1, 2, kLHintsCenterY, 5, 5, 0, 0));
2157 0, 17, 0, 0, 8));
2158 // coverity[negative_returns]: no problem with -1, the format is kNESInteger
2160 // add "First Entry" label and number entry
2161 fFrmMore->AddFrame(new TGLabel(fFrmMore, "First entry :"),
2162 new TGTableLayoutHints(0, 1, 2, 3, kLHintsCenterY, 5, 5, 0, 0));
2166 17, 0, 0, 8));
2167
2168 // add "Event list" label and text entry
2169 fFrmMore->AddFrame(new TGLabel(fFrmMore, "Event list :"),
2170 new TGTableLayoutHints(0, 1, 3, 4, kLHintsCenterY, 5, 5, 0, 0));
2172 (const char *)0, 6), new TGTableLayoutHints(1, 2, 3, 4, 0, 17,
2173 5, 0, 0));
2174 // add "Browse" button
2175 fFrmMore->AddFrame(btnTmp = new TGTextButton(fFrmMore, "Browse..."),
2176 new TGTableLayoutHints(2, 3, 3, 4, 0, 6, 0, 0, 8));
2177 btnTmp->Connect("Clicked()", "TEditQueryFrame", this, "OnBrowseEventList()");
2178
2179 fTxtQueryName->Associate(this);
2180 fTxtChain->Associate(this);
2181 fTxtSelector->Associate(this);
2182 fTxtOptions->Associate(this);
2183 fNumEntries->Associate(this);
2185 fTxtEventList->Associate(this);
2186
2187 fTxtQueryName->Connect("TextChanged(char*)", "TEditQueryFrame", this,
2188 "SettingsChanged()");
2189 fTxtChain->Connect("TextChanged(char*)", "TEditQueryFrame", this,
2190 "SettingsChanged()");
2191 fTxtSelector->Connect("TextChanged(char*)", "TEditQueryFrame", this,
2192 "SettingsChanged()");
2193 fTxtOptions->Connect("TextChanged(char*)", "TEditQueryFrame", this,
2194 "SettingsChanged()");
2195 fNumEntries->Connect("ValueChanged(Long_t)", "TEditQueryFrame", this,
2196 "SettingsChanged()");
2197 fNumFirstEntry->Connect("ValueChanged(Long_t)", "TEditQueryFrame", this,
2198 "SettingsChanged()");
2199 fTxtEventList->Connect("TextChanged(char*)", "TEditQueryFrame", this,
2200 "SettingsChanged()");
2201}
2202
2203////////////////////////////////////////////////////////////////////////////////
2204/// Show/hide options frame and update button text accordingly.
2205
2207{
2208 if (IsVisible(fFrmMore)) {
2210 fBtnMore->SetText(" More >> ");
2211 }
2212 else {
2214 fBtnMore->SetText(" Less << ");
2215 }
2216}
2217
2218////////////////////////////////////////////////////////////////////////////////
2219/// Call new chain dialog.
2220
2222{
2223 TNewChainDlg *dlg = new TNewChainDlg(fClient->GetRoot(), this);
2224 dlg->Connect("OnElementSelected(TObject *)", "TEditQueryFrame",
2225 this, "OnElementSelected(TObject *)");
2226}
2227
2228////////////////////////////////////////////////////////////////////////////////
2229/// Handle OnElementSelected signal coming from new chain dialog.
2230
2232{
2233 if (obj) {
2234 fChain = obj;
2235 if (obj->IsA() == TChain::Class())
2237 else if (obj->IsA() == TDSet::Class())
2238 fTxtChain->SetText(((TDSet *)fChain)->GetObjName());
2239 }
2240}
2241
2242////////////////////////////////////////////////////////////////////////////////
2243/// Open file browser to choose selector macro.
2244
2246{
2247 TGFileInfo fi;
2249 new TGFileDialog(fClient->GetRoot(), this, kFDOpen, &fi);
2250 if (!fi.fFilename) return;
2252}
2253
2254////////////////////////////////////////////////////////////////////////////////
2255///Browse event list
2256
2258{
2259}
2260
2261////////////////////////////////////////////////////////////////////////////////
2262/// Save current settings in main session viewer.
2263
2265{
2266 // if we are in edition mode and query description is valid,
2267 // use it, otherwise create a new one
2268 TQueryDescription *newquery;
2269 if (fQuery)
2270 newquery = fQuery;
2271 else
2272 newquery = new TQueryDescription();
2273
2274 // update query description fields
2275 newquery->fSelectorString = fTxtSelector->GetText();
2276 if (fChain) {
2277 newquery->fTDSetString = fChain->GetName();
2278 newquery->fChain = fChain;
2279 }
2280 else {
2281 newquery->fTDSetString = "";
2282 newquery->fChain = 0;
2283 }
2284 newquery->fQueryName = fTxtQueryName->GetText();
2285 newquery->fOptions = fTxtOptions->GetText();
2286 newquery->fNoEntries = fNumEntries->GetIntNumber();
2288 newquery->fNbFiles = 0;
2289 newquery->fResult = 0;
2290
2291 if (newquery->fChain) {
2292 if (newquery->fChain->IsA() == TChain::Class())
2293 newquery->fNbFiles = ((TChain *)newquery->fChain)->GetListOfFiles()->GetEntriesFast();
2294 else if (newquery->fChain->IsA() == TDSet::Class())
2295 newquery->fNbFiles = ((TDSet *)newquery->fChain)->GetListOfElements()->GetSize();
2296 }
2297 // update user data with modified query description
2299 fViewer->GetSessionHierarchy()->RenameItem(item, newquery->fQueryName);
2300 item->SetUserData(newquery);
2301 // update list tree
2308 if (fViewer->GetActDesc()->fLocal ||
2312 fViewer->GetActDesc()->fProof->IsValid())) {
2313 fViewer->GetQueryFrame()->GetTab()->SetTab("Status");
2315 }
2316}
2317
2318////////////////////////////////////////////////////////////////////////////////
2319/// Settings have changed, update GUI accordingly.
2320
2322{
2323 if (fQuery) {
2324 if ((strcmp(fQuery->fSelectorString.Data(), fTxtSelector->GetText())) ||
2325 (strcmp(fQuery->fQueryName.Data(), fTxtQueryName->GetText())) ||
2326 (strcmp(fQuery->fOptions.Data(), fTxtOptions->GetText())) ||
2329 (fQuery->fChain != fChain)) {
2331 }
2332 else {
2334 }
2335 }
2336 else {
2337 if ((fTxtQueryName->GetText()) &&
2338 ((fTxtQueryName->GetText()) ||
2339 (fTxtChain->GetText())))
2341 else
2343 }
2344}
2345
2346////////////////////////////////////////////////////////////////////////////////
2347/// Update entry fields with query description values.
2348
2350{
2351 fChain = 0;
2352 fQuery = desc;
2353 fTxtChain->SetText("");
2354 if (desc->fChain) {
2355 fChain = desc->fChain;
2357 }
2364}
2365
2366////////////////////////////////////////////////////////////////////////////////
2367// Query Frame
2368
2369////////////////////////////////////////////////////////////////////////////////
2370/// Constructor
2371
2373 TGCompositeFrame(p, w, h), fBtnSubmit(0), fBtnFinalize(0), fBtnStop(0),
2374 fBtnAbort(0), fBtnShowLog(0), fBtnRetrieve(0), fBtnSave(0), fInfoTextView(0),
2375 fModified(0), fFiles(0), fFirst(0), fEntries(0), fPrevTotal(0),
2376 fPrevProcessed(0), fLabInfos(0), fLabStatus(0), fTotal(0), fRate(0),
2377 fStatus(kStopped), fTab(0), fFA(0), fFB(0), fFC(0), fFD(0), frmProg(0),
2378 fECanvas(0), fStatsCanvas(0), fViewer(0), fDesc(0)
2379{
2380}
2381
2382////////////////////////////////////////////////////////////////////////////////
2383/// Destructor.
2384
2386{
2387 Cleanup();
2388}
2389
2390////////////////////////////////////////////////////////////////////////////////
2391/// Build query information frame.
2392
2394{
2397 fFirst = fEntries = fPrevTotal = 0;
2398 fPrevProcessed = 0;
2399 fViewer = gui;
2400 fModified = kFALSE;
2401
2402 // main query tab
2403 fTab = new TGTab(this, 200, 200);
2405 kLHintsExpandY, 2, 2, 2, 2));
2406
2407 // add "Status" tab element
2408 TGCompositeFrame *tf = fTab->AddTab("Status");
2409 fFB = new TGCompositeFrame(tf, 100, 100, kVerticalFrame);
2412
2413 // new frame containing control buttons and feedback histos canvas
2414 TGCompositeFrame* frmcanvas = new TGHorizontalFrame(fFB, 350, 100);
2415 // control buttons frame
2416 TGCompositeFrame* frmBut2 = new TGVerticalFrame(frmcanvas, 150, 100);
2417 fBtnSubmit = new TGTextButton(frmBut2, " Submit ");
2418 fBtnSubmit->SetToolTipText("Submit (process) selected query");
2420 kLHintsExpandX, 5, 5, 5, 5));
2421 fBtnStop = new TGTextButton(frmBut2, "Stop");
2422 fBtnStop->SetToolTipText("Stop processing query");
2424 kLHintsExpandX, 5, 5, 5, 5));
2425 fBtnAbort = new TGTextButton(frmBut2, "Abort");
2426 fBtnAbort->SetToolTipText("Abort processing query");
2428 kLHintsExpandX, 5, 5, 5, 5));
2429 frmcanvas->AddFrame(frmBut2, new TGLayoutHints(kLHintsLeft | kLHintsCenterY |
2431 // feedback histos embedded canvas
2432 fECanvas = new TRootEmbeddedCanvas("fECanvas", frmcanvas, 400, 150);
2437 4, 4, 4, 4));
2438 fFB->AddFrame(frmcanvas, new TGLayoutHints(kLHintsLeft | kLHintsTop |
2440
2441 // progress infos label
2442 fLabInfos = new TGLabel(fFB, " ");
2443 fFB->AddFrame(fLabInfos, new TGLayoutHints(kLHintsLeft, 5, 5, 5, 5));
2444 // progress status label
2445 fLabStatus = new TGLabel(fFB, " ");
2446 fFB->AddFrame(fLabStatus, new TGLayoutHints(kLHintsLeft, 5, 5, 5, 5));
2447
2448 //progress bar
2451 frmProg->SetBarColor("green");
2452 fFB->AddFrame(frmProg, new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5));
2453 // total progress infos
2454 fFB->AddFrame(fTotal = new TGLabel(fFB,
2455 " Estimated time left : 0 sec (--- events of --- processed) "),
2456 new TGLayoutHints(kLHintsLeft, 5, 5, 5, 5));
2457 // progress rate infos
2458 fFB->AddFrame(fRate = new TGLabel(fFB,
2459 " Processing Rate : -- events/sec "),
2460 new TGLayoutHints(kLHintsLeft, 5, 5, 5, 5));
2461
2462 // add "Results" tab element
2463 tf = fTab->AddTab("Results");
2464 fFC = new TGCompositeFrame(tf, 100, 100, kVerticalFrame);
2467 // query result (header) information text view
2468 fInfoTextView = new TGTextView(fFC, 330, 185, "", kSunkenFrame |
2471 kLHintsExpandY | kLHintsExpandX, 5, 5, 10, 10));
2472
2473 // add "Retrieve", "Finalize" and "Show Log" buttons
2474 TGCompositeFrame* frmBut3 = new TGHorizontalFrame(fFC, 350, 100);
2475 fBtnRetrieve = new TGTextButton(frmBut3, "Retrieve");
2476 fBtnRetrieve->SetToolTipText("Retrieve query results");
2478 kLHintsExpandX, 5, 5, 10, 10));
2479 fBtnFinalize = new TGTextButton(frmBut3, "Finalize");
2480 fBtnFinalize->SetToolTipText("Finalize query");
2482 kLHintsExpandX, 5, 5, 10, 10));
2483 fBtnShowLog = new TGTextButton(frmBut3, "Show Log");
2484 fBtnShowLog->SetToolTipText("Show query log (open log window)");
2486 kLHintsExpandX, 5, 5, 10, 10));
2488
2489 // add "Results" tab element
2490 tf = fTab->AddTab("Edit Query");
2491 fFD = new TEditQueryFrame(tf, 100, 100);
2492 fFD->Build(fViewer);
2493 tf->AddFrame(fFD, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 10, 0));
2494 TString btntxt;
2495 if (fViewer->GetActDesc()->fLocal ||
2496 (fViewer->GetActDesc()->fProof &&
2497 fViewer->GetActDesc()->fProof->IsValid())) {
2498 btntxt = " Submit ";
2499 }
2500 else {
2501 btntxt = " Apply changes ";
2502 }
2503 tf->AddFrame(fBtnSave = new TGTextButton(tf, btntxt),
2504 new TGLayoutHints(kLHintsTop | kLHintsLeft, 10, 5, 25, 5));
2505
2506 // connect button actions to functions
2507 fBtnSave->Connect("Clicked()", "TEditQueryFrame", fFD,
2508 "OnBtnSave()");
2509 fBtnSubmit->Connect("Clicked()", "TSessionQueryFrame", this,
2510 "OnBtnSubmit()");
2511 fBtnFinalize->Connect("Clicked()", "TSessionQueryFrame", this,
2512 "OnBtnFinalize()");
2513 fBtnStop->Connect("Clicked()", "TSessionQueryFrame", this,
2514 "OnBtnStop()");
2515 fBtnAbort->Connect("Clicked()", "TSessionQueryFrame", this,
2516 "OnBtnAbort()");
2517 fBtnShowLog->Connect("Clicked()", "TSessionQueryFrame", this,
2518 "OnBtnShowLog()");
2519 fBtnRetrieve->Connect("Clicked()", "TSessionQueryFrame", this,
2520 "OnBtnRetrieve()");
2521// fBtnSave->SetState(kButtonDisabled);
2522 Resize(350, 310);
2523}
2524
2525////////////////////////////////////////////////////////////////////////////////
2526/// Notify changes in query editor settings.
2527
2529{
2530 fModified = mod;
2531 if (fModified) {
2533 }
2534 else {
2536 }
2537 if (fViewer->GetActDesc()->fLocal ||
2538 (fViewer->GetActDesc()->fProof &&
2541}
2542
2543////////////////////////////////////////////////////////////////////////////////
2544/// Feedback function connected to Feedback signal.
2545/// Used to update feedback histograms.
2546
2548{
2549 // if no actual session, just return
2550 if (!fViewer->GetActDesc()->fAttached)
2551 return;
2552 if (!fViewer->GetActDesc()->fProof)
2553 return;
2554 if ((fViewer->GetActDesc()->fActQuery) &&
2559 return;
2560 TProof *sender = dynamic_cast<TProof*>((TQObject*)gTQSender);
2561 // if Proof sender match actual session one, update feedback histos
2562 if (sender && (sender == fViewer->GetActDesc()->fProof))
2563 UpdateHistos(objs);
2564}
2565
2566////////////////////////////////////////////////////////////////////////////////
2567/// Update feedback histograms.
2568
2570{
2571 TVirtualPad *save = gPad;
2572 TObject *o;
2573 Int_t pos = 1;
2574 Int_t i = 0;
2575 while (kFeedbackHistos[i]) {
2576 // check if user has selected this histogram in the option menu
2577 if (fViewer->GetCascadeMenu()->IsEntryChecked(41+i)) {
2578 if ( (o = objs->FindObject(kFeedbackHistos[i]))) {
2579 fStatsCanvas->cd(pos);
2580 gPad->SetEditable(kTRUE);
2581 if (TH1 *h = dynamic_cast<TH1*>(o)) {
2582 h->SetStats(0);
2583 h->SetBarWidth(0.75);
2584 h->SetBarOffset(0.125);
2585 h->SetFillColor(9);
2586 h->Draw("bar");
2587 pos++;
2588 }
2589 else if (TH2 *h2 = dynamic_cast<TH2*>(o)) {
2590 h2->Draw();
2591 pos++;
2592 }
2593 gPad->Modified();
2594 }
2595 }
2596 i++;
2597 }
2598 // update canvas
2599 fStatsCanvas->cd();
2602 if (save != 0) {
2603 save->cd();
2604 } else {
2605 gPad = 0;
2606 }
2607}
2608
2609////////////////////////////////////////////////////////////////////////////////
2610/// Update progress bar and status labels.
2611
2613{
2614 Long_t tt;
2615 UInt_t hh=0, mm=0, ss=0;
2616 TString stm;
2617 // if no actual session, just return
2618 if (!fViewer->GetActDesc()->fProof)
2619 return;
2620 // if Proof sender does't match actual session one, return
2621 TProof *sender = dynamic_cast<TProof*>((TQObject*)gTQSender);
2622 if (!sender || (sender != fViewer->GetActDesc()->fProof))
2623 return;
2624
2625 if ((fViewer->GetActDesc()->fActQuery) &&
2630 fTotal->SetText(" Estimated time left : 0 sec (0 events of 0 processed) ");
2631 fRate->SetText(" Processing Rate : 0.0f events/sec ");
2632 frmProg->Reset();
2633 fFB->Layout();
2634 return;
2635 }
2636
2637 if (total < 0)
2638 total = fPrevTotal;
2639 else
2640 fPrevTotal = total;
2641
2642 // if no change since last call, just return
2643 if (fPrevProcessed == processed)
2644 return;
2645 TString buf;
2646
2647 // Update information at first call
2648 if (fEntries != total) {
2649 buf.Form("PROOF cluster : \"%s\" - %d worker nodes",
2652 fLabInfos->SetText(buf);
2653
2654 fEntries = total;
2655 buf.Form(" %d files, %lld events, starting event %lld",
2657 fLabStatus->SetText(buf);
2658 }
2659
2660 // compute progress bar position and update
2661 Float_t pos = (Float_t)((Double_t)(processed * 100)/(Double_t)total);
2662 frmProg->SetPosition(pos);
2663 // if 100%, stop animation and set icon to "connected"
2664 if (pos >= 100.0) {
2666 fViewer->ChangeRightLogo("monitor01.xpm");
2667 }
2668
2669 // get current time
2670 if ((fViewer->GetActDesc()->fActQuery->fStatus ==
2677 Float_t eta = 0;
2678 if (processed)
2679 eta = ((Float_t)((Long64_t)tdiff)*total/Float_t(processed) -
2680 Long64_t(tdiff))/1000.;
2681
2682 tt = (Long_t)eta;
2683 if (tt > 0) {
2684 hh = (UInt_t)(tt / 3600);
2685 mm = (UInt_t)((tt % 3600) / 60);
2686 ss = (UInt_t)((tt % 3600) % 60);
2687 }
2688 if (hh)
2689 stm.Form("%d h %d min %d sec", hh, mm, ss);
2690 else if (mm)
2691 stm.Form("%d min %d sec", mm, ss);
2692 else
2693 stm.Form("%d sec", ss);
2694 if (processed == total) {
2695 // finished
2696 tt = (Long_t) Long64_t(tdiff)/1000;
2697 if (tt > 0) {
2698 hh = (UInt_t)(tt / 3600);
2699 mm = (UInt_t)((tt % 3600) / 60);
2700 ss = (UInt_t)((tt % 3600) % 60);
2701 }
2702 if (hh)
2703 stm.Form("%d h %d min %d sec", hh, mm, ss);
2704 else if (mm)
2705 stm.Form("%d min %d sec", mm, ss);
2706 else
2707 stm.Form("%d sec", ss);
2708 buf.Form(" Processed : %lld events in %s", total, stm.Data());
2709 fTotal->SetText(buf.Data());
2710 } else {
2711 // update status infos
2712 buf.Form(" Estimated time left : %s (%lld events of %lld processed) ",
2713 stm.Data(), processed, total);
2714 fTotal->SetText(buf.Data());
2715 }
2716 if (processed > 0 && (Long64_t)tdiff > 0) {
2717 buf.Form(" Processing Rate : %.1f events/sec ",
2718 (Float_t)processed/(Long64_t)tdiff*1000.);
2719 fRate->SetText(buf);
2720 }
2721 fPrevProcessed = processed;
2722
2723 fFB->Layout();
2724}
2725
2726////////////////////////////////////////////////////////////////////////////////
2727/// New version of Progress (just forward to the old version
2728/// for the time being).
2729
2731 Long64_t /*bytesread*/, Float_t /*initTime*/,
2732 Float_t /*procTime*/, Float_t /*evtrti*/,
2733 Float_t /*mbrti*/, Int_t /*actw*/,
2734 Int_t /*tses*/, Float_t /*eses*/)
2735{
2736 Progress(total, processed);
2737}
2738
2739////////////////////////////////////////////////////////////////////////////////
2740/// Update progress bar and status labels.
2741
2743{
2744 Long_t tt;
2745 UInt_t hh=0, mm=0, ss=0;
2746 TString stm;
2747 TString cproc;
2748 Int_t status;
2749
2750 switch (fViewer->GetActDesc()->fActQuery->fStatus) {
2751
2753 cproc = " - ABORTED";
2754 status = kAborted;
2755 break;
2757 cproc = " - STOPPED";
2758 status = kStopped;
2759 break;
2761 cproc = " ";
2762 status = kRunning;
2763 break;
2766 cproc = " ";
2767 status = kDone;
2768 break;
2769 default:
2770 status = -1;
2771 break;
2772 }
2773 if (processed < 0) processed = 0;
2774
2775 frmProg->SetBarColor("green");
2776 if (status == kAborted)
2777 frmProg->SetBarColor("red");
2778 else if (status == kStopped)
2779 frmProg->SetBarColor("yellow");
2780 else if (status == -1 ) {
2781 fTotal->SetText(" Estimated time left : 0 sec (0 events of 0 processed) ");
2782 fRate->SetText(" Processing Rate : 0.0f events/sec ");
2783 frmProg->Reset();
2784 fFB->Layout();
2785 return;
2786 }
2787
2788 if (total < 0)
2789 total = fPrevTotal;
2790 else
2791 fPrevTotal = total;
2792
2793 // if no change since last call, just return
2794 TString buf;
2795
2796 // Update information at first call
2797 if (fEntries != total) {
2798 fLabInfos->SetText("Local Session");
2799
2800 fEntries = total;
2801 buf.Form(" %d files, %lld events, starting event %lld",
2803 fLabStatus->SetText(buf.Data());
2804 }
2805
2806 // compute progress bar position and update
2807 Float_t pos = 0.0;
2808 if (processed > 0 && total > 0)
2809 pos = (Float_t)((Double_t)(processed * 100)/(Double_t)total);
2810 frmProg->SetPosition(pos);
2811 // if 100%, stop animation and set icon to "connected"
2812 if (pos >= 100.0) {
2814 fViewer->ChangeRightLogo("monitor01.xpm");
2815 }
2816
2817 // get current time
2818 if (status == kRunning)
2822 Float_t eta = 0;
2823 if (processed)
2824 eta = ((Float_t)((Long64_t)tdiff)*total/(Float_t)(processed) -
2825 (Long64_t)(tdiff))/1000.;
2826
2827 tt = (Long_t)eta;
2828 if (tt > 0) {
2829 hh = (UInt_t)(tt / 3600);
2830 mm = (UInt_t)((tt % 3600) / 60);
2831 ss = (UInt_t)((tt % 3600) % 60);
2832 }
2833 if (hh)
2834 stm = TString::Format("%d h %d min %d sec", hh, mm, ss);
2835 else if (mm)
2836 stm = TString::Format("%d min %d sec", mm, ss);
2837 else
2838 stm = TString::Format("%d sec", ss);
2839 if ((processed != total) && (status == kRunning)) {
2840 // update status infos
2841 buf.Form(" Estimated time left : %s (%lld events of %lld processed) ",
2842 stm.Data(), processed, total);
2843 fTotal->SetText(buf);
2844 } else {
2845 tt = (Long_t) Long64_t(tdiff)/1000;
2846 if (tt > 0) {
2847 hh = (UInt_t)(tt / 3600);
2848 mm = (UInt_t)((tt % 3600) / 60);
2849 ss = (UInt_t)((tt % 3600) % 60);
2850 }
2851 if (hh)
2852 stm = TString::Format("%d h %d min %d sec", hh, mm, ss);
2853 else if (mm)
2854 stm = TString::Format("%d min %d sec", mm, ss);
2855 else
2856 stm = TString::Format("%d sec", ss);
2857 buf.Form(" Processed : %ld events in %s",
2858 (Long_t)processed, stm.Data());
2859 buf += cproc;
2860 fTotal->SetText(buf.Data());
2861 }
2862 if (processed > 0 && (Long64_t)tdiff > 0) {
2863 buf.Form(" Processing Rate : %.1f events/sec ",
2864 (Float_t)processed/(Long64_t)tdiff*1000.);
2865 fRate->SetText(buf.Data());
2866 }
2867 fPrevProcessed = processed;
2868
2869 fFB->Layout();
2870}
2871
2872////////////////////////////////////////////////////////////////////////////////
2873/// Indicate that Cancel or Stop was clicked.
2874
2876{
2877 if (aborted == kTRUE) {
2878 // Aborted
2879 frmProg->SetBarColor("red");
2880 }
2881 else {
2882 // Stopped
2883 frmProg->SetBarColor("yellow");
2884 }
2885 // disconnect progress related signals
2886 if (fViewer->GetActDesc()->fProof &&
2888 fViewer->GetActDesc()->fProof->Disconnect("Progress(Long64_t,Long64_t)",
2889 this, "Progress(Long64_t,Long64_t)");
2890 fViewer->GetActDesc()->fProof->Disconnect("Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)",
2891 this, "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)");
2892 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)",
2893 this, "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t,Int_t,Int_t,Float_t)");
2894 fViewer->GetActDesc()->fProof->Disconnect("StopProcess(Bool_t)", this,
2895 "IndicateStop(Bool_t)");
2896 }
2897}
2898
2899////////////////////////////////////////////////////////////////////////////////
2900/// Reset progress frame information fields.
2901
2902void TSessionQueryFrame::ResetProgressDialog(const char * /*selector*/, Int_t files,
2903 Long64_t first, Long64_t entries)
2904{
2905 TString buf;
2906 fFiles = files > 0 ? files : 0;
2907 fFirst = first;
2908 fEntries = entries;
2909 fPrevProcessed = 0;
2910 fPrevTotal = 0;
2911
2912 if (!fViewer->GetActDesc()->fLocal) {
2913 frmProg->SetBarColor("green");
2914 frmProg->Reset();
2915 }
2916
2917 buf.Form("%0d files, %0lld events, starting event %0lld",
2918 fFiles > 0 ? fFiles : 0, fEntries > 0 ? fEntries : 0,
2919 fFirst >= 0 ? fFirst : 0);
2920 fLabStatus->SetText(buf.Data());
2921 // Reconnect the slots
2922 if (fViewer->GetActDesc()->fProof &&
2924 fViewer->GetActDesc()->fProof->Connect("Progress(Long64_t,Long64_t)",
2925 "TSessionQueryFrame", this, "Progress(Long64_t,Long64_t)");
2926 fViewer->GetActDesc()->fProof->Connect("Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)",
2927 "TSessionQueryFrame", this,
2928 "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)");
2929 fViewer->GetActDesc()->fProof->Connect("StopProcess(Bool_t)",
2930 "TSessionQueryFrame", this, "IndicateStop(Bool_t)");
2931 buf.Form("PROOF cluster : \"%s\" - %d worker nodes",
2934 fLabInfos->SetText(buf.Data());
2935 }
2936 else if (fViewer->GetActDesc()->fLocal) {
2938 fLabInfos->SetText("Local Session");
2939 fLabStatus->SetText(" ");
2940 }
2941 else {
2942 fLabInfos->SetText(" ");
2943 fLabStatus->SetText(" ");
2944 }
2945 fFB->Layout();
2946}
2947
2948////////////////////////////////////////////////////////////////////////////////
2949/// Finalize query.
2950
2952{
2953 // check if Proof is valid
2954 if (fViewer->GetActDesc()->fProof &&
2956 gPad->SetEditable(kFALSE);
2958 if (!item) return;
2959 TObject *obj = (TObject *)item->GetUserData();
2960 if ((obj) && (obj->IsA() == TQueryDescription::Class())) {
2961 // as it can take time, set watch cursor
2962 gVirtualX->SetCursor(GetId(),gVirtualX->CreateCursor(kWatch));
2963 TQueryDescription *query = (TQueryDescription *)obj;
2965 UpdateButtons(query);
2966 // restore cursor
2967 gVirtualX->SetCursor(GetId(), 0);
2968 }
2969 }
2970 if (fViewer->GetActDesc()->fLocal) {
2971 gPad->SetEditable(kFALSE);
2973 if (chain && chain->GetPlayer())
2975 }
2976}
2977
2978////////////////////////////////////////////////////////////////////////////////
2979/// Stop processing query.
2980
2982{
2983 // check for proof validity
2984 if (fViewer->GetActDesc()->fProof &&
2987 }
2988 if (fViewer->GetActDesc()->fLocal) {
2989 gROOT->SetInterrupt();
2992 }
2993 // stop icon animation and set connected icon
2994 fViewer->ChangeRightLogo("monitor01.xpm");
2996}
2997
2998////////////////////////////////////////////////////////////////////////////////
2999/// Show query log.
3000
3002{
3004 if (!item) return;
3005 TObject *obj = (TObject *)item->GetUserData();
3006 if ((!obj) || (obj->IsA() != TQueryDescription::Class()))
3007 return;
3008 TQueryDescription *query = (TQueryDescription *)obj;
3009 fViewer->ShowLog(query->fReference.Data());
3010}
3011
3012////////////////////////////////////////////////////////////////////////////////
3013/// Retrieve query.
3014
3016{
3017 // check for proof validity
3018 if (fViewer->GetActDesc()->fAttached &&
3022 if (!item) return;
3023 TObject *obj = (TObject *)item->GetUserData();
3024 if (obj && obj->IsA() == TQueryDescription::Class()) {
3025 // as it can take time, set watch cursor
3026 gVirtualX->SetCursor(GetId(), gVirtualX->CreateCursor(kWatch));
3027 TQueryDescription *query = (TQueryDescription *)obj;
3029 if (rc == 0)
3031 // restore cursor
3032 gVirtualX->SetCursor(GetId(), 0);
3033 }
3034 }
3035 if (fViewer->GetActDesc()->fLocal) {
3036 TGListTreeItem *item=0, *item2=0;
3038 fViewer->GetActDesc());
3039 if (item) {
3040 item2 = fViewer->GetSessionHierarchy()->FindItemByObj(item,
3042 }
3043 if (item2) {
3044 // add input and output list entries
3046 if (chain && chain->GetPlayer()) {
3047 TSelector *selector = chain->GetPlayer()->GetSelectorFromFile();
3048 if (selector) {
3049 TList *objlist = selector->GetOutputList();
3050 if (objlist)
3051 if (!fViewer->GetSessionHierarchy()->FindChildByName(item2, "OutputList"))
3052 fViewer->GetSessionHierarchy()->AddItem(item2, "OutputList");
3053 }
3054 }
3055 }
3056 // update list tree, query frame information, and buttons state
3059 UpdateInfos();
3061 }
3062}
3063
3064////////////////////////////////////////////////////////////////////////////////
3065/// Abort processing query.
3066
3068{
3069 // check for proof validity
3070 if (fViewer->GetActDesc()->fProof &&
3073 }
3074 if (fViewer->GetActDesc()->fLocal) {
3075 gROOT->SetInterrupt();
3078 }
3079 // stop icon animation and set connected icon
3080 fViewer->ChangeRightLogo("monitor01.xpm");
3082}
3083
3084////////////////////////////////////////////////////////////////////////////////
3085/// Submit query.
3086
3088{
3089 Int_t retval;
3090 Long64_t id = 0;
3092 if (!item) return;
3093 // retrieve query description attached to list tree item
3094 TObject *obj = (TObject *)item->GetUserData();
3095 if (!obj || obj->IsA() != TQueryDescription::Class())
3096 return;
3097 TQueryDescription *newquery = (TQueryDescription *)obj;
3098 // reset progress information
3100 newquery->fNbFiles, newquery->fFirstEntry, newquery->fNoEntries);
3101 // set query start time
3102 newquery->fStartTime = gSystem->Now();
3104 // check for proof validity
3105 if (fViewer->GetActDesc()->fProof &&
3108 // set query description status to submitted
3110 // if feedback option selected
3112 Int_t i = 0;
3113 // browse list of feedback histos and check user's selected ones
3114 while (kFeedbackHistos[i]) {
3115 if (fViewer->GetCascadeMenu()->IsEntryChecked(41+i)) {
3118 }
3119 i++;
3120 }
3121 // connect feedback signal
3122 fViewer->GetActDesc()->fProof->Connect("Feedback(TList *objs)",
3123 "TSessionQueryFrame", fViewer->GetQueryFrame(),
3124 "Feedback(TList *objs)");
3125 gROOT->Time();
3126 }
3127 else {
3128 // if feedback option not selected, clear Proof's feedback option
3130 }
3131 // set current proof session
3132 fViewer->GetActDesc()->fProof->cd();
3133 // check if parameter file has been specified
3134 if (newquery->fChain) {
3135 if (fViewer->GetActDesc()->fProof->IsLite()) {
3136 newquery->fOptions = "";
3137 }
3138 // set query reference id
3139 newquery->fReference= TString::Format("session-%s:q%d",
3142 if (newquery->fChain->IsA() == TChain::Class()) {
3143 // TChain case
3145 ((TChain *)newquery->fChain)->SetProof(fViewer->GetActDesc()->fProof);
3146 id = ((TChain *)newquery->fChain)->Process(newquery->fSelectorString,
3147 newquery->fOptions,
3148 newquery->fNoEntries > 0 ? newquery->fNoEntries : 1234567890,
3149 newquery->fFirstEntry);
3150 }
3151 else if (newquery->fChain->IsA() == TDSet::Class()) {
3152 // TDSet case
3154 id = ((TDSet *)newquery->fChain)->Process(newquery->fSelectorString,
3155 newquery->fOptions,
3156 newquery->fNoEntries,
3157 newquery->fFirstEntry);
3158 }
3159 }
3160 else {
3161 Error("Submit", "No TChain defined; skipping");
3163 return;
3164 }
3165 // set query reference id to unique identifier
3166 newquery->fReference= TString::Format("session-%s:q%lld",
3168 // start icon animation
3170 }
3171 else if (fViewer->GetActDesc()->fLocal) { // local session case
3172 // if feedback option selected
3174 Int_t i = 0;
3175 // browse list of feedback histos and check user's selected ones
3176 while (kFeedbackHistos[i]) {
3177 if (fViewer->GetCascadeMenu()->IsEntryChecked(41+i)) {
3179 }
3180 i++;
3181 }
3182 }
3183 if (newquery->fChain) {
3184 if (newquery->fChain->IsA() == TChain::Class()) {
3185 // TChain case
3188 UpdateButtons(newquery);
3189 gPad->SetEditable(kFALSE);
3190 ((TChain *)newquery->fChain)->SetTimerInterval(100);
3191 id = ((TChain *)newquery->fChain)->Process(newquery->fSelectorString,
3192 newquery->fOptions,
3193 newquery->fNoEntries > 0 ? newquery->fNoEntries : 1234567890,
3194 newquery->fFirstEntry);
3195 ((TChain *)newquery->fChain)->SetTimerInterval(0);
3196 OnBtnRetrieve();
3197 TChain *chain = (TChain *)newquery->fChain;
3198 ProgressLocal(chain->GetEntries(),
3199 chain->GetReadEntry()+1);
3203 UpdateButtons(newquery);
3204 }
3205 else {
3206 new TGMsgBox(fClient->GetRoot(), this, "Error Submitting Query",
3207 "Only TChains are allowed in Local Session (no TDSet) !",
3208 kMBIconExclamation,kMBOk,&retval);
3209 }
3210 }
3211 else {
3212 Error("Submit", "No TChain defined; skipping");
3214 return;
3215 }
3216 // set query reference id to unique identifier
3217 newquery->fReference = TString::Format("local-session-%s:q%lld", newquery->fQueryName.Data(), id);
3218 }
3219 // update buttons state
3220 UpdateButtons(newquery);
3221}
3222
3223////////////////////////////////////////////////////////////////////////////////
3224/// Update buttons state for the current query status.
3225
3227{
3229 if (!item) return;
3230 // retrieve query description attached to list tree item
3231 TObject *obj = (TObject *)item->GetUserData();
3232 if (!obj || obj->IsA() != TQueryDescription::Class())
3233 return;
3234 TQueryDescription *query = (TQueryDescription *)obj;
3235 if (desc != query) return;
3236
3237 Bool_t submit_en = kFALSE;
3238 if ((fViewer->GetActDesc()->fProof &&
3239 fViewer->GetActDesc()->fProof->IsValid()) ||
3241 submit_en = kTRUE;
3242
3243 switch (desc->fStatus) {
3245 fBtnSubmit->SetEnabled(submit_en);
3251 break;
3252
3254 fBtnSubmit->SetEnabled(submit_en);
3256 if (((desc->fResult == 0) || (desc->fResult &&
3257 (desc->fResult->IsFinalized() ||
3258 (desc->fResult->GetInputObject("TDSet") == 0)))) &&
3259 !(fViewer->GetActDesc()->fLocal))
3265 break;
3266
3268 fBtnSubmit->SetEnabled(submit_en);
3274 break;
3275
3283 break;
3284
3292 break;
3293
3295 fBtnSubmit->SetEnabled(submit_en);
3301 break;
3302
3304 fBtnSubmit->SetEnabled(submit_en);
3310 break;
3311
3313 fBtnSubmit->SetEnabled(submit_en);
3319 break;
3320
3321 default:
3322 break;
3323 }
3324 if (fViewer->GetActDesc()->fLocal &&
3328 }
3329}
3330
3331////////////////////////////////////////////////////////////////////////////////
3332/// Update query information (header) text view.
3333
3335{
3336 TString buffer;
3337 const char *qst[] = {"aborted ", "submitted", "running ",
3338 "stopped ", "completed"};
3339
3342
3343 if (fViewer->GetActDesc()->fLocal ||
3347 fViewer->GetActDesc()->fProof->IsValid())) {
3348 fBtnSave->SetText(" Submit ");
3349 }
3350 else {
3351 fBtnSave->SetText(" Apply changes ");
3352 }
3355 if (!fViewer->GetActDesc()->fActQuery ||
3357 ResetProgressDialog("", 0, 0, 0);
3358 if (fViewer->GetActDesc()->fLocal) {
3359 if (fViewer->GetActDesc()->fActQuery) {
3361 if (chain) {
3362 ProgressLocal(chain->GetEntries(),
3363 chain->GetReadEntry()+1);
3364 }
3365 else {
3366 ProgressLocal(0, 0);
3367 }
3369 }
3370 }
3371 else {
3372 fTotal->SetText(" Estimated time left : 0 sec (0 events of 0 processed) ");
3373 fRate->SetText(" Processing Rate : 0.0f events/sec ");
3374 frmProg->Reset();
3375 fFB->Layout();
3376 }
3377 return;
3378 }
3380
3381 // Status label
3382 Int_t st = (result->GetStatus() > 0 && result->GetStatus() <=
3383 TQueryResult::kCompleted) ? result->GetStatus() : 0;
3384
3385 Int_t qry = result->GetSeqNum();
3386
3387 buffer = TString::Format("------------------------------------------------------\n");
3388 // Print header
3389 if (!result->IsDraw()) {
3390 const char *fin = result->IsFinalized() ? "finalized" : qst[st];
3391 const char *arc = result->IsArchived() ? "(A)" : "";
3392 buffer = TString::Format(" Query No : %d\n", qry);
3393 buffer += TString::Format(" Ref : \"%s:%s\"\n", result->GetTitle(),
3394 result->GetName());
3395 buffer += TString::Format(" Selector : %s\n",
3396 result->GetSelecImp()->GetTitle());
3397 buffer += TString::Format("Status : %9s%s\n", fin, arc);
3398 buffer += TString::Format("------------------------------------------------------\n");
3399 } else {
3400 buffer += TString::Format(" Query No : %d\n", qry);
3401 buffer += TString::Format(" Ref : \"%s:%s\"\n", result->GetTitle(),
3402 result->GetName());
3403 buffer += TString::Format(" Selector : %s\n",
3404 result->GetSelecImp()->GetTitle());
3405 buffer += TString::Format("------------------------------------------------------\n");
3406 }
3407
3408 // Time information
3409 Int_t elapsed = (Int_t)(result->GetEndTime().Convert() -
3410 result->GetStartTime().Convert());
3411 buffer += TString::Format(" Started : %s\n",
3412 result->GetStartTime().AsString());
3413 buffer += TString::Format(" Real time : %d sec (CPU time: %.1f sec)\n",
3414 elapsed, result->GetUsedCPU());
3415
3416 // Number of events processed, rate, size
3417 Double_t rate = 0.0;
3418 if (result->GetEntries() > -1 && elapsed > 0)
3419 rate = result->GetEntries() / (Double_t)elapsed ;
3420 Float_t size = ((Float_t)result->GetBytes())/(1024*1024);
3421 buffer += TString::Format(" Processed : %lld events (size: %.3f MBs)\n",
3422 result->GetEntries(), size);
3423 buffer += TString::Format(" Rate : %.1f evts/sec\n", rate);
3424
3425 // Package information
3426 if (strlen(result->GetParList()) > 1) {
3427 buffer += TString::Format(" Packages : %s\n", result->GetParList());
3428 }
3429
3430 // Result information
3431 TString res = result->GetResultFile();
3432 if (!result->IsArchived()) {
3433 Int_t dq = res.Index("queries");
3434 if (dq > -1) {
3435 res.Remove(0,res.Index("queries"));
3436 res.Insert(0,"<PROOF_SandBox>/");
3437 }
3438 if (res.BeginsWith("-")) {
3439 res = (result->GetStatus() == TQueryResult::kAborted) ?
3440 "not available" : "sent to client";
3441 }
3442 }
3443 if (res.Length() > 1) {
3444 buffer += TString::Format("------------------------------------------------------\n");
3445 buffer += TString::Format(" Results : %s\n", res.Data());
3446 }
3447
3448 if (result->GetOutputList() && result->GetOutputList()->GetSize() > 0) {
3449 buffer += TString::Format(" Outlist : %d objects\n",
3450 result->GetOutputList()->GetSize());
3451 buffer += TString::Format("------------------------------------------------------\n");
3452 }
3453 fInfoTextView->LoadBuffer(buffer.Data());
3454
3455 //Float_t pos = Float_t((Double_t)(result->GetEntries() * 100)/(Double_t)total);
3456 if (result->GetStatus() == TQueryResult::kAborted)
3457 frmProg->SetBarColor("red");
3458 else if (result->GetStatus() == TQueryResult::kStopped)
3459 frmProg->SetBarColor("yellow");
3460 else
3461 frmProg->SetBarColor("green");
3462
3463 frmProg->SetPosition(100.0);
3464
3465 buffer = TString::Format(" Processed : %lld events in %.1f sec", result->GetEntries(),
3466 (Float_t)elapsed);
3467 fTotal->SetText(buffer.Data());
3468 buffer = TString::Format(" Processing Rate : %.1f events/sec ", rate);
3469 fRate->SetText(buffer.Data());
3470 fFB->Layout();
3471}
3472
3473//////////////////////////////////////////////////////////////////////////////////////////
3474// Output frame
3475
3476////////////////////////////////////////////////////////////////////////////////
3477/// Constructor.
3478
3480 TGCompositeFrame(p, w, h), fEntryTmp(0), fLVContainer(0), fViewer(0)
3481{
3482}
3483
3484////////////////////////////////////////////////////////////////////////////////
3485/// Destructor.
3486
3488{
3489 delete fLVContainer; // this container is inside the TGListView and is not
3490 // deleted automatically
3491 Cleanup();
3492}
3493
3494////////////////////////////////////////////////////////////////////////////////
3495/// Build query output information frame.
3496
3498{
3499 fViewer = gui;
3502
3503 // Container of object TGListView
3504 TGListView *frmListView = new TGListView(this, 340, 190);
3506 fLVContainer->Associate(frmListView);
3508 AddFrame(frmListView, new TGLayoutHints<