From: panos Date: Mon, 13 Nov 2006 12:57:16 +0000 (+0000) Subject: Adding the AliLoginFrame class: the login window of the GUI. X-Git-Url: http://git.uio.no/git/?a=commitdiff_plain;h=58744dc7d675799acbfb2ec7b2c1dbf5c524fc91;p=u%2Fmrichter%2FAliRoot.git Adding the AliLoginFrame class: the login window of the GUI. --- diff --git a/ANALYSIS/Aliengui/AliLoginFrame.cxx b/ANALYSIS/Aliengui/AliLoginFrame.cxx new file mode 100644 index 00000000000..cb36364f060 --- /dev/null +++ b/ANALYSIS/Aliengui/AliLoginFrame.cxx @@ -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 (const_cast (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 index 00000000000..70e78b2e00f --- /dev/null +++ b/ANALYSIS/Aliengui/AliLoginFrame.h @@ -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 + +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