(hopefully) Last tweaks to have the embedding straight : the charge of sdigits is...
[u/mrichter/AliRoot.git] / ANALYSIS / Aliengui / AliLoginFrame.cxx
CommitLineData
58744dc7 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// 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//-----------------------------------------------------------------
23
24#include "TGLabel.h"
25#include "TGTextBuffer.h"
26#include "TGTextEntry.h"
27#include "TGridResult.h"
28#include "TTimer.h"
29#include "TGMsgBox.h"
30
31#include "TGrid.h"
32
33#include "AliAnalysisGUI.h"
34#include "AliLoginFrame.h"
35
36ClassImp(AliLoginFrame)
37
38//___________________________________________________________________________
a313abd0 39AliLoginFrame::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),
44 fVFrame1(0),
45 fHFrame1(0), fHFrame2(0), fHFrame3(0) {
58744dc7 46 // Constructor.
47
48 SetWindowName("Login");
49
50 // create the Vertical Frame for the text fields and buttons
51 fVFrame1 = new TGVerticalFrame(this, 400, 150, kFixedWidth);
52
53 // create the Horizontal Frame 1
54 fHFrame1 = new TGHorizontalFrame(this, 400, 50, kFixedWidth);
55
56 fLabel1 = new TGLabel(fHFrame1, new TGString("Server"));
57 fTextServer = new TGTextEntry(fHFrame1, new TGTextBuffer(35));
58 fTextServer->SetText("alien://");
59
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));
64
65 fVFrame1->AddFrame(fHFrame1,new TGLayoutHints(kLHintsTop));
66
67 // Create the Horizontal for the buttons
68 fHFrame3 = new TGHorizontalFrame(this, 400, 50, kFixedWidth);
69
70 fButtonLogIn = new TGTextButton(fHFrame3, "Log In", 1);
71 fButtonLogIn->Connect("Clicked()", "AliLoginFrame", this, "DoLogIn()");
72
73 fButtonCancel = new TGTextButton(fHFrame3, "Cancel", 2);
74 fButtonCancel->Connect("Clicked()", "AliLoginFrame", this, "DoCancel()");
75
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));
80
81 fHFrame3->Resize();
82
83 fVFrame1->AddFrame(fHFrame3, new TGLayoutHints(kLHintsBottom));
84
85 AddFrame(fVFrame1, new TGLayoutHints(kLHintsTop));
86
87 MapSubwindows();
88 Resize();
89 MapWindow();
90}
91
92//___________________________________________________________________________
93AliLoginFrame::~AliLoginFrame() {
94 // Destructor.
95
96 DeleteWindow();
97 SetCleanup(kDeepCleanup);
98}
99
100//___________________________________________________________________________
101void AliLoginFrame::DoLogIn() {
102 // When LogIn Button is pressed.
103
104 AliAnalysisGUI * fAnalysisGUI = dynamic_cast<AliAnalysisGUI*> (const_cast<TGWindow*> (GetMain()));
105
106 fAnalysisGUI->LogIn(fTextServer->GetText());
107
108 if(gGrid) {
109 TGridResult* result = gGrid->Command("motd",kFALSE,0);
110 int i=0;
111 const char* line="";
112 TString * msg = new TString();
113 while ((line=result->GetKey(i++,""))) {
114 msg->Append(line);
115 msg->Append("\n");
116 }
117 new TGMsgBox(gClient->GetRoot(), this, "Welcome", msg->Data(), 0, kMBOk);
118 TTimer::SingleShot(1, "AliLoginFrame", this, "CloseWindow()");
119 }
120}
121
122//___________________________________________________________________________
123void AliLoginFrame::DoCancel() {
124 // When Cancel button is pressed.
125
126 TTimer::SingleShot(150, "AliLoginFrame", this, "CloseWindow()");
127}