]>
Commit | Line | Data |
---|---|---|
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 | ||
36 | ClassImp(AliLoginFrame) | |
37 | ||
38 | //___________________________________________________________________________ | |
39 | AliLoginFrame::AliLoginFrame(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options) : TGTransientFrame(p, main, w, h, options) { | |
40 | // Constructor. | |
41 | ||
42 | SetWindowName("Login"); | |
43 | ||
44 | // create the Vertical Frame for the text fields and buttons | |
45 | fVFrame1 = new TGVerticalFrame(this, 400, 150, kFixedWidth); | |
46 | ||
47 | // create the Horizontal Frame 1 | |
48 | fHFrame1 = new TGHorizontalFrame(this, 400, 50, kFixedWidth); | |
49 | ||
50 | fLabel1 = new TGLabel(fHFrame1, new TGString("Server")); | |
51 | fTextServer = new TGTextEntry(fHFrame1, new TGTextBuffer(35)); | |
52 | fTextServer->SetText("alien://"); | |
53 | ||
54 | fHFrame1->AddFrame(fLabel1, | |
55 | new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 5, 5, 5)); | |
56 | fHFrame1->AddFrame(fTextServer, | |
57 | new TGLayoutHints(kLHintsRight | kLHintsTop, 5, 5, 5, 5)); | |
58 | ||
59 | fVFrame1->AddFrame(fHFrame1,new TGLayoutHints(kLHintsTop)); | |
60 | ||
61 | // Create the Horizontal for the buttons | |
62 | fHFrame3 = new TGHorizontalFrame(this, 400, 50, kFixedWidth); | |
63 | ||
64 | fButtonLogIn = new TGTextButton(fHFrame3, "Log In", 1); | |
65 | fButtonLogIn->Connect("Clicked()", "AliLoginFrame", this, "DoLogIn()"); | |
66 | ||
67 | fButtonCancel = new TGTextButton(fHFrame3, "Cancel", 2); | |
68 | fButtonCancel->Connect("Clicked()", "AliLoginFrame", this, "DoCancel()"); | |
69 | ||
70 | fHFrame3->AddFrame(fButtonLogIn,new TGLayoutHints | |
71 | (kLHintsCenterY | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2)); | |
72 | fHFrame3->AddFrame(fButtonCancel,new TGLayoutHints | |
73 | (kLHintsCenterY | kLHintsRight | kLHintsExpandX, 2, 2, 2, 2)); | |
74 | ||
75 | fHFrame3->Resize(); | |
76 | ||
77 | fVFrame1->AddFrame(fHFrame3, new TGLayoutHints(kLHintsBottom)); | |
78 | ||
79 | AddFrame(fVFrame1, new TGLayoutHints(kLHintsTop)); | |
80 | ||
81 | MapSubwindows(); | |
82 | Resize(); | |
83 | MapWindow(); | |
84 | } | |
85 | ||
86 | //___________________________________________________________________________ | |
87 | AliLoginFrame::~AliLoginFrame() { | |
88 | // Destructor. | |
89 | ||
90 | DeleteWindow(); | |
91 | SetCleanup(kDeepCleanup); | |
92 | } | |
93 | ||
94 | //___________________________________________________________________________ | |
95 | void AliLoginFrame::DoLogIn() { | |
96 | // When LogIn Button is pressed. | |
97 | ||
98 | AliAnalysisGUI * fAnalysisGUI = dynamic_cast<AliAnalysisGUI*> (const_cast<TGWindow*> (GetMain())); | |
99 | ||
100 | fAnalysisGUI->LogIn(fTextServer->GetText()); | |
101 | ||
102 | if(gGrid) { | |
103 | TGridResult* result = gGrid->Command("motd",kFALSE,0); | |
104 | int i=0; | |
105 | const char* line=""; | |
106 | TString * msg = new TString(); | |
107 | while ((line=result->GetKey(i++,""))) { | |
108 | msg->Append(line); | |
109 | msg->Append("\n"); | |
110 | } | |
111 | new TGMsgBox(gClient->GetRoot(), this, "Welcome", msg->Data(), 0, kMBOk); | |
112 | TTimer::SingleShot(1, "AliLoginFrame", this, "CloseWindow()"); | |
113 | } | |
114 | } | |
115 | ||
116 | //___________________________________________________________________________ | |
117 | void AliLoginFrame::DoCancel() { | |
118 | // When Cancel button is pressed. | |
119 | ||
120 | TTimer::SingleShot(150, "AliLoginFrame", this, "CloseWindow()"); | |
121 | } |