1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-----------------------------------------------------------------
19 // AliLoginFrame class
20 // The class that deals with the login frame of the GUI
21 // Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
22 //-----------------------------------------------------------------
25 #include "TGTextBuffer.h"
26 #include "TGTextEntry.h"
27 #include "TGridResult.h"
33 #include "AliAnalysisGUI.h"
34 #include "AliLoginFrame.h"
36 ClassImp(AliLoginFrame)
38 //___________________________________________________________________________
39 AliLoginFrame::AliLoginFrame(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options) :
40 TGTransientFrame(p, main, w, h, options),
41 fLabel1(0), fLabel2(0),
42 fTextServer(0), fTextUsername(0),
43 fButtonLogIn(0), fButtonCancel(0),
45 fHFrame1(0), fHFrame2(0), fHFrame3(0) {
48 SetWindowName("Login");
50 // create the Vertical Frame for the text fields and buttons
51 fVFrame1 = new TGVerticalFrame(this, 400, 150, kFixedWidth);
53 // create the Horizontal Frame 1
54 fHFrame1 = new TGHorizontalFrame(this, 400, 50, kFixedWidth);
56 fLabel1 = new TGLabel(fHFrame1, new TGString("Server"));
57 fTextServer = new TGTextEntry(fHFrame1, new TGTextBuffer(35));
58 fTextServer->SetText("alien://");
60 fHFrame1->AddFrame(fLabel1,
61 new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 5, 5, 5));
62 fHFrame1->AddFrame(fTextServer,
63 new TGLayoutHints(kLHintsRight | kLHintsTop, 5, 5, 5, 5));
65 fVFrame1->AddFrame(fHFrame1,new TGLayoutHints(kLHintsTop));
67 // Create the Horizontal for the buttons
68 fHFrame3 = new TGHorizontalFrame(this, 400, 50, kFixedWidth);
70 fButtonLogIn = new TGTextButton(fHFrame3, "Log In", 1);
71 fButtonLogIn->Connect("Clicked()", "AliLoginFrame", this, "DoLogIn()");
73 fButtonCancel = new TGTextButton(fHFrame3, "Cancel", 2);
74 fButtonCancel->Connect("Clicked()", "AliLoginFrame", this, "DoCancel()");
76 fHFrame3->AddFrame(fButtonLogIn,new TGLayoutHints
77 (kLHintsCenterY | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2));
78 fHFrame3->AddFrame(fButtonCancel,new TGLayoutHints
79 (kLHintsCenterY | kLHintsRight | kLHintsExpandX, 2, 2, 2, 2));
83 fVFrame1->AddFrame(fHFrame3, new TGLayoutHints(kLHintsBottom));
85 AddFrame(fVFrame1, new TGLayoutHints(kLHintsTop));
92 //___________________________________________________________________________
93 AliLoginFrame::~AliLoginFrame() {
97 SetCleanup(kDeepCleanup);
100 //___________________________________________________________________________
101 void AliLoginFrame::DoLogIn() {
102 // When LogIn Button is pressed.
104 AliAnalysisGUI * fAnalysisGUI = dynamic_cast<AliAnalysisGUI*> (const_cast<TGWindow*> (GetMain()));
106 fAnalysisGUI->LogIn(fTextServer->GetText());
109 TGridResult* result = gGrid->Command("motd",kFALSE,0);
112 TString * msg = new TString();
113 while ((line=result->GetKey(i++,""))) {
117 new TGMsgBox(gClient->GetRoot(), this, "Welcome", msg->Data(), 0, kMBOk);
118 TTimer::SingleShot(1, "AliLoginFrame", this, "CloseWindow()");
122 //___________________________________________________________________________
123 void AliLoginFrame::DoCancel() {
124 // When Cancel button is pressed.
126 TTimer::SingleShot(150, "AliLoginFrame", this, "CloseWindow()");