]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/Aliengui/AliPackageFrame.cxx
Modifications for eff. c++ warnings.
[u/mrichter/AliRoot.git] / ANALYSIS / Aliengui / AliPackageFrame.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //-----------------------------------------------------------------
19 //           AliPackageFrame class
20 //   The class that deals with the package tab of the GUI
21 //   Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
22 //-----------------------------------------------------------------
23
24 #include "TGLabel.h"
25 #include "TGTextEntry.h"
26 #include "TGButton.h"
27 #include "TGFileDialog.h"
28
29 #include "TSystem.h"
30 #include "TObjString.h"
31
32 #include "AliAnalysisGUI.h"
33 #include "AliPackageFrame.h"
34
35 ClassImp(AliPackageFrame)
36
37 //___________________________________________________________________________
38   AliPackageFrame::AliPackageFrame (const TGWindow *main, UInt_t w, UInt_t h, AliAnalysisGUI * v): 
39     TGHorizontalFrame(main, w, h), 
40     fVFrame1(0), fVFrame2(0),
41     fLabel1(0), fTextPackage(0), fButtonSelect(0), fButtonBuild(0),
42     fAliAnalysisGUI(v) {
43    // ctor.
44   
45    fVFrame1 = new TGVerticalFrame(this, 100, 100);
46    AddFrame(fVFrame1, new TGLayoutHints(kLHintsLeft, 5,5,5,5));
47
48    fLabel1 = new TGLabel(fVFrame1, new TGString("PAR file"));
49    fVFrame1->AddFrame(fLabel1, new TGLayoutHints(kLHintsTop, 5,5,10,5));
50    
51    fTextPackage = new TGTextEntry(fVFrame1, new TGTextBuffer(50));
52    fVFrame1->AddFrame(fTextPackage, new TGLayoutHints(kLHintsBottom, 5,5,5,5));
53    fTextPackage->SetEnabled(false);
54
55    fVFrame2 = new TGVerticalFrame(this, 100, 200);
56    AddFrame(fVFrame2, new TGLayoutHints(kLHintsLeft, 5,5,5,5));
57
58    fButtonSelect = new TGTextButton(fVFrame2, "Select...", 1);
59    fVFrame2->AddFrame(fButtonSelect,  new TGLayoutHints(kLHintsExpandX | kLHintsTop, 5,5,5,5));
60    fButtonSelect->Connect("Clicked()", "AliPackageFrame", this, "OnSelect()");
61
62    fButtonBuild = new TGTextButton(fVFrame2, "Build...", 2);
63    fVFrame2->AddFrame(fButtonBuild,  new TGLayoutHints(kLHintsExpandX | kLHintsBottom, 5,5,5,5));
64
65    fButtonBuild->Connect("Clicked()", "AliPackageFrame", this, "OnBuild()");
66
67    MapWindow();
68    Resize();
69    MapSubwindows();
70 }
71
72 //___________________________________________________________________________
73 void AliPackageFrame::OnSelect() {
74    // When Select button is pressed.
75    const char *filetypes[] = { 
76      "PAR files",    "*.par",
77      0,               0 
78    };
79
80
81    static TString dir(".");
82    TGFileInfo fi;
83    fi.fFileTypes = filetypes;
84    fi.fIniDir    = StrDup(dir);
85
86    new TGFileDialog(gClient->GetRoot(), fAliAnalysisGUI, kFDOpen, &fi);
87
88    fTextPackage->SetText(fi.fFilename);
89
90 }
91
92 //___________________________________________________________________________
93 void AliPackageFrame::OnBuild() {
94
95    // When Build button is pressed.  
96
97    TString fname (fTextPackage->GetText());
98
99    TObjArray *a = fname.Tokenize("/");
100    TObjString * ostr = (TObjString*)a->At(a->GetEntries()-1);
101
102    CreatePARFile(ostr->GetString().Data());
103
104 }
105
106 //___________________________________________________________________________
107 void AliPackageFrame::CreatePARFile(const char* pararchivename) {
108    // Create PAR file
109
110    if (pararchivename) {
111      char processline[1024];
112      //     sprintf(processline,".! tar xvzf ../tags/%s.par",pararchivename);
113      sprintf(processline,".! tar xvzf %s",pararchivename);
114      gROOT->ProcessLine(processline);
115
116      //    const char* ocwd = gSystem->WorkingDirectory();
117      gSystem->ChangeDirectory("ESD");
118
119      // check for BUILD.sh and execute
120      if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
121        printf("*******************************\n");
122        printf("*** Building PAR archive    ***\n");
123        printf("*******************************\n");
124        if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
125          Error("batchSelector","Cannot Build the PAR Archive! - Abort!");
126          return;
127        }           
128
129        if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
130
131          printf("*******************************\n");
132          printf("*** Setup PAR archive       ***\n");
133          printf("*******************************\n");
134
135          gROOT->Macro("PROOF-INF/SETUP.C");
136        }
137
138        gSystem->ChangeDirectory("../");
139
140      }
141
142    }
143 }