Adding the AliPackageFrame class: the package/par file frame of the GUI (second tab).
authorpanos <panos@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 13 Nov 2006 12:58:11 +0000 (12:58 +0000)
committerpanos <panos@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 13 Nov 2006 12:58:11 +0000 (12:58 +0000)
ANALYSIS/Aliengui/AliPackageFrame.cxx [new file with mode: 0644]
ANALYSIS/Aliengui/AliPackageFrame.h [new file with mode: 0644]

diff --git a/ANALYSIS/Aliengui/AliPackageFrame.cxx b/ANALYSIS/Aliengui/AliPackageFrame.cxx
new file mode 100644 (file)
index 0000000..adc32b5
--- /dev/null
@@ -0,0 +1,139 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id$ */
+
+//-----------------------------------------------------------------
+//           AliPackageFrame class
+//   The class that deals with the package tab of the GUI
+//   Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
+//-----------------------------------------------------------------
+
+#include "TGLabel.h"
+#include "TGTextEntry.h"
+#include "TGButton.h"
+#include "TGFileDialog.h"
+
+#include "TSystem.h"
+#include "TObjString.h"
+
+#include "AliAnalysisGUI.h"
+#include "AliPackageFrame.h"
+
+ClassImp(AliPackageFrame)
+
+//___________________________________________________________________________
+  AliPackageFrame::AliPackageFrame (const TGWindow *main, UInt_t w, UInt_t h, AliAnalysisGUI * v): TGHorizontalFrame(main, w, h), fAliAnalysisGUI(v) {
+   // ctor.
+  
+   fVFrame1 = new TGVerticalFrame(this, 100, 100);
+   AddFrame(fVFrame1, new TGLayoutHints(kLHintsLeft, 5,5,5,5));
+
+   fLabel1 = new TGLabel(fVFrame1, new TGString("PAR file"));
+   fVFrame1->AddFrame(fLabel1, new TGLayoutHints(kLHintsTop, 5,5,10,5));
+   
+   fTextPackage = new TGTextEntry(fVFrame1, new TGTextBuffer(50));
+   fVFrame1->AddFrame(fTextPackage, new TGLayoutHints(kLHintsBottom, 5,5,5,5));
+   fTextPackage->SetEnabled(false);
+
+   fVFrame2 = new TGVerticalFrame(this, 100, 200);
+   AddFrame(fVFrame2, new TGLayoutHints(kLHintsLeft, 5,5,5,5));
+
+   fButtonSelect = new TGTextButton(fVFrame2, "Select...", 1);
+   fVFrame2->AddFrame(fButtonSelect,  new TGLayoutHints(kLHintsExpandX | kLHintsTop, 5,5,5,5));
+   fButtonSelect->Connect("Clicked()", "AliPackageFrame", this, "OnSelect()");
+
+   fButtonBuild = new TGTextButton(fVFrame2, "Build...", 2);
+   fVFrame2->AddFrame(fButtonBuild,  new TGLayoutHints(kLHintsExpandX | kLHintsBottom, 5,5,5,5));
+
+   fButtonBuild->Connect("Clicked()", "AliPackageFrame", this, "OnBuild()");
+
+   MapWindow();
+   Resize();
+   MapSubwindows();
+}
+
+//___________________________________________________________________________
+void AliPackageFrame::OnSelect() {
+   // When Select button is pressed.
+   const char *filetypes[] = { 
+     "PAR files",    "*.par",
+     0,               0 
+   };
+
+
+   static TString dir(".");
+   TGFileInfo fi;
+   fi.fFileTypes = filetypes;
+   fi.fIniDir    = StrDup(dir);
+
+   new TGFileDialog(gClient->GetRoot(), fAliAnalysisGUI, kFDOpen, &fi);
+
+   fTextPackage->SetText(fi.fFilename);
+
+}
+
+//___________________________________________________________________________
+void AliPackageFrame::OnBuild() {
+
+   // When Build button is pressed.  
+
+   TString fname (fTextPackage->GetText());
+
+   TObjArray *a = fname.Tokenize("/");
+   TObjString * ostr = (TObjString*)a->At(a->GetEntries()-1);
+
+   CreatePARFile(ostr->GetString().Data());
+
+}
+
+//___________________________________________________________________________
+void AliPackageFrame::CreatePARFile(const char* pararchivename) {
+   // Create PAR file
+
+   if (pararchivename) {
+     char processline[1024];
+     //     sprintf(processline,".! tar xvzf ../tags/%s.par",pararchivename);
+     sprintf(processline,".! tar xvzf %s",pararchivename);
+     gROOT->ProcessLine(processline);
+
+     //    const char* ocwd = gSystem->WorkingDirectory();
+     gSystem->ChangeDirectory("ESD");
+
+     // check for BUILD.sh and execute
+     if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
+       printf("*******************************\n");
+       printf("*** Building PAR archive    ***\n");
+       printf("*******************************\n");
+       if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
+        Error("batchSelector","Cannot Build the PAR Archive! - Abort!");
+        return;
+       }           
+
+       if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
+
+        printf("*******************************\n");
+        printf("*** Setup PAR archive       ***\n");
+        printf("*******************************\n");
+
+        gROOT->Macro("PROOF-INF/SETUP.C");
+       }
+
+       gSystem->ChangeDirectory("../");
+
+     }
+
+   }
+}
diff --git a/ANALYSIS/Aliengui/AliPackageFrame.h b/ANALYSIS/Aliengui/AliPackageFrame.h
new file mode 100644 (file)
index 0000000..bc1da24
--- /dev/null
@@ -0,0 +1,64 @@
+#ifndef ALIPACKAGEFRAME_H
+#define ALIPACKAGEFRAME_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+//-------------------------------------------------------------------------
+//                          Class AliPackageFrame
+//   AliPackageFrame class that describes the package frame of the GUI
+//
+//    Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
+//-------------------------------------------------------------------------
+
+
+
+//////////////////////////////////////////////////////////////////////////
+//                                                                      //
+//                        AliPackageFrame                               //
+//                                                                      //
+//                      Package tab of the GUI.                         //
+//                                                                      //
+//////////////////////////////////////////////////////////////////////////
+
+#include <TGFrame.h>
+
+class TGLabel;
+class TGVerticalFrame;
+class TGTextEntry;
+class TGButton;
+
+class AliAnalysisGUI;
+
+//___________________________________________________________________________
+class AliPackageFrame : public TGHorizontalFrame {
+
+ public:
+  AliPackageFrame(const TGWindow *main, UInt_t w, UInt_t h, AliAnalysisGUI*);
+   
+  //___________________________________________________________________________
+  //slots
+  void OnBuild();
+  void OnSelect();
+
+  //___________________________________________________________________________
+ private:
+  AliPackageFrame(const AliPackageFrame&);
+  AliPackageFrame& operator= (const AliPackageFrame&);
+  
+  void CreatePARFile(const char* parfile);
+  
+  TGVerticalFrame     *fVFrame1, *fVFrame2; //vertical frames 
+  TGLabel             *fLabel1;  //package label  
+  TGTextEntry         *fTextPackage; //package text box
+  TGButton            *fButtonSelect; //select button
+  TGButton            *fButtonBuild; //run button
+  
+  AliAnalysisGUI      *fAliAnalysisGUI; //analysis gui pointer
+  
+  ClassDef(AliPackageFrame, 0); // AliPackageFrame
+};
+
+
+#endif