]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/Aliengui/AliPackageFrame.cxx
Adding includes now needed by ROOT
[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
25 #include <TGButton.h>
26 #include <TGFileDialog.h>
27 #include <TGLabel.h>
28 #include <TGTextEntry.h>
29 #include <TObjArray.h>
30 #include <TObjString.h>
31 #include <TSystem.h>
32
33 #include "AliAnalysisGUI.h"
34 #include "AliPackageFrame.h"
35
36 ClassImp(AliPackageFrame)
37
38 //___________________________________________________________________________
39   AliPackageFrame::AliPackageFrame (const TGWindow *main, UInt_t w, UInt_t h, AliAnalysisGUI * v): 
40     TGHorizontalFrame(main, w, h), 
41     fVFrame1(0), fVFrame2(0),
42     fLabel1(0), fTextPackage(0), fButtonSelect(0), fButtonBuild(0),
43     fAliAnalysisGUI(v) {
44    // ctor.
45   
46    fVFrame1 = new TGVerticalFrame(this, 100, 100);
47    AddFrame(fVFrame1, new TGLayoutHints(kLHintsLeft, 5,5,5,5));
48
49    fLabel1 = new TGLabel(fVFrame1, new TGString("PAR file"));
50    fVFrame1->AddFrame(fLabel1, new TGLayoutHints(kLHintsTop, 5,5,10,5));
51    
52    fTextPackage = new TGTextEntry(fVFrame1, new TGTextBuffer(50));
53    fVFrame1->AddFrame(fTextPackage, new TGLayoutHints(kLHintsBottom, 5,5,5,5));
54    fTextPackage->SetEnabled(false);
55
56    fVFrame2 = new TGVerticalFrame(this, 100, 200);
57    AddFrame(fVFrame2, new TGLayoutHints(kLHintsLeft, 5,5,5,5));
58
59    fButtonSelect = new TGTextButton(fVFrame2, "Select...", 1);
60    fVFrame2->AddFrame(fButtonSelect,  new TGLayoutHints(kLHintsExpandX | kLHintsTop, 5,5,5,5));
61    fButtonSelect->Connect("Clicked()", "AliPackageFrame", this, "OnSelect()");
62
63    fButtonBuild = new TGTextButton(fVFrame2, "Build...", 2);
64    fVFrame2->AddFrame(fButtonBuild,  new TGLayoutHints(kLHintsExpandX | kLHintsBottom, 5,5,5,5));
65
66    fButtonBuild->Connect("Clicked()", "AliPackageFrame", this, "OnBuild()");
67
68    MapWindow();
69    Resize();
70    MapSubwindows();
71 }
72
73 //___________________________________________________________________________
74 void AliPackageFrame::OnSelect() {
75    // When Select button is pressed.
76    const char *filetypes[] = { 
77      "PAR files",    "*.par",
78      0,               0 
79    };
80
81
82    static TString dir(".");
83    TGFileInfo fi;
84    fi.fFileTypes = filetypes;
85    fi.fIniDir    = StrDup(dir);
86
87    new TGFileDialog(gClient->GetRoot(), fAliAnalysisGUI, kFDOpen, &fi);
88
89    fTextPackage->SetText(fi.fFilename);
90
91 }
92
93 //___________________________________________________________________________
94 void AliPackageFrame::OnBuild() {
95
96    // When Build button is pressed.  
97
98    TString fname (fTextPackage->GetText());
99
100    TObjArray *a = fname.Tokenize("/");
101    TObjString * ostr = (TObjString*)a->At(a->GetEntries()-1);
102
103    CreatePARFile(ostr->GetString().Data());
104
105 }
106
107 //___________________________________________________________________________
108 void AliPackageFrame::CreatePARFile(const char* pararchivename) {
109    // Create PAR file
110
111    if (pararchivename) {
112      char processline[1024];
113      //     sprintf(processline,".! tar xvzf ../tags/%s.par",pararchivename);
114      sprintf(processline,".! tar xvzf %s",pararchivename);
115      gROOT->ProcessLine(processline);
116
117      //    const char* ocwd = gSystem->WorkingDirectory();
118      gSystem->ChangeDirectory("ESD");
119
120      // check for BUILD.sh and execute
121      if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
122        printf("*******************************\n");
123        printf("*** Building PAR archive    ***\n");
124        printf("*******************************\n");
125        if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
126          Error("batchSelector","Cannot Build the PAR Archive! - Abort!");
127          return;
128        }           
129
130        if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
131
132          printf("*******************************\n");
133          printf("*** Setup PAR archive       ***\n");
134          printf("*******************************\n");
135
136          gROOT->Macro("PROOF-INF/SETUP.C");
137        }
138
139        gSystem->ChangeDirectory("../");
140
141      }
142
143    }
144 }