]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Adding the AliLoginFrame class: the login window of the GUI.
authorpanos <panos@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 13 Nov 2006 12:57:16 +0000 (12:57 +0000)
committerpanos <panos@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 13 Nov 2006 12:57:16 +0000 (12:57 +0000)
ANALYSIS/Aliengui/AliLoginFrame.cxx [new file with mode: 0644]
ANALYSIS/Aliengui/AliLoginFrame.h [new file with mode: 0644]

diff --git a/ANALYSIS/Aliengui/AliLoginFrame.cxx b/ANALYSIS/Aliengui/AliLoginFrame.cxx
new file mode 100644 (file)
index 0000000..cb36364
--- /dev/null
@@ -0,0 +1,121 @@
+/**************************************************************************
+ * 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$ */
+
+//-----------------------------------------------------------------
+//           AliLoginFrame class
+//   The class that deals with the login frame of the GUI
+//   Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
+//-----------------------------------------------------------------
+
+#include "TGLabel.h"
+#include "TGTextBuffer.h"
+#include "TGTextEntry.h"
+#include "TGridResult.h"
+#include "TTimer.h"
+#include "TGMsgBox.h"
+
+#include "TGrid.h"
+
+#include "AliAnalysisGUI.h"
+#include "AliLoginFrame.h"
+
+ClassImp(AliLoginFrame)
+
+//___________________________________________________________________________
+AliLoginFrame::AliLoginFrame(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options) : TGTransientFrame(p, main, w, h, options) {
+  // Constructor.
+
+  SetWindowName("Login");
+
+  // create the Vertical Frame for the text fields and buttons
+  fVFrame1 = new TGVerticalFrame(this, 400, 150, kFixedWidth);
+
+  // create the Horizontal Frame 1 
+  fHFrame1 = new TGHorizontalFrame(this, 400, 50, kFixedWidth);
+
+  fLabel1 = new TGLabel(fHFrame1, new TGString("Server"));
+  fTextServer = new TGTextEntry(fHFrame1, new TGTextBuffer(35));
+  fTextServer->SetText("alien://");
+  
+  fHFrame1->AddFrame(fLabel1, 
+                    new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 5, 5, 5));
+  fHFrame1->AddFrame(fTextServer, 
+                    new TGLayoutHints(kLHintsRight | kLHintsTop, 5, 5, 5, 5));
+  
+  fVFrame1->AddFrame(fHFrame1,new TGLayoutHints(kLHintsTop));
+  
+  // Create the Horizontal for the buttons
+  fHFrame3 = new TGHorizontalFrame(this, 400, 50, kFixedWidth);
+  
+  fButtonLogIn = new TGTextButton(fHFrame3, "Log In", 1);
+  fButtonLogIn->Connect("Clicked()", "AliLoginFrame", this, "DoLogIn()");
+  
+  fButtonCancel = new TGTextButton(fHFrame3, "Cancel", 2);
+  fButtonCancel->Connect("Clicked()", "AliLoginFrame", this, "DoCancel()");
+  
+  fHFrame3->AddFrame(fButtonLogIn,new TGLayoutHints
+                    (kLHintsCenterY | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
+  fHFrame3->AddFrame(fButtonCancel,new TGLayoutHints
+                    (kLHintsCenterY | kLHintsRight | kLHintsExpandX, 2, 2, 2, 2));
+  
+  fHFrame3->Resize();
+  
+  fVFrame1->AddFrame(fHFrame3, new TGLayoutHints(kLHintsBottom)); 
+  
+  AddFrame(fVFrame1, new TGLayoutHints(kLHintsTop)); 
+  
+  MapSubwindows();
+  Resize();
+  MapWindow();
+}
+
+//___________________________________________________________________________
+AliLoginFrame::~AliLoginFrame() {
+  // Destructor.
+  
+  DeleteWindow();
+  SetCleanup(kDeepCleanup);
+}
+
+//___________________________________________________________________________
+void AliLoginFrame::DoLogIn() {
+  // When LogIn Button is pressed.
+  
+  AliAnalysisGUI * fAnalysisGUI = dynamic_cast<AliAnalysisGUI*> (const_cast<TGWindow*> (GetMain()));
+  
+  fAnalysisGUI->LogIn(fTextServer->GetText());
+  
+  if(gGrid) {
+    TGridResult* result = gGrid->Command("motd",kFALSE,0);
+    int i=0;
+    const char* line="";
+    TString * msg = new TString();
+    while ((line=result->GetKey(i++,""))) {      
+      msg->Append(line);
+      msg->Append("\n");
+    }
+    new TGMsgBox(gClient->GetRoot(), this, "Welcome", msg->Data(), 0, kMBOk);
+    TTimer::SingleShot(1, "AliLoginFrame", this, "CloseWindow()");
+  }
+}
+
+//___________________________________________________________________________
+void AliLoginFrame::DoCancel() {
+  // When Cancel button is pressed.
+
+  TTimer::SingleShot(150, "AliLoginFrame", this, "CloseWindow()");
+}
diff --git a/ANALYSIS/Aliengui/AliLoginFrame.h b/ANALYSIS/Aliengui/AliLoginFrame.h
new file mode 100644 (file)
index 0000000..70e78b2
--- /dev/null
@@ -0,0 +1,57 @@
+#ifndef ALILOGINFRAME_H
+#define ALILOGINFRAME_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+//-------------------------------------------------------------------------
+//                          Class AliLoginFrame
+//   AliPackageFrame class that describes the login frame of the GUI
+//
+//    Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
+//-------------------------------------------------------------------------
+
+
+
+//////////////////////////////////////////////////////////////////////////
+//                                                                      //
+//                        AliLoginFrame                                 //
+//                                                                      //
+//                      Login frame of the GUI.                         //
+//                                                                      //
+//////////////////////////////////////////////////////////////////////////
+
+#include <TGFrame.h>
+
+class TGLabel;
+class TGButton;
+class TGTextEntry;
+class TGVerticalFrame;
+class TGHorizontalFrame;
+
+//___________________________________________________________________________
+class AliLoginFrame : public TGTransientFrame {
+  
+ public:
+  AliLoginFrame(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options = kVerticalFrame);
+  ~AliLoginFrame();
+  
+  void DoLogIn();
+  void DoCancel();
+  
+  //___________________________________________________________________________
+ private:
+  AliLoginFrame(const AliLoginFrame&); // cp ctor
+  AliLoginFrame& operator= (const AliLoginFrame&); // op=
+  
+  TGLabel            *fLabel1, *fLabel2; //labels
+  TGTextEntry        *fTextServer, *fTextUsername; //server - username text box
+  TGButton           *fButtonLogIn, *fButtonCancel; //login & cancel buttons
+  TGVerticalFrame    *fVFrame1; //vertical frame
+  TGHorizontalFrame  *fHFrame1, *fHFrame2, *fHFrame3; //horizontal frames
+  
+  ClassDef(AliLoginFrame, 0); // LogIn Frame
+};
+
+#endif