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