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